Stellarium 0.15.0
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  {
82  equatorialJ2000,
83  equatorial,
84  horizontal,
85  galactic,
86  ecliptic,
87  eclipticJ2000
88  };
89 
90  SearchDialog(QObject* parent);
91  virtual ~SearchDialog();
93  void styleChanged();
94  bool eventFilter(QObject *object, QEvent *event);
95 
96 public slots:
97  void retranslate();
99  void setSimpleStyle();
100 
103  {
104  currentCoordinateSystem = cs;
105  }
108  {
109  return currentCoordinateSystem;
110  }
112  QString getCurrentCoordinateSystemKey(void) const;
114  void setCurrentCoordinateSystemKey(QString key);
115 
116  void setCoordinateSystem(int csID);
117  void populateCoordinateSystemsList();
118  void populateCoordinateAxis();
119 
120 protected:
121  Ui_searchDialogForm* ui;
123  virtual void createDialogContent();
124 
125 private slots:
126  void greekLetterClicked();
128  void onSimbadStatusChanged();
130  void onSearchTextChanged(const QString& text);
131 
132  void gotoObject();
133  void gotoObject(const QString& nameI18n);
134  // for going from list views
135  void gotoObject(QListWidgetItem* item);
136 
137  void searchListChanged(const QString& newText);
138 
140  void manualPositionChanged();
141 
143  void enableSimbadSearch(bool enable);
144 
146  void enableStartOfWordsAutofill(bool enable);
147 
149  void setHasSelectedFlag();
150 
152  void selectSimbadServer(int index);
153 
155  void updateListWidget(int index);
156 
157  // retranslate/recreate tab
158  void updateListTab();
159 
160  void showContextMenu(const QPoint &pt);
161 
162  void pasteAndGo();
163 
164 private:
165  class SimbadSearcher* simbadSearcher;
166  class SimbadLookupReply* simbadReply;
167  QMap<QString, Vec3d> simbadResults;
168  class StelObjectMgr* objectMgr;
169  class QSettings* conf;
170 
171  QString substituteGreek(const QString& keyString);
172  QString getGreekLetterByName(const QString& potentialGreekLetterName);
173  QHash<QString, QString> greekLetters;
175  bool flagHasSelectedText;
176 
177  bool useStartOfWords;
178  bool useSimbad;
180  QString simbadServerUrl;
181  void populateSimbadServerList();
183  static const char* DEF_SIMBAD_URL;
184 
185  // The current coordinate system
186  CoordinateSystem currentCoordinateSystem;
187 
188 public:
189  static QString extSearchText;
190 
191 };
192 
193 #endif // _SEARCHDIALOG_HPP_
194 
void setCurrentCoordinateSystem(CoordinateSystem cs)
Set the current coordinate system.
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:52
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.
CoordinateSystem getCurrentCoordinateSystem() const
Get the current coordinate system.
CoordinateSystem
Available coordinate systems.
The sky object search dialog.
Provides lookup features into the online Simbad service from CDS.