Stellarium 0.15.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  friend class SimbadSearcher;
38 public:
39 
42  {
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 
63  void deleteNetworkReply();
64 
65 signals:
67  void statusChanged();
68 
69 private slots:
70  void httpQueryFinished();
71  void delayTimerCompleted();
72 
73 private:
75  SimbadLookupReply(const QString& url, QNetworkAccessManager* mgr, int delayMs=500);
76 
77  QString url;
78 
80  QNetworkReply* reply;
81  QNetworkAccessManager* netMgr;
82 
84  QMap<QString, Vec3d> resultPositions;
85 
87  SimbadLookupStatus currentStatus;
88 
90  QString errorString;
91 };
92 
93 
97 class SimbadSearcher : public QObject
98 {
99  Q_OBJECT
100 
101 public:
102  SimbadSearcher(QObject* parent = NULL);
103 
111  SimbadLookupReply* lookup(const QString& serverUrl, const QString& objectName, int maxNbResult=1, int delayMs=500);
112 
113 private:
115  QNetworkAccessManager* networkMgr;
116 };
117 
118 #endif /*SIMBADSEARCHER_HPP_*/
Simbad is still being queried.
QString getErrorString() const
Get the error descrition string. Return empty string if no error occured.
void statusChanged()
Triggered when the lookup status change.
The query is over. The reply can be deleted.
void deleteNetworkReply()
Explicitly delete the internal QNetworkReply. Must not be called from a QNetworkReply signal...
Contains all the information about a current simbad lookup query.
An error occured while looking up Simbad. Call getErrorString() for a description of the error...
SimbadLookupStatus getCurrentStatus() const
Get the current status.
QString getCurrentStatusString() const
Get a I18n string describing the current status. It can be used e.g for reporting in widgets...
Provides lookup features into the online Simbad service from CDS.
QMap< QString, Vec3d > getResults() const
Get the result list of matching objectName/position.
SimbadLookupStatus
Possible status for a simbad query.
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.