]> git.mxchange.org Git - flightgear.git/blob - src/GUI/QtLauncher.hxx
Correct handling of updating packages
[flightgear.git] / src / GUI / QtLauncher.hxx
1 // QtLauncher.hxx - GUI launcher dialog using Qt5
2 //
3 // Written by James Turner, started December 2014.
4 //
5 // Copyright (C) 2014 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_QTLAUNCHER_HXX
22 #define FG_QTLAUNCHER_HXX
23
24 #include <QDialog>
25 #include <QScopedPointer>
26 #include <QStringList>
27 #include <QModelIndex>
28 #include <QTimer>
29 #include <QUrl>
30
31
32 #include <Airports/airport.hxx>
33 #include <simgear/package/Package.hxx>
34 #include <simgear/package/Catalog.hxx>
35
36 namespace Ui
37 {
38     class Launcher;
39 }
40
41 class AirportSearchModel;
42 class QModelIndex;
43 class AircraftProxyModel;
44 class AircraftItemModel;
45 class QCheckBox;
46 class CatalogListModel;
47
48 class QtLauncher : public QDialog
49 {
50     Q_OBJECT
51 public:
52     QtLauncher();
53     virtual ~QtLauncher();
54
55     static void initApp(int& argc, char** argv);
56
57     static bool runLauncherDialog();
58
59 private slots:
60     void onRun();
61     void onQuit();
62
63     void onSearchAirports();
64
65     void onAirportChanged();
66
67     void onAirportChoiceSelected(const QModelIndex& index);
68     void onAircraftSelected(const QModelIndex& index);
69     void onRequestPackageInstall(const QModelIndex& index);
70     void onCancelDownload(const QModelIndex& index);
71     
72     void onPopupAirportHistory();
73     void onPopupAircraftHistory();
74
75     void onEditRatingsFilter();
76
77     void updateAirportDescription();
78     void updateSettingsSummary();
79
80     void onAirportSearchComplete();
81
82     void onRembrandtToggled(bool b);
83     void onToggleTerrasync(bool enabled);
84
85     void onSubsytemIdleTimeout();
86
87     void onEditPaths();
88     
89     void onAirportDiagramClicked(FGRunwayRef rwy);
90
91     void onAircraftInstalledCompleted(QModelIndex index);
92     void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
93 private:
94     void setAirport(FGAirportRef ref);
95
96     /**
97      * Check if the passed index is the selected aircraft, and if so, refresh
98      * the associated UI data
99      */
100     void maybeUpdateSelectedAircraft(QModelIndex index);
101     void updateSelectedAircraft();
102
103     void restoreSettings();
104     void saveSettings();
105     
106     QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
107     QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
108
109     void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
110
111     simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
112     
113     QScopedPointer<Ui::Launcher> m_ui;
114     AirportSearchModel* m_airportsModel;
115     AircraftProxyModel* m_aircraftProxy;
116     AircraftItemModel* m_aircraftModel;
117     FGAirportRef m_selectedAirport;
118
119     QUrl m_selectedAircraft;
120     QList<QUrl> m_recentAircraft;
121     QStringList m_recentAirports;
122     QTimer* m_subsystemIdleTimer;
123
124     int m_ratingFilters[4];
125 };
126
127 #endif // of FG_QTLAUNCHER_HXX