Stellarium 0.14.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  enum CoordinateSystem
82  {
83  equatorialJ2000,
84  equatorial,
85  horizontal,
86  galactic,
87  ecliptic,
88  eclipticJ2000
89  };
90 
91  SearchDialog(QObject* parent);
92  virtual ~SearchDialog();
94  void styleChanged();
95  bool eventFilter(QObject *object, QEvent *event);
96 
97 public slots:
98  void retranslate();
100  void setSimpleStyle();
101 
103  void setCurrentCoordinateSystem(CoordinateSystem cs)
104  {
105  currentCoordinateSystem = cs;
106  }
108  CoordinateSystem getCurrentCoordinateSystem() const
109  {
110  return currentCoordinateSystem;
111  }
113  QString getCurrentCoordinateSystemKey(void) const;
115  void setCurrentCoordinateSystemKey(QString key);
116 
117  void setCoordinateSystem(int csID);
118  void populateCoordinateSystemsList();
119  void populateCoordinateAxis();
120 
121 protected:
122  Ui_searchDialogForm* ui;
124  virtual void createDialogContent();
125 
126 private slots:
127  void greekLetterClicked();
129  void onSimbadStatusChanged();
131  void onSearchTextChanged(const QString& text);
132 
133  void gotoObject();
134  void gotoObject(const QString& nameI18n);
135  // for going from list views
136  void gotoObject(QListWidgetItem* item);
137 
138  void searchListChanged(const QString& newText);
139 
141  void manualPositionChanged();
142 
144  void enableSimbadSearch(bool enable);
145 
147  void enableStartOfWordsAutofill(bool enable);
148 
150  void setHasSelectedFlag();
151 
153  void selectSimbadServer(int index);
154 
156  void updateListWidget(int index);
157 
158  // retranslate/recreate tab
159  void updateListTab();
160 
161  void showContextMenu(const QPoint &pt);
162 
163  void pasteAndGo();
164 
165 private:
166  class SimbadSearcher* simbadSearcher;
167  class SimbadLookupReply* simbadReply;
168  QMap<QString, Vec3d> simbadResults;
169  class StelObjectMgr* objectMgr;
170  class QSettings* conf;
171 
172  QString substituteGreek(const QString& keyString);
173  QString getGreekLetterByName(const QString& potentialGreekLetterName);
174  QHash<QString, QString> greekLetters;
176  bool flagHasSelectedText;
177 
178  bool useStartOfWords;
179  bool useSimbad;
181  QString simbadServerUrl;
182  void populateSimbadServerList();
184  static const char* DEF_SIMBAD_URL;
185 
186  // The current coordinate system
187  CoordinateSystem currentCoordinateSystem;
188 };
189 
190 #endif // _SEARCHDIALOG_HPP_
191 
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.