2015-10-16 01:05:17 +00:00
|
|
|
// QtLauncher_private.hxx - GUI launcher dialog using Qt5
|
|
|
|
//
|
|
|
|
// Written by James Turner, started October 2015.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015 James Turner <zakalawe@mac.com>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License as
|
|
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful, but
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
#ifndef FG_QTLAUNCHER_PRIVATE_HXX
|
|
|
|
#define FG_QTLAUNCHER_PRIVATE_HXX
|
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
#include <QMainWindow>
|
2015-10-16 01:05:17 +00:00
|
|
|
#include <QScopedPointer>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QUrl>
|
|
|
|
|
|
|
|
#include <simgear/package/Package.hxx>
|
|
|
|
#include <simgear/package/Catalog.hxx>
|
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class Launcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
class QModelIndex;
|
|
|
|
class AircraftProxyModel;
|
|
|
|
class AircraftItemModel;
|
|
|
|
class QCheckBox;
|
|
|
|
class CatalogListModel;
|
2016-07-08 08:36:42 +00:00
|
|
|
class RemoteXMLRequest;
|
2015-10-16 01:05:17 +00:00
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
class QtLauncher : public QMainWindow
|
2015-10-16 01:05:17 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QtLauncher();
|
|
|
|
virtual ~QtLauncher();
|
|
|
|
|
2017-01-26 00:31:41 +00:00
|
|
|
bool execInApp();
|
2016-01-10 22:38:01 +00:00
|
|
|
|
Initial support for NavData/<type>/*.dat[.gz] files in scenery paths
Load every file matching the pattern NavData/apt/*.dat[.gz] inside each
scenery path. These files are loaded in the same order as the components
of globals->get_unmangled_fg_scenery() they reside in. Inside a given
component, the order is determined by pathSortPredicate() in
simgear/misc/sg_dir.cxx (lexicographic order at the time of this
writing). For compatibility with existing scenery,
$FG_ROOT/Airports/apt.dat.gz is also loaded last.
The idea is that such files will have the same precedence order as the
globals->get_unmangled_fg_scenery() scenery components they come from.
This commit doesn't handle this fully yet, though: it blindly loads all
these files. A future commit will ensure that no airport is loaded twice
due to overlapping apt.dat files. This commit however handles all the
logic of navdata cache rebuilding when the list, the order of apt.dat
files, or any of their timestamps changes.
Although only apt.dat files receive a new treatment in this commit, the
changes to NavDataCache.[ch]xx are already generic so that extension of
this method to fix.dat, nav.dat, etc. will require almost no change to
NavDataCache.[ch]xx (however, changes will probably be needed in the
various loaders: in fixlist.[ch]xx, navdb.[ch]xx, etc.).
src/Navaids/CacheSchema.h:
- increment the SCHEMA_VERSION by 1. This ensures among others that if
someone uses a FlightGear version posterior to this change with
new-style scenery (having NavData/apt/*.dat[.gz] files inside
scenery paths), then goes back to a FlightGear version anterior to
this change, his NavCache is rebuilt ignoring the in-scenery-paths
NavData/apt/*.dat[.gz] files, as expected with the old FlightGear
version.
src/Navaids/NavDataCache.cxx:
- NavDataCachePrivate: replace aptDatPath (SGPath) with aptDatPaths
(PathList).
- NavDataCachePrivate::getDatFilesPaths(): new method that returns the
list of $scenery_path/NavData/<type>/*.dat[.gz] files found inside
scenery paths (where <type> is one of 'apt', 'fix', etc.), plus the
historical file (e.g., $FG_ROOT/Airports/apt.dat.gz for the 'apt'
type).
- NavDataCachePrivate::areDatFilesModified(): new method that tells
whether any of these files (for a given type) has changed since the
last NavCache rebuild, or if their ordered list has changed.
- NavDataCachePrivate::isCachedFileModified(): minor changes.
- NavDataCache::updateListsOfDatFiles(): new method that updates the
lists of dat files used for NavCache freshness checking and
rebuilding, i.e. currently sets/updates d->aptDatPaths using the new
method d->getDatFilesPaths(), and d->metarDatPath, d->navDatPath,
d->fixDatPath, d->poiDatPath, etc. as usual. This method will be
useful for instance in the built-in launcher after updating scenery
paths and before calling NavDataCache::isRebuildRequired().
- NavDataCache::NavDataCache(): use
NavDataCache::updateListsOfDatFiles() to initialize d->aptDatPaths,
d->metarDatPath, d->navDatPath, d->fixDatPath, d->poiDatPath, etc.
- NavDataCache::isRebuildRequired(): use
NavDataCachePrivate::areDatFilesModified() instead of just checking
$FG_ROOT/Airports/apt.dat.gz.
- NavDataCache::doRebuild(): load all apt.dat files listed in
d->aptDatPaths, instead of only $FG_ROOT/Airports/apt.dat.gz. Write
their ordered list and timestamps in the NavCache.
src/Navaids/NavDataCache.hxx:
- declare the new method NavDataCache::updateListsOfDatFiles().
- NavDataCache::DatFileType: new enum with values DATFILETYPE_APT,
DATFILETYPE_METAR, DATFILETYPE_AWY, DATFILETYPE_NAV,
DATFILETYPE_FIX, DATFILETYPE_POI, DATFILETYPE_CARRIER and
DATFILETYPE_TACAN_FREQ. Maybe some of the corresponding files won't
have to be moved to scenery paths, but simply listing them in the
enum doesn't change how they are dealt with. Those for which
per-scenery-path locations doesn't make sense can just be removed
from the enum.
- NavDataCache::datTypeStr: new static string_list giving an
std::string such as 'apt' for each value of the
NavDataCache::DatFileType enum.
- NavDataCache::defaultDatFile: new static string_list giving a path
(relative to $FG_ROOT) to the historical/default file for each value
of the NavDataCache::DatFileType enum.
src/Airports/apt_loader.cxx and src/Airports/apt_loader.hxx:
- always include a path to the apt.dat file being processed in log
messages, since they can now apply to many files;
- be clearer about code 99: it should normally be at the end of
apt.dat files, but technically, it is not an EOF;
- use the expression "row code" consistently with the apt.dat format
spec (for now: only in places where there is another change to do).
src/GUI/QtLauncher.cxx and src/GUI/QtLauncher_private.hxx:
- turn QtLauncher::setSceneryPaths() into a static method and call it
in runLauncherDialog() before instantiating NavDataCache, so that
NavDataCache::updateListsOfDatFiles() (called from NavDataCache's
constructor) can see all configured scenery paths.
2016-10-11 14:31:13 +00:00
|
|
|
static void setSceneryPaths();
|
2016-01-10 22:38:01 +00:00
|
|
|
|
2016-04-08 09:26:19 +00:00
|
|
|
static void restartTheApp(QStringList fgArgs);
|
2017-01-26 00:31:41 +00:00
|
|
|
|
|
|
|
bool wasRejected();
|
2016-02-24 19:50:37 +00:00
|
|
|
protected:
|
2017-01-26 00:31:41 +00:00
|
|
|
virtual void closeEvent(QCloseEvent *event) override;
|
2016-02-24 19:50:37 +00:00
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
private slots:
|
|
|
|
// run is used when the launcher is invoked before the main app is
|
|
|
|
// started
|
|
|
|
void onRun();
|
|
|
|
|
|
|
|
// apply is used in-app, where we must set properties and trigger
|
|
|
|
// a reset; setting command line options won't help us.
|
|
|
|
void onApply();
|
2016-07-08 08:36:42 +00:00
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
void onQuit();
|
|
|
|
|
|
|
|
|
|
|
|
void onAircraftSelected(const QModelIndex& index);
|
|
|
|
void onRequestPackageInstall(const QModelIndex& index);
|
2016-11-06 20:50:34 +00:00
|
|
|
void onRequestPackageUninstall(const QModelIndex& index);
|
2017-02-06 14:09:07 +00:00
|
|
|
void onShowPreviews(const QModelIndex& index);
|
2015-10-16 01:05:17 +00:00
|
|
|
void onCancelDownload(const QModelIndex& index);
|
|
|
|
|
|
|
|
void onPopupAircraftHistory();
|
2016-11-07 11:54:38 +00:00
|
|
|
void onPopupLocationHistory();
|
2015-10-16 01:05:17 +00:00
|
|
|
|
|
|
|
void onEditRatingsFilter();
|
|
|
|
|
|
|
|
void updateSettingsSummary();
|
|
|
|
|
|
|
|
|
|
|
|
void onRembrandtToggled(bool b);
|
|
|
|
void onToggleTerrasync(bool enabled);
|
|
|
|
|
|
|
|
void onSubsytemIdleTimeout();
|
|
|
|
|
|
|
|
void onAircraftInstalledCompleted(QModelIndex index);
|
|
|
|
void onAircraftInstallFailed(QModelIndex index, QString errorMessage);
|
2016-01-10 18:56:46 +00:00
|
|
|
|
|
|
|
void onShowInstalledAircraftToggled(bool b);
|
2016-01-11 08:46:16 +00:00
|
|
|
|
|
|
|
void maybeRestoreAircraftSelection();
|
|
|
|
|
2016-04-08 09:26:19 +00:00
|
|
|
void onRestoreDefaults();
|
|
|
|
|
|
|
|
void onDownloadDirChanged();
|
2016-07-08 08:36:42 +00:00
|
|
|
|
|
|
|
void onRefreshMPServers();
|
2016-07-08 08:36:42 +00:00
|
|
|
void onMPServerActivated(int index);
|
2016-07-08 08:36:42 +00:00
|
|
|
|
2016-11-07 19:49:33 +00:00
|
|
|
void onUpdateAllAircraft();
|
|
|
|
|
|
|
|
void onPackagesNeedUpdate(bool yes);
|
2016-07-08 08:36:42 +00:00
|
|
|
|
2017-02-22 17:09:13 +00:00
|
|
|
void onAircraftPathsChanged();
|
2015-10-16 01:05:17 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the passed index is the selected aircraft, and if so, refresh
|
|
|
|
* the associated UI data
|
|
|
|
*/
|
|
|
|
void maybeUpdateSelectedAircraft(QModelIndex index);
|
|
|
|
void updateSelectedAircraft();
|
|
|
|
|
|
|
|
void restoreSettings();
|
|
|
|
void saveSettings();
|
|
|
|
|
|
|
|
QModelIndex proxyIndexForAircraftURI(QUrl uri) const;
|
|
|
|
QModelIndex sourceIndexForAircraftURI(QUrl uri) const;
|
|
|
|
|
|
|
|
void setEnableDisableOptionFromCheckbox(QCheckBox* cbox, QString name) const;
|
|
|
|
|
|
|
|
simgear::pkg::PackageRef packageForAircraftURI(QUrl uri) const;
|
|
|
|
|
2016-04-15 16:06:53 +00:00
|
|
|
void checkOfficialCatalogMessage();
|
|
|
|
void onOfficialCatalogMessageLink(QUrl link);
|
|
|
|
|
2016-11-07 19:49:33 +00:00
|
|
|
void checkUpdateAircraft();
|
|
|
|
|
2016-07-08 08:36:42 +00:00
|
|
|
void onRefreshMPServersDone(simgear::HTTP::Request*);
|
|
|
|
void onRefreshMPServersFailed(simgear::HTTP::Request*);
|
|
|
|
int findMPServerPort(const std::string& host);
|
2016-07-08 08:36:42 +00:00
|
|
|
void restoreMPServerSelection();
|
2016-07-08 08:36:42 +00:00
|
|
|
|
2016-01-10 19:47:57 +00:00
|
|
|
// need to wait after a model reset before restoring selection and
|
|
|
|
// scrolling, to give the view time it seems.
|
|
|
|
void delayedAircraftModelReset();
|
|
|
|
void onRatingsFilterToggled();
|
|
|
|
|
2016-11-07 11:54:38 +00:00
|
|
|
void updateLocationHistory();
|
2016-11-07 19:49:33 +00:00
|
|
|
bool shouldShowOfficialCatalogMessage() const;
|
2016-11-07 11:54:38 +00:00
|
|
|
|
2015-10-16 01:05:17 +00:00
|
|
|
QScopedPointer<Ui::Launcher> m_ui;
|
|
|
|
AircraftProxyModel* m_aircraftProxy;
|
|
|
|
AircraftItemModel* m_aircraftModel;
|
|
|
|
|
|
|
|
QUrl m_selectedAircraft;
|
|
|
|
QList<QUrl> m_recentAircraft;
|
|
|
|
QTimer* m_subsystemIdleTimer;
|
2017-01-26 00:31:41 +00:00
|
|
|
bool m_inAppMode = false;
|
|
|
|
bool m_runInApp = false;
|
|
|
|
bool m_accepted = false;
|
2015-10-16 01:05:17 +00:00
|
|
|
|
|
|
|
int m_ratingFilters[4];
|
2016-07-08 08:36:42 +00:00
|
|
|
|
|
|
|
SGSharedPtr<RemoteXMLRequest> m_mpServerRequest;
|
|
|
|
bool m_doRestoreMPServer;
|
2016-11-07 11:54:38 +00:00
|
|
|
|
|
|
|
QVariantList m_recentLocations;
|
2015-10-16 01:05:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // of FG_QTLAUNCHER_PRIVATE_HXX
|