Stellarium 0.13.3
SearchDialog.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2008 Guillaume Chereau
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18 */
19 
20 #ifndef _SEARCHDIALOG_HPP_
21 #define _SEARCHDIALOG_HPP_
22 
23 #include <QObject>
24 #include <QLabel>
25 #include <QMap>
26 #include <QHash>
27 #include "StelDialog.hpp"
28 #include "VecMath.hpp"
29 
30 // pre declaration of the ui class
31 class Ui_searchDialogForm;
32 
34 {
35  bool operator()(const QString &s1, const QString &s2) const
36  {
37  return s1.length() < s2.length();
38  }
39 };
40 
44 class CompletionLabel : public QLabel
45 {
46  Q_OBJECT
47 
48 public:
49  CompletionLabel(QWidget* parent=0);
50  ~CompletionLabel();
51 
52  QString getSelected(void);
53  void setValues(const QStringList&);
54  bool isEmpty() const {return values.isEmpty();}
55  void appendValues(const QStringList&);
56  void clearValues();
57 
58 public slots:
59  void selectNext();
60  void selectPrevious();
61  void selectFirst();
62 
63 private:
64  void updateText();
65  int selectedIdx;
66  QStringList values;
67 };
68 
69 QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
70 
71 class SearchDialog : public StelDialog
74 {
75  Q_OBJECT
76  Q_ENUMS(CoordinateSystem)
77 
78 public:
81  enum CoordinateSystem
82  {
83  equatorialJ2000,
84  equatorial,
85  horizontal,
86  galactic
87  };
88 
89  SearchDialog(QObject* parent);
90  virtual ~SearchDialog();
92  void styleChanged();
93  bool eventFilter(QObject *object, QEvent *event);
94 
95 public slots:
96  void retranslate();
98  void setSimpleStyle();
99 
101  void setCurrentCoordinateSystem(CoordinateSystem cs)
102  {
103  currentCoordinateSystem = cs;
104  }
106  CoordinateSystem getCurrentCoordinateSystem() const
107  {
108  return currentCoordinateSystem;
109  }
111  QString getCurrentCoordinateSystemKey(void) const;
113  void setCurrentCoordinateSystemKey(QString key);
114 
115  void setCoordinateSystem(int csID);
116  void populateCoordinateSystemsList();
117  void populateCoordinateAxis();
118 
119 protected:
120  Ui_searchDialogForm* ui;
122  virtual void createDialogContent();
123 
124 private slots:
125  void greekLetterClicked();
127  void onSimbadStatusChanged();
129  void onSearchTextChanged(const QString& text);
130 
131  void gotoObject();
132  void gotoObject(const QString& nameI18n);
133  // for going from list views
134  void gotoObject(QListWidgetItem* item);
135 
136  void searchListChanged(const QString& newText);
137 
139  void manualPositionChanged();
140 
142  void enableSimbadSearch(bool enable);
143 
145  void enableStartOfWordsAutofill(bool enable);
146 
148  void setHasSelectedFlag();
149 
151  void selectSimbadServer(int index);
152 
154  void updateListWidget(int index);
155 
156  // retranslate/recreate tab
157  void updateListTab();
158 
159  void showContextMenu(const QPoint &pt);
160 
161  void pasteAndGo();
162 
163 private:
164  class SimbadSearcher* simbadSearcher;
165  class SimbadLookupReply* simbadReply;
166  QMap<QString, Vec3d> simbadResults;
167  class StelObjectMgr* objectMgr;
168  class QSettings* conf;
169 
170  QString substituteGreek(const QString& keyString);
171  QString getGreekLetterByName(const QString& potentialGreekLetterName);
172  QHash<QString, QString> greekLetters;
174  bool flagHasSelectedText;
175 
176  bool useStartOfWords;
177  bool useSimbad;
179  QString simbadServerUrl;
180  void populateSimbadServerList();
182  static const char* DEF_SIMBAD_URL;
183 
184  // The current coordinate system
185  CoordinateSystem currentCoordinateSystem;
186 };
187 
188 #endif // _SEARCHDIALOG_HPP_
189 
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:44
Contains all the information about a current simbad lookup query.
Display a list of results matching the search string, and allow to tab through those selections...
Manage the selection and queries on one or more StelObjects.
The sky object search dialog.
Provides lookup features into the online Simbad service from CDS.