]> git.mxchange.org Git - flightgear.git/blob - src/GUI/AddCatalogDialog.hxx
Code cleanups, code updates and fix at least on (possible) devide-by-zero
[flightgear.git] / src / GUI / AddCatalogDialog.hxx
1 // AddCatalogDialog.hxx - part of GUI launcher using Qt5
2 //
3 // Written by James Turner, started March 2015.
4 //
5 // Copyright (C) 2015 James Turner <zakalawe@mac.com>
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21 #ifndef FG_GUI_ADDCATALOGDIALOG_HXX
22 #define FG_GUI_ADDCATALOGDIALOG_HXX
23
24 #include <QDialog>
25 #include <QUrl>
26
27 #include <simgear/package/Root.hxx>
28 #include <simgear/package/Catalog.hxx>
29
30 namespace Ui {
31 class AddCatalogDialog;
32 }
33
34 class AddCatalogDialog : public QDialog
35 {
36     Q_OBJECT
37
38 public:
39     explicit AddCatalogDialog(QWidget *parent,
40                               simgear::pkg::RootRef root);
41     ~AddCatalogDialog();
42
43     simgear::pkg::CatalogRef addedCatalog();
44
45     void setUrlAndDownload(QUrl url);
46 private slots:
47     virtual void reject();
48     virtual void accept();
49
50     void onUrlTextChanged();
51 private:
52     void startDownload();
53     void updateUi();
54
55     // callback from the catalog
56     void onCatalogStatusChanged(simgear::pkg::Catalog* cat);
57
58     enum State {
59         STATE_START = 0, // awaiting user input on first screen
60         STATE_DOWNLOADING = 1, // in-progress, showing progress page
61         STATE_FINISHED = 2, // catalog added ok, showing summary page
62         STATE_DOWNLOAD_FAILED // download checks failed for some reason
63
64     };
65
66     State m_state;
67
68     Ui::AddCatalogDialog *ui;
69     simgear::pkg::RootRef m_packageRoot;
70     QUrl m_catalogUrl;
71     simgear::pkg::CatalogRef m_result;
72 };
73
74 #endif // FG_GUI_ADDCATALOGDIALOG_HXX