mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #720, use interfaces directly with component
(menus functions can directly update data)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
c591fe2517
commit
a9464ef537
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackcore/db/databaseutils.h"
|
||||
#include "blackgui/components/dbownmodelscomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/menus/aircraftmodelmenus.h"
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Db;
|
||||
using namespace BlackGui::Menus;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
@@ -41,7 +43,6 @@ namespace BlackGui
|
||||
ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
|
||||
ui->tvp_OwnAircraftModels->addFilterDialog();
|
||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMergeWithDbDataMenu(ui->tvp_OwnAircraftModels, this->modelLoader(), false));
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this, true));
|
||||
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::ps_requestOwnModelsUpdate);
|
||||
@@ -58,6 +59,9 @@ namespace BlackGui
|
||||
{
|
||||
CLogMessage(this).error("Init of model loader failed in component");
|
||||
}
|
||||
|
||||
// menu
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_OwnAircraftModels, this, false));
|
||||
}
|
||||
|
||||
CDbOwnModelsComponent::~CDbOwnModelsComponent()
|
||||
@@ -132,8 +136,21 @@ namespace BlackGui
|
||||
if (this->m_modelLoader) { this->m_modelLoader->gracefulShutdown(); }
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::setModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->modelLoader()->setCachedModels(models, simulator);
|
||||
ui->tvp_OwnAircraftModels->replaceOrAddModelsWithString(models);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::updateModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->modelLoader()->replaceOrAddCachedModels(models, simulator);
|
||||
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
|
||||
}
|
||||
|
||||
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simulator)
|
||||
{
|
||||
// called when simulator is changed / init
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
|
||||
// already loaded
|
||||
@@ -176,7 +193,8 @@ namespace BlackGui
|
||||
|
||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
const CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
|
||||
// for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
|
||||
const CSimulatorInfo sims = CSimulatorInfo::allSimulators();
|
||||
const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||
if (!noSims)
|
||||
{
|
||||
@@ -332,7 +350,7 @@ namespace BlackGui
|
||||
CLogMessage(this).info("Starting loading for %1") << simulator.toQString();
|
||||
this->ui->tvp_OwnAircraftModels->showLoadIndicator();
|
||||
Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services");
|
||||
this->m_modelLoader->startLoading(mode, sGui->getWebDataServices()->getModels());
|
||||
this->m_modelLoader->startLoading(mode, &CDatabaseUtils::consolidateModelsWithDbData);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simulator)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/aircraftmodelinterfaces.h"
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -32,7 +33,6 @@ class QAction;
|
||||
class QWidget;
|
||||
|
||||
namespace Ui { class CDbOwnModelsComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Menus { class CMenuActions; }
|
||||
@@ -44,9 +44,18 @@ namespace BlackGui
|
||||
/*!
|
||||
* Handling of own models on disk (the models installed for the simulator)
|
||||
*/
|
||||
class CDbOwnModelsComponent : public QFrame
|
||||
class CDbOwnModelsComponent :
|
||||
public QFrame,
|
||||
public BlackMisc::Simulation::IModelsSetable,
|
||||
public BlackMisc::Simulation::IModelsUpdatable,
|
||||
public BlackMisc::Simulation::IModelsPerSimulatorSetable,
|
||||
public BlackMisc::Simulation::IModelsPerSimulatorUpdatable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsSetable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsUpdatable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorSetable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorUpdatable)
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
@@ -88,6 +97,14 @@ namespace BlackGui
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
//! \name Implementations of the models interfaces
|
||||
//! @{
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setModels(models, this->getOwnModelsSimulator()); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->updateModels(models, this->getOwnModelsSimulator()); }
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Request own models
|
||||
void ps_requestOwnModelsUpdate();
|
||||
@@ -103,7 +120,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_simulatorSelection {this }; //!< last selection
|
||||
|
||||
//! Init or change model loader
|
||||
|
||||
Reference in New Issue
Block a user