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/webdataservices.h"
|
||||||
|
#include "blackcore/db/databaseutils.h"
|
||||||
#include "blackgui/components/dbownmodelscomponent.h"
|
#include "blackgui/components/dbownmodelscomponent.h"
|
||||||
#include "blackgui/guiapplication.h"
|
#include "blackgui/guiapplication.h"
|
||||||
#include "blackgui/menus/aircraftmodelmenus.h"
|
#include "blackgui/menus/aircraftmodelmenus.h"
|
||||||
@@ -25,6 +26,7 @@
|
|||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
|
using namespace BlackCore::Db;
|
||||||
using namespace BlackGui::Menus;
|
using namespace BlackGui::Menus;
|
||||||
using namespace BlackGui::Views;
|
using namespace BlackGui::Views;
|
||||||
using namespace BlackGui::Models;
|
using namespace BlackGui::Models;
|
||||||
@@ -41,7 +43,6 @@ namespace BlackGui
|
|||||||
ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
|
ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
|
||||||
ui->tvp_OwnAircraftModels->addFilterDialog();
|
ui->tvp_OwnAircraftModels->addFilterDialog();
|
||||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
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));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this, true));
|
||||||
|
|
||||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::ps_requestOwnModelsUpdate);
|
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");
|
CLogMessage(this).error("Init of model loader failed in component");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// menu
|
||||||
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_OwnAircraftModels, this, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbOwnModelsComponent::~CDbOwnModelsComponent()
|
CDbOwnModelsComponent::~CDbOwnModelsComponent()
|
||||||
@@ -132,8 +136,21 @@ namespace BlackGui
|
|||||||
if (this->m_modelLoader) { this->m_modelLoader->gracefulShutdown(); }
|
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)
|
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
|
// called when simulator is changed / init
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||||
|
|
||||||
// already loaded
|
// already loaded
|
||||||
@@ -176,7 +193,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
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();
|
const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||||
if (!noSims)
|
if (!noSims)
|
||||||
{
|
{
|
||||||
@@ -332,7 +350,7 @@ namespace BlackGui
|
|||||||
CLogMessage(this).info("Starting loading for %1") << simulator.toQString();
|
CLogMessage(this).info("Starting loading for %1") << simulator.toQString();
|
||||||
this->ui->tvp_OwnAircraftModels->showLoadIndicator();
|
this->ui->tvp_OwnAircraftModels->showLoadIndicator();
|
||||||
Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services");
|
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)
|
void CDbOwnModelsComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simulator)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||||
|
#include "blackmisc/simulation/aircraftmodelinterfaces.h"
|
||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
@@ -32,7 +33,6 @@ class QAction;
|
|||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace Ui { class CDbOwnModelsComponent; }
|
namespace Ui { class CDbOwnModelsComponent; }
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
namespace Menus { class CMenuActions; }
|
namespace Menus { class CMenuActions; }
|
||||||
@@ -44,9 +44,18 @@ namespace BlackGui
|
|||||||
/*!
|
/*!
|
||||||
* Handling of own models on disk (the models installed for the simulator)
|
* 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_OBJECT
|
||||||
|
Q_INTERFACES(BlackMisc::Simulation::IModelsSetable)
|
||||||
|
Q_INTERFACES(BlackMisc::Simulation::IModelsUpdatable)
|
||||||
|
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorSetable)
|
||||||
|
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorUpdatable)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
@@ -88,6 +97,14 @@ namespace BlackGui
|
|||||||
//! Graceful shutdown
|
//! Graceful shutdown
|
||||||
void gracefulShutdown();
|
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:
|
private slots:
|
||||||
//! Request own models
|
//! Request own models
|
||||||
void ps_requestOwnModelsUpdate();
|
void ps_requestOwnModelsUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user