Stellarium 0.15.2
MpcImportWindow.hpp
1 /*
2  * Solar System editor plug-in for Stellarium
3  *
4  * Copyright (C) 2010-2011 Bogdan Marinov
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _MPC_IMPORT_WINDOW_
22 #define _MPC_IMPORT_WINDOW_
23 
24 #include <QObject>
25 #include <QNetworkAccessManager>
26 #include <QNetworkReply>
27 #include <QStandardItemModel>
28 #include "StelDialog.hpp"
29 
30 #include "SolarSystemEditor.hpp"
31 
32 class Ui_mpcImportWindow;
33 
38 {
39  Q_OBJECT
40 public:
41  enum ImportType {
42  MpcComets,
43  MpcMinorPlanets
44  };
45 
47  virtual ~MpcImportWindow();
48 
49 public slots:
50  void retranslate();
51 
52 signals:
53  void objectsImported();
54 
55 private slots:
56  //Radio buttons for type
57  void switchImportType(bool checked);
58 
59  //File
60  void selectFile();
61 
62  //Download
63  void pasteClipboardURL();
64  void bookmarkSelected(QString);
65 
66  //Buttons for the list tab
67  void acquireObjectData();
68  void abortDownload();
69 
70  //Online search
71  void sendQuery();
72  void sendQueryToUrl(QUrl url);
73  void abortQuery();
74  void updateCountdown();
75  void resetNotFound();
76 
77  //Network
78  void updateDownloadProgress(qint64 bytesReceived, qint64 bytesTotal);
79  void updateQueryProgress(qint64 bytesReceived, qint64 bytesTotal);
80  void downloadComplete(QNetworkReply * reply);
81  void receiveQueryReply(QNetworkReply * reply);
82  void readQueryReply(QNetworkReply * reply);
83 
85  void markAll();
87  void unmarkAll();
88  void addObjects();
89  void discardObjects();
90 
92  void resetDialog();
93 
94 private:
95  SolarSystemEditor * ssoManager;
96  QList<SsoElements> candidatesForAddition;
97  QList<SsoElements> candidatesForUpdate;
98  QStandardItemModel * candidateObjectsModel;
99 
100  ImportType importType;
101 
102  void updateTexts();
103 
105  SsoElements readElementsFromString(QString elements);
107  QList<SsoElements> readElementsFromFile(ImportType type, QString filePath);
108 
109  void populateBookmarksList();
110  //void populateCandidateObjects();
111  void populateCandidateObjects(QList<SsoElements>);
112  void enableInterface(bool enable);
113 
114  //Downloading
115  QNetworkAccessManager * networkManager;
116  QNetworkReply * downloadReply;
117  QNetworkReply * queryReply;
118  class StelProgressController * downloadProgressBar;
119  class StelProgressController * queryProgressBar;
120  void startDownload(QString url);
121  void deleteDownloadProgressBar();
122  void deleteQueryProgressBar();
123 
124  typedef QHash<QString,QString> Bookmarks;
125  QHash<ImportType, Bookmarks> bookmarks;
126  void loadBookmarks();
127  void loadBookmarksGroup(QVariantMap source, Bookmarks & bookmarkGroup);
128  void saveBookmarks();
129  void saveBookmarksGroup(Bookmarks & bookmarkGroup, QVariantMap & output);
130 
131  //Online search
132  QString query;
133  int countdown;
134  QTimer * countdownTimer;
135  void startCountdown();
136  void resetCountdown();
137 
138 protected:
139  virtual void createDialogContent();
140  Ui_mpcImportWindow * ui;
141 };
142 
143 #endif //_MPC_IMPORT_WINDOW_
Base class for all the GUI windows in Stellarium.
Definition: StelDialog.hpp:72
Main class of the Solar System Editor plug-in.
Maintain the state of a progress bar.
virtual void createDialogContent()
Initialize the dialog widgets and connect the signals/slots.
Window for importing orbital elements from the Minor Planet Center.