Stellarium 0.13.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 
77 public:
78  SearchDialog(QObject* parent);
79  virtual ~SearchDialog();
81  void styleChanged();
82  bool eventFilter(QObject *object, QEvent *event);
83 
84 public slots:
85  void retranslate();
87  void setSimpleStyle();
88 
89 protected:
90  Ui_searchDialogForm* ui;
92  virtual void createDialogContent();
93 
94 private slots:
95  void greekLetterClicked();
97  void onSimbadStatusChanged();
99  void onSearchTextChanged(const QString& text);
100 
101  void gotoObject();
102  void gotoObject(const QString& nameI18n);
103  // for going from list views
104  void gotoObject(QListWidgetItem* item);
105 
106  void searchListChanged(const QString& newText);
107 
109  void manualPositionChanged();
110 
112  void enableSimbadSearch(bool enable);
113 
115  void enableStartOfWordsAutofill(bool enable);
116 
118  void setHasSelectedFlag();
119 
121  void selectSimbadServer(int index);
122 
124  void updateListWidget(int index);
125 
126  // retranslate/recreate tab
127  void updateListTab();
128 
129  void showContextMenu(const QPoint &pt);
130 
131  void pasteAndGo();
132 
133 private:
134  class SimbadSearcher* simbadSearcher;
135  class SimbadLookupReply* simbadReply;
136  QMap<QString, Vec3d> simbadResults;
137  class StelObjectMgr* objectMgr;
138 
139  QString substituteGreek(const QString& keyString);
140  QString getGreekLetterByName(const QString& potentialGreekLetterName);
141  QHash<QString, QString> greekLetters;
143  bool flagHasSelectedText;
144 
145  bool useStartOfWords;
146  bool useSimbad;
148  QString simbadServerUrl;
149  void populateSimbadServerList();
151  static const char* DEF_SIMBAD_URL;
152 };
153 
154 #endif // _SEARCHDIALOG_HPP_
155 
Definition: SearchDialog.hpp:33
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:45
Contains all the information about a current simbad lookup query.
Definition: SimbadSearcher.hpp:32
Display a list of results matching the search string, and allow to tab through those selections...
Definition: SearchDialog.hpp:44
Manage the selection and queries on one or more StelObjects.
Definition: StelObjectMgr.hpp:36
The sky object search dialog.
Definition: SearchDialog.hpp:69
Provides lookup features into the online Simbad service from CDS.
Definition: SimbadSearcher.hpp:94