00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SIMBADSEARCHER_HPP_
00020 #define SIMBADSEARCHER_HPP_
00021
00022 #include "VecMath.hpp"
00023 #include <QObject>
00024 #include <QMap>
00025
00026 class QNetworkReply;
00027 class QNetworkAccessManager;
00028
00032 class SimbadLookupReply : public QObject
00033 {
00034 Q_OBJECT
00035 Q_ENUMS(SimbadLookupStatus);
00036
00037 public:
00038 friend class SimbadSearcher;
00039
00041 enum SimbadLookupStatus
00042 {
00043 SimbadLookupQuerying,
00044 SimbadLookupErrorOccured,
00045 SimbadLookupFinished
00046 };
00047
00048 ~SimbadLookupReply();
00049
00051 QMap<QString, Vec3d> getResults() const {return resultPositions;}
00052
00054 SimbadLookupStatus getCurrentStatus() const {return currentStatus;}
00055
00057 QString getCurrentStatusString() const;
00058
00060 QString getErrorString() const {return errorString;}
00061
00062 signals:
00064 void statusChanged();
00065
00066 private slots:
00067 void httpQueryFinished();
00068 void delayTimerCompleted();
00069
00070 private:
00072 SimbadLookupReply(const QString& url, QNetworkAccessManager* mgr, int delayMs=500);
00073
00074 QString url;
00075
00077 QNetworkReply* reply;
00078 QNetworkAccessManager* netMgr;
00079
00081 QMap<QString, Vec3d> resultPositions;
00082
00084 SimbadLookupStatus currentStatus;
00085
00087 QString errorString;
00088 };
00089
00090
00094 class SimbadSearcher : public QObject
00095 {
00096 Q_OBJECT
00097
00098 public:
00099 SimbadSearcher(QObject* parent);
00100
00107 SimbadLookupReply* lookup(const QString& objectName, int maxNbResult=1, int delayMs=500);
00108
00109 private:
00111 QNetworkAccessManager* networkMgr;
00112 };
00113
00114 #endif