bool m_done;
};
-AircraftItemModel::AircraftItemModel(QObject* pr) :
- QAbstractListModel(pr)
+AircraftItemModel::AircraftItemModel(QObject* pr, simgear::pkg::RootRef& rootRef) :
+ QAbstractListModel(pr),
+ m_packageRoot(rootRef)
{
QStringList dirs;
Q_FOREACH(std::string ap, globals->get_aircraft_paths()) {
#ifndef FG_GUI_AIRCRAFT_MODEL
#define FG_GUI_AIRCRAFT_MODEL
-#include <QThread>
#include <QAbstractListModel>
#include <QDateTime>
#include <QDir>
#include <QPixmap>
+#include <simgear/package/Root.hxx>
+
const int AircraftPathRole = Qt::UserRole + 1;
const int AircraftAuthorsRole = Qt::UserRole + 2;
const int AircraftVariantRole = Qt::UserRole + 3;
{
Q_OBJECT
public:
- AircraftItemModel(QObject* pr);
+ AircraftItemModel(QObject* pr, simgear::pkg::RootRef& root);
~AircraftItemModel();
AircraftScanThread* m_scanThread;
QList<AircraftItem*> m_items;
QList<quint32> m_activeVariant;
+ simgear::pkg::RootRef m_packageRoot;
};
#endif // of FG_GUI_AIRCRAFT_MODEL
#include <simgear/timing/timestamp.hxx>
#include <simgear/props/props_io.hxx>
#include <simgear/structure/exception.hxx>
+#include <simgear/structure/subsystem_mgr.hxx>
#include <simgear/misc/sg_path.hxx>
#include "ui_Launcher.h"
#include <Airports/airport.hxx>
#include <Airports/dynamics.hxx> // for parking
#include <Main/options.hxx>
+#include <Main/fg_init.hxx>
#include <Viewer/WindowBuilder.hxx>
+#include <Network/HTTPClient.hxx>
using namespace flightgear;
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_ui->searchList->setModel(m_airportsModel);
connect(m_ui->searchList, &QListView::clicked,
// create and configure the proxy model
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->setSortCaseSensitivity(Qt::CaseInsensitive);
m_ui->msaaCheckbox->setEnabled(!b);
}
+void QtLauncher::onSubsytemIdleTimeout()
+{
+ globals->get_subsystem_mgr()->update(0.0);
+}
+
#include "QtLauncher.moc"
#include <QScopedPointer>
#include <QStringList>
#include <QModelIndex>
+#include <QTimer>
#include <Airports/airport.hxx>
void onRemoveSceneryPath();
void onRembrandtToggled(bool b);
+
+ void onSubsytemIdleTimeout();
private:
void setAirport(FGAirportRef ref);
void updateSelectedAircraft();
QStringList m_recentAircraft,
m_recentAirports;
QString m_customAircraftDir;
+ QTimer* m_subsystemIdleTimer;
int m_ratingFilters[4];
};
void fgInitAircraftPaths(bool reinit)
{
- if (!reinit) {
- // 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);
+ if (!globals->packageRoot()) {
+ fgInitPackageRoot();
}
SGSharedPtr<Root> pkgRoot(globals->packageRoot());
globals->get_props()) ) {
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.
////////////////////////////////////////////////////////////////////
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);
+
+}
void fgStartNewReset();
+// setup the package system including the global root
+void fgInitPackageRoot();
+
#endif // _FG_INIT_HXX
} // of anonymous namespace
-FGHTTPClient::FGHTTPClient()
+FGHTTPClient::FGHTTPClient() :
+ _inited(false)
{
}
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);
std::string proxyHost(fgGetString("/sim/presets/proxy/host"));
// start a refresh now
packageRoot->refresh();
}
+
+ _inited = true;
}
static naRef f_package_existingInstall( pkg::Package& pkg,
virtual void update(double);
private:
+ bool _inited;
std::auto_ptr<simgear::HTTP::Client> _http;
};