Stellarium 0.13.0
SimbadSearcher.hpp
1 /*
2  * Copyright (C) 2008 Fabien Chereau
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
17  */
18 
19 #ifndef SIMBADSEARCHER_HPP_
20 #define SIMBADSEARCHER_HPP_
21 
22 #include "VecMath.hpp"
23 #include <QObject>
24 #include <QMap>
25 
26 class QNetworkReply;
27 class QNetworkAccessManager;
28 
32 class SimbadLookupReply : public QObject
33 {
34  Q_OBJECT
35  Q_ENUMS(SimbadLookupStatus)
36 
37 public:
38  friend class SimbadSearcher;
39 
41  enum SimbadLookupStatus
42  {
43  SimbadLookupQuerying,
44  SimbadLookupErrorOccured,
45  SimbadLookupFinished
46  };
47 
49 
51  QMap<QString, Vec3d> getResults() const {return resultPositions;}
52 
54  SimbadLookupStatus getCurrentStatus() const {return currentStatus;}
55 
57  QString getCurrentStatusString() const;
58 
60  QString getErrorString() const {return errorString;}
61 
62 signals:
64  void statusChanged();
65 
66 private slots:
67  void httpQueryFinished();
68  void delayTimerCompleted();
69 
70 private:
72  SimbadLookupReply(const QString& url, QNetworkAccessManager* mgr, int delayMs=500);
73 
74  QString url;
75 
77  QNetworkReply* reply;
78  QNetworkAccessManager* netMgr;
79 
81  QMap<QString, Vec3d> resultPositions;
82 
84  SimbadLookupStatus currentStatus;
85 
87  QString errorString;
88 };
89 
90 
94 class SimbadSearcher : public QObject
95 {
96  Q_OBJECT
97 
98 public:
99  SimbadSearcher(QObject* parent);
100 
108  SimbadLookupReply* lookup(const QString& serverUrl, const QString& objectName, int maxNbResult=1, int delayMs=500);
109 
110 private:
112  QNetworkAccessManager* networkMgr;
113 };
114 
115 #endif /*SIMBADSEARCHER_HPP_*/
void statusChanged()
Triggered when the lookup status change.
Contains all the information about a current simbad lookup query.
Provides lookup features into the online Simbad service from CDS.
SimbadLookupReply * lookup(const QString &serverUrl, const QString &objectName, int maxNbResult=1, int delayMs=500)
Lookup in Simbad for object which have a name starting with objectName.