Stellarium 0.12.4
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 
36 class CompletionLabel : public QLabel
37 {
38  Q_OBJECT
39 
40 public:
41  CompletionLabel(QWidget* parent=0);
42  ~CompletionLabel();
43 
44  QString getSelected(void);
45  void setValues(const QStringList&);
46  bool isEmpty() const {return values.isEmpty();}
47  void appendValues(const QStringList&);
48  void clearValues();
49 
50 public slots:
51  void selectNext();
52  void selectPrevious();
53  void selectFirst();
54 
55 private:
56  void updateText();
57  int selectedIdx;
58  QStringList values;
59 };
60 
61 QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
62 
63 
64 
65 class SearchDialog : public StelDialog
66 {
67  Q_OBJECT
68 
69 public:
70  SearchDialog();
71  virtual ~SearchDialog();
73  void styleChanged();
74  bool eventFilter(QObject *object, QEvent *event);
75 
76 public slots:
77  void retranslate();
79  void setVisible(bool);
81  void setSimpleStyle();
82 
83 protected:
84  Ui_searchDialogForm* ui;
86  virtual void createDialogContent();
87 
88 private slots:
89  void greekLetterClicked();
91  void onSimbadStatusChanged();
93  void onSearchTextChanged(const QString& text);
94 
95  void gotoObject();
96  void gotoObject(const QString& nameI18n);
97  // for going from list views
98  void gotoObject(QListWidgetItem* item);
99 
100  void searchListChanged(const QString& newText);
101 
103  void manualPositionChanged();
104 
106  void enableSimbadSearch(bool enable);
107 
109  void enableStartOfWordsAutofill(bool enable);
110 
112  void setHasSelectedFlag();
113 
115  void selectSimbadServer(int index);
116 
118  void updateListWidget(int index);
119 
120  // retranslate/recreate tab
121  void updateListTab();
122 
123 private:
124  class SimbadSearcher* simbadSearcher;
125  class SimbadLookupReply* simbadReply;
126  QMap<QString, Vec3d> simbadResults;
127  class StelObjectMgr* objectMgr;
128 
129  QString substituteGreek(const QString& keyString);
130  QString getGreekLetterByName(const QString& potentialGreekLetterName);
131  QHash<QString, QString> greekLetters;
133  bool flagHasSelectedText;
134 
135  bool useStartOfWords;
136  bool useSimbad;
138  QString simbadServerUrl;
139  void populateSimbadServerList();
141  static const char* DEF_SIMBAD_URL;
142 };
143 
144 #endif // _SEARCHDIALOG_HPP_
145