Start wiring package manager into the launcher.
This commit is contained in:
parent
68efa84b3a
commit
11c2623dec
8 changed files with 77 additions and 20 deletions
|
@ -281,8 +281,9 @@ private:
|
||||||
bool m_done;
|
bool m_done;
|
||||||
};
|
};
|
||||||
|
|
||||||
AircraftItemModel::AircraftItemModel(QObject* pr) :
|
AircraftItemModel::AircraftItemModel(QObject* pr, simgear::pkg::RootRef& rootRef) :
|
||||||
QAbstractListModel(pr)
|
QAbstractListModel(pr),
|
||||||
|
m_packageRoot(rootRef)
|
||||||
{
|
{
|
||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
Q_FOREACH(std::string ap, globals->get_aircraft_paths()) {
|
Q_FOREACH(std::string ap, globals->get_aircraft_paths()) {
|
||||||
|
|
|
@ -21,12 +21,13 @@
|
||||||
#ifndef FG_GUI_AIRCRAFT_MODEL
|
#ifndef FG_GUI_AIRCRAFT_MODEL
|
||||||
#define FG_GUI_AIRCRAFT_MODEL
|
#define FG_GUI_AIRCRAFT_MODEL
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
|
#include <simgear/package/Root.hxx>
|
||||||
|
|
||||||
const int AircraftPathRole = Qt::UserRole + 1;
|
const int AircraftPathRole = Qt::UserRole + 1;
|
||||||
const int AircraftAuthorsRole = Qt::UserRole + 2;
|
const int AircraftAuthorsRole = Qt::UserRole + 2;
|
||||||
const int AircraftVariantRole = Qt::UserRole + 3;
|
const int AircraftVariantRole = Qt::UserRole + 3;
|
||||||
|
@ -68,7 +69,7 @@ class AircraftItemModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AircraftItemModel(QObject* pr);
|
AircraftItemModel(QObject* pr, simgear::pkg::RootRef& root);
|
||||||
|
|
||||||
~AircraftItemModel();
|
~AircraftItemModel();
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ private:
|
||||||
AircraftScanThread* m_scanThread;
|
AircraftScanThread* m_scanThread;
|
||||||
QList<AircraftItem*> m_items;
|
QList<AircraftItem*> m_items;
|
||||||
QList<quint32> m_activeVariant;
|
QList<quint32> m_activeVariant;
|
||||||
|
simgear::pkg::RootRef m_packageRoot;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // of FG_GUI_AIRCRAFT_MODEL
|
#endif // of FG_GUI_AIRCRAFT_MODEL
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include <simgear/timing/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
#include <simgear/props/props_io.hxx>
|
#include <simgear/props/props_io.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
|
||||||
#include "ui_Launcher.h"
|
#include "ui_Launcher.h"
|
||||||
|
@ -58,7 +59,9 @@
|
||||||
#include <Airports/airport.hxx>
|
#include <Airports/airport.hxx>
|
||||||
#include <Airports/dynamics.hxx> // for parking
|
#include <Airports/dynamics.hxx> // for parking
|
||||||
#include <Main/options.hxx>
|
#include <Main/options.hxx>
|
||||||
|
#include <Main/fg_init.hxx>
|
||||||
#include <Viewer/WindowBuilder.hxx>
|
#include <Viewer/WindowBuilder.hxx>
|
||||||
|
#include <Network/HTTPClient.hxx>
|
||||||
|
|
||||||
using namespace flightgear;
|
using namespace flightgear;
|
||||||
|
|
||||||
|
@ -374,6 +377,12 @@ QtLauncher::QtLauncher() :
|
||||||
m_ratingFilters[i] = 3;
|
m_ratingFilters[i] = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_subsystemIdleTimer = new QTimer(this);
|
||||||
|
m_subsystemIdleTimer->setInterval(0);
|
||||||
|
connect(m_subsystemIdleTimer, &QTimer::timeout,
|
||||||
|
this, &QtLauncher::onSubsytemIdleTimeout);
|
||||||
|
m_subsystemIdleTimer->start();
|
||||||
|
|
||||||
m_airportsModel = new AirportSearchModel;
|
m_airportsModel = new AirportSearchModel;
|
||||||
m_ui->searchList->setModel(m_airportsModel);
|
m_ui->searchList->setModel(m_airportsModel);
|
||||||
connect(m_ui->searchList, &QListView::clicked,
|
connect(m_ui->searchList, &QListView::clicked,
|
||||||
|
@ -391,7 +400,18 @@ QtLauncher::QtLauncher() :
|
||||||
|
|
||||||
// create and configure the proxy model
|
// create and configure the proxy model
|
||||||
m_aircraftProxy = new AircraftProxyModel(this);
|
m_aircraftProxy = new AircraftProxyModel(this);
|
||||||
m_aircraftProxy->setSourceModel(new AircraftItemModel(this));
|
|
||||||
|
fgInitPackageRoot();
|
||||||
|
simgear::pkg::RootRef r(globals->packageRoot());
|
||||||
|
|
||||||
|
FGHTTPClient* http = new FGHTTPClient;
|
||||||
|
globals->add_subsystem("http", http);
|
||||||
|
|
||||||
|
// we guard against re-init in the global phase; bind and postinit
|
||||||
|
// will happen as normal
|
||||||
|
http->init();
|
||||||
|
|
||||||
|
m_aircraftProxy->setSourceModel(new AircraftItemModel(this, r));
|
||||||
|
|
||||||
m_aircraftProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
m_aircraftProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_aircraftProxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
m_aircraftProxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
@ -1029,5 +1049,10 @@ void QtLauncher::onRembrandtToggled(bool b)
|
||||||
m_ui->msaaCheckbox->setEnabled(!b);
|
m_ui->msaaCheckbox->setEnabled(!b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtLauncher::onSubsytemIdleTimeout()
|
||||||
|
{
|
||||||
|
globals->get_subsystem_mgr()->update(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
#include "QtLauncher.moc"
|
#include "QtLauncher.moc"
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <Airports/airport.hxx>
|
#include <Airports/airport.hxx>
|
||||||
|
|
||||||
|
@ -76,6 +77,8 @@ private slots:
|
||||||
void onRemoveSceneryPath();
|
void onRemoveSceneryPath();
|
||||||
|
|
||||||
void onRembrandtToggled(bool b);
|
void onRembrandtToggled(bool b);
|
||||||
|
|
||||||
|
void onSubsytemIdleTimeout();
|
||||||
private:
|
private:
|
||||||
void setAirport(FGAirportRef ref);
|
void setAirport(FGAirportRef ref);
|
||||||
void updateSelectedAircraft();
|
void updateSelectedAircraft();
|
||||||
|
@ -98,6 +101,7 @@ private:
|
||||||
QStringList m_recentAircraft,
|
QStringList m_recentAircraft,
|
||||||
m_recentAirports;
|
m_recentAirports;
|
||||||
QString m_customAircraftDir;
|
QString m_customAircraftDir;
|
||||||
|
QTimer* m_subsystemIdleTimer;
|
||||||
|
|
||||||
int m_ratingFilters[4];
|
int m_ratingFilters[4];
|
||||||
};
|
};
|
||||||
|
|
|
@ -503,17 +503,8 @@ static void initAircraftDirsNasalSecurity()
|
||||||
|
|
||||||
void fgInitAircraftPaths(bool reinit)
|
void fgInitAircraftPaths(bool reinit)
|
||||||
{
|
{
|
||||||
if (!reinit) {
|
if (!globals->packageRoot()) {
|
||||||
// there is some debate if we should be using FG_HOME here (hidden
|
fgInitPackageRoot();
|
||||||
// location) vs a user-visible location inside Documents (especially on
|
|
||||||
// Windows and Mac). Really this location should be managed by FG, not
|
|
||||||
// the user, but it can potentially grow large.
|
|
||||||
SGPath packageAircraftDir = globals->get_fg_home();
|
|
||||||
packageAircraftDir.append("Aircraft");
|
|
||||||
|
|
||||||
SGSharedPtr<Root> pkgRoot(new Root(packageAircraftDir, FLIGHTGEAR_VERSION));
|
|
||||||
// set the http client later (too early in startup right now)
|
|
||||||
globals->setPackageRoot(pkgRoot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
|
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
|
||||||
|
@ -725,7 +716,10 @@ void fgCreateSubsystems(bool duringReset) {
|
||||||
throw sg_io_exception("Error loading materials file", mpath);
|
throw sg_io_exception("Error loading materials file", mpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
globals->add_subsystem( "http", new FGHTTPClient );
|
// may exist already due to GUI startup
|
||||||
|
if (!globals->get_subsystem("http")) {
|
||||||
|
globals->add_subsystem( "http", new FGHTTPClient );
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Initialize the scenery management subsystem.
|
// Initialize the scenery management subsystem.
|
||||||
|
@ -1115,3 +1109,21 @@ void fgStartNewReset()
|
||||||
fgSetBool("/sim/sceneryloaded",false);
|
fgSetBool("/sim/sceneryloaded",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fgInitPackageRoot()
|
||||||
|
{
|
||||||
|
if (globals->packageRoot()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// there is some debate if we should be using FG_HOME here (hidden
|
||||||
|
// location) vs a user-visible location inside Documents (especially on
|
||||||
|
// Windows and Mac). Really this location should be managed by FG, not
|
||||||
|
// the user, but it can potentially grow large.
|
||||||
|
SGPath packageAircraftDir = globals->get_fg_home();
|
||||||
|
packageAircraftDir.append("Aircraft");
|
||||||
|
|
||||||
|
SGSharedPtr<Root> pkgRoot(new Root(packageAircraftDir, FLIGHTGEAR_VERSION));
|
||||||
|
// set the http client later (too early in startup right now)
|
||||||
|
globals->setPackageRoot(pkgRoot);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ void fgStartReposition();
|
||||||
|
|
||||||
void fgStartNewReset();
|
void fgStartNewReset();
|
||||||
|
|
||||||
|
// setup the package system including the global root
|
||||||
|
void fgInitPackageRoot();
|
||||||
|
|
||||||
#endif // _FG_INIT_HXX
|
#endif // _FG_INIT_HXX
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,8 @@ public:
|
||||||
|
|
||||||
} // of anonymous namespace
|
} // of anonymous namespace
|
||||||
|
|
||||||
FGHTTPClient::FGHTTPClient()
|
FGHTTPClient::FGHTTPClient() :
|
||||||
|
_inited(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +121,12 @@ FGHTTPClient::~FGHTTPClient()
|
||||||
|
|
||||||
void FGHTTPClient::init()
|
void FGHTTPClient::init()
|
||||||
{
|
{
|
||||||
|
// launcher may need to setup HTTP access abnormally early, so
|
||||||
|
// guard against duplicate inits
|
||||||
|
if (_inited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_http.reset(new simgear::HTTP::Client);
|
_http.reset(new simgear::HTTP::Client);
|
||||||
|
|
||||||
std::string proxyHost(fgGetString("/sim/presets/proxy/host"));
|
std::string proxyHost(fgGetString("/sim/presets/proxy/host"));
|
||||||
|
@ -152,6 +159,8 @@ void FGHTTPClient::init()
|
||||||
// start a refresh now
|
// start a refresh now
|
||||||
packageRoot->refresh();
|
packageRoot->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static naRef f_package_existingInstall( pkg::Package& pkg,
|
static naRef f_package_existingInstall( pkg::Package& pkg,
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual void update(double);
|
virtual void update(double);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool _inited;
|
||||||
std::auto_ptr<simgear::HTTP::Client> _http;
|
std::auto_ptr<simgear::HTTP::Client> _http;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue