mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
refs #641, moved last simulator selection to caches
* removed from component cache * kept renamed component caches as stubs for later usage refs #646, removed gui state cache as it causes build issues on Jenkins (idea was to keep the classes as stubs for later usage)
This commit is contained in:
@@ -1,71 +0,0 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "lastselections.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
namespace Data
|
||||
{
|
||||
QString CDbOwnModelsComponent::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->m_simulator.toQString(i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
CVariant CDbOwnModelsComponent::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLastSimulator:
|
||||
return this->m_simulator.propertyByIndex(index.copyFrontRemoved());
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CDbOwnModelsComponent>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLastSimulator:
|
||||
this->m_simulator.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CDbOwnModelsComponent::comparePropertyByIndex(const CDbOwnModelsComponent &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQString().compare(compareValue.toQString()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLastSimulator:
|
||||
return this->m_simulator.comparePropertyByIndex(compareValue.getLastSimulatorSelection(), index.copyFrontRemoved());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -1,91 +0,0 @@
|
||||
/* Copyright (C) 2016
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_DATA_LASTSELECTIONS_H
|
||||
#define BLACKGUI_COMPONENTS_DATA_LASTSELECTIONS_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
namespace Data
|
||||
{
|
||||
/*!
|
||||
* Store last selections/interactions with this component
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbOwnModelsComponent : public BlackMisc::CValueObject<CDbOwnModelsComponent>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexLastSimulator = BlackMisc::CPropertyIndex::GlobalIndexCDbOwnModelsComponent
|
||||
};
|
||||
|
||||
//! Constructor
|
||||
CDbOwnModelsComponent() {}
|
||||
|
||||
//! Simulator last selected
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getLastSimulatorSelection() const { return m_simulator; }
|
||||
|
||||
//! Simulator last selected
|
||||
void setLastSimulatorSelection(const BlackMisc::Simulation::CSimulatorInfo &simulator) { m_simulator = simulator; }
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CDbOwnModelsComponent &compareValue, const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
private:
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< Last simulator selection
|
||||
|
||||
BLACK_METACLASS(
|
||||
CDbOwnModelsComponent,
|
||||
BLACK_METAMEMBER(simulator)
|
||||
);
|
||||
};
|
||||
|
||||
//! Trait for model cache
|
||||
struct DbOwnModelsComponent : public BlackMisc::CDataTrait<CDbOwnModelsComponent>
|
||||
{
|
||||
//! Default value
|
||||
static const CDbOwnModelsComponent &defaultValue()
|
||||
{
|
||||
static const CDbOwnModelsComponent ls;
|
||||
return ls;
|
||||
}
|
||||
|
||||
//! First load is synchronous
|
||||
static bool isPinned() { return true; }
|
||||
|
||||
//! Key in data cache
|
||||
static const char *key() { return "dbownmodelscomponent"; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackGui::Components::Data::CDbOwnModelsComponent)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -699,7 +699,7 @@ namespace BlackGui
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelForModelString(modelString);
|
||||
}
|
||||
|
||||
const CSimulatorInfo &CDbMappingComponent::getOwnModelsSimulator() const
|
||||
const CSimulatorInfo CDbMappingComponent::getOwnModelsSimulator() const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "blackgui/menus/menudelegate.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/data/lastselections.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
@@ -112,7 +111,7 @@ namespace BlackGui
|
||||
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
|
||||
const Simulation::CSimulatorInfo getOwnModelsSimulator() const;
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
|
||||
@@ -33,22 +33,23 @@ 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);
|
||||
|
||||
this->m_lastInteractions.synchronize();
|
||||
|
||||
// should be single simulator or no simulator (default)
|
||||
const CSimulatorInfo sim = this->m_lastInteractions.getCopy().getLastSimulatorSelection();
|
||||
BLACK_VERIFY_X(!sim.isMultipleSimulators(), Q_FUNC_INFO, "Should be single simulator or default");
|
||||
if (sim.isSingleSimulator())
|
||||
this->m_simulatorSelection.synchronize();
|
||||
const CSimulatorInfo simulator(this->m_simulatorSelection.get());
|
||||
const bool s = this->initModelLoader(!simulator.isSingleSimulator() ? CSimulatorInfo(CSimulatorInfo::FSX) : simulator);
|
||||
if (s)
|
||||
{
|
||||
// if we have already use this before, use it again, but only from cache
|
||||
this->initModelLoader(sim);
|
||||
this->m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
|
||||
}
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMergeWithDbDataMenu(ui->tvp_OwnAircraftModels, this->modelLoader(), false));
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this, true));
|
||||
else
|
||||
{
|
||||
CLogMessage(this).error("Init of model loader failed in component");
|
||||
}
|
||||
}
|
||||
|
||||
CDbOwnModelsComponent::~CDbOwnModelsComponent()
|
||||
@@ -89,7 +90,7 @@ namespace BlackGui
|
||||
return ui->tvp_OwnAircraftModels->selectedObjects();
|
||||
}
|
||||
|
||||
const CSimulatorInfo &CDbOwnModelsComponent::getOwnModelsSimulator() const
|
||||
const CSimulatorInfo CDbOwnModelsComponent::getOwnModelsSimulator() const
|
||||
{
|
||||
static const CSimulatorInfo noSim;
|
||||
if (!this->m_modelLoader) { return noSim; }
|
||||
@@ -117,27 +118,28 @@ namespace BlackGui
|
||||
if (this->m_modelLoader) { this->m_modelLoader->gracefulShutdown(); }
|
||||
}
|
||||
|
||||
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simInfo)
|
||||
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
|
||||
// already loaded
|
||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simInfo))
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simulator))
|
||||
{
|
||||
this->setSaveFileName(simInfo);
|
||||
this->setSaveFileName(simulator);
|
||||
return true;
|
||||
}
|
||||
|
||||
// unload old
|
||||
// mismatching loader
|
||||
if (this->m_modelLoader)
|
||||
{
|
||||
this->m_modelLoader->gracefulShutdown();
|
||||
}
|
||||
|
||||
// create loader, also syncronizes the caches
|
||||
this->m_modelLoader = IAircraftModelLoader::createModelLoader(simInfo);
|
||||
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simInfo))
|
||||
this->m_modelLoader = IAircraftModelLoader::createModelLoader(simulator); // last selected simulator or explicit given
|
||||
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simulator))
|
||||
{
|
||||
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
||||
CLogMessage(this).error("Failed to init model loader %1") << simulator.toQString();
|
||||
this->m_modelLoader.reset();
|
||||
return false;
|
||||
}
|
||||
@@ -146,7 +148,7 @@ namespace BlackGui
|
||||
bool c = connect(this->m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbOwnModelsComponent::ps_onOwnModelsLoadingFinished);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
||||
Q_UNUSED(c);
|
||||
this->setSaveFileName(simInfo);
|
||||
this->setSaveFileName(simulator);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -242,45 +244,35 @@ namespace BlackGui
|
||||
);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
void CDbOwnModelsComponent::ps_loadInstalledModels(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
if (!this->initModelLoader(simInfo))
|
||||
if (!this->initModelLoader(simulator))
|
||||
{
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simInfo.toQString();
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simulator.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->m_modelLoader->isLoadingFinished())
|
||||
{
|
||||
CLogMessage(this).info("Loading for %1 already in progress") << simInfo.toQString();
|
||||
CLogMessage(this).info("Loading for %1 already in progress") << simulator.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
CLogMessage(this).info("Starting loading for %1") << simInfo.toQString();
|
||||
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());
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simInfo)
|
||||
void CDbOwnModelsComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
|
||||
if (success && this->m_modelLoader)
|
||||
{
|
||||
const CAircraftModelList models(this->m_modelLoader->getAircraftModels());
|
||||
const int modelsLoaded = models.size();
|
||||
this->ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
|
||||
if (modelsLoaded > 0)
|
||||
{
|
||||
// store for later
|
||||
Data::CDbOwnModelsComponent mc(this->m_lastInteractions.get());
|
||||
if (simInfo.isSingleSimulator() && mc.getLastSimulatorSelection() != simInfo)
|
||||
{
|
||||
mc.setLastSimulatorSelection(simInfo);
|
||||
this->m_lastInteractions.set(mc);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (modelsLoaded < 1)
|
||||
{
|
||||
// loading ok, but no data
|
||||
CLogMessage(this).warning("Loading completed, but no models");
|
||||
@@ -288,15 +280,15 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
CLogMessage(this).error("Loading of models failed, simulator %1") << simInfo.toQString();
|
||||
this->ui->tvp_OwnAircraftModels->clear();
|
||||
CLogMessage(this).error("Loading of models failed, simulator %1") << simulator.toQString();
|
||||
}
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_requestSimulatorModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
void CDbOwnModelsComponent::ps_requestSimulatorModels(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
this->ps_loadInstalledModels(simInfo, mode);
|
||||
this->ps_loadInstalledModels(simulator, mode);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#define BLACKGUI_COMPONENTS_DBOWNMODELSCOMPONENT_H
|
||||
|
||||
#include "blackgui/models/aircraftmodellistmodel.h"
|
||||
#include "blackgui/components/data/lastselections.h"
|
||||
#include "blackgui/menus/menudelegate.h"
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include <QFrame>
|
||||
@@ -49,7 +48,7 @@ namespace BlackGui
|
||||
BlackMisc::Simulation::CAircraftModelList getOwnSelectedModels() const;
|
||||
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
|
||||
const BlackMisc::Simulation::CSimulatorInfo getOwnModelsSimulator() const;
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
@@ -74,21 +73,21 @@ namespace BlackGui
|
||||
void ps_requestOwnModelsUpdate();
|
||||
|
||||
//! Load the models
|
||||
void ps_loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
void ps_loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
//! Model loading finished
|
||||
void ps_onOwnModelsLoadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
void ps_onOwnModelsLoadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Request simulator models
|
||||
void ps_requestSimulatorModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
void ps_requestSimulatorModels(const BlackMisc::Simulation::CSimulatorInfo &simulator, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackGui::Components::Data::DbOwnModelsComponent> m_lastInteractions {this}; //!< last interactions
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheLastSelection> m_simulatorSelection {this }; //!< last selection
|
||||
|
||||
//! Init model loader
|
||||
bool initModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
bool initModelLoader(const Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! File name for savinf
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "blackgui/menus/aircraftmodelmenus.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "dbmappingcomponent.h"
|
||||
#include "dbownmodelsetdialog.h"
|
||||
#include "ui_dbownmodelsetcomponent.h"
|
||||
@@ -36,10 +37,11 @@ namespace BlackGui
|
||||
ui->tvp_OwnModelSet->menuRemoveItems(CAircraftModelView::MenuDisplayAutomaticallyAndRefresh | CAircraftModelView::MenuStashing | CAircraftModelView::MenuBackend | CAircraftModelView::MenuRefresh);
|
||||
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows | CAircraftModelView::MenuClear);
|
||||
ui->tvp_OwnModelSet->addFilterDialog();
|
||||
ui->tvp_OwnModelSet->setCustomMenu(new CLoadModelsMenu(this));
|
||||
ui->tvp_OwnModelSet->setJsonLoad(CAircraftModelView::AllowOnlySingleSimulator | CAircraftModelView::ReduceToOneSimulator);
|
||||
ui->tvp_OwnModelSet->setCustomMenu(new CLoadModelsMenu(this));
|
||||
ui->tvp_OwnModelSet->setCustomMenu(new CMergeWithDbDataMenu(ui->tvp_OwnModelSet, this, true));
|
||||
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuOrderable);
|
||||
ui->tvp_OwnModelSet->setSorting(CAircraftModel::IndexOrderString);
|
||||
ui->tvp_OwnModelSet->initAsOrderable();
|
||||
|
||||
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
|
||||
@@ -47,9 +49,16 @@ namespace BlackGui
|
||||
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
|
||||
connect(&this->m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
|
||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::rowCountChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged);
|
||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::ps_modelChanged);
|
||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::ps_onJsonDataLoaded);
|
||||
|
||||
this->ps_onRowCountChanged(ui->tvp_OwnModelSet->rowCount(), ui->tvp_OwnModelSet->hasFilter());
|
||||
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
|
||||
if (sim.isSingleSimulator())
|
||||
{
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(this->m_modelSetLoader.getAircraftModels());
|
||||
}
|
||||
const int c = this->m_modelSetLoader.getAircraftModelsCount();
|
||||
this->ps_onRowCountChanged(c, ui->tvp_OwnModelSet->hasFilter());
|
||||
}
|
||||
|
||||
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
|
||||
@@ -103,6 +112,11 @@ namespace BlackGui
|
||||
return ui->tvp_OwnModelSet->container();
|
||||
}
|
||||
|
||||
const CSimulatorInfo CDbOwnModelSetComponent::getModelSetSimulator() const
|
||||
{
|
||||
return this->m_modelSetLoader.getSimulator();
|
||||
}
|
||||
|
||||
CStatusMessage CDbOwnModelSetComponent::addToModelSet(const CAircraftModel &model, const CSimulatorInfo &simulator)
|
||||
{
|
||||
return this->addToModelSet(CAircraftModelList({model}), simulator);
|
||||
@@ -195,16 +209,18 @@ namespace BlackGui
|
||||
void CDbOwnModelSetComponent::ps_changeSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
this->m_modelSetLoader.changeSimulator(simulator);
|
||||
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
|
||||
|
||||
this->setSimulator(simulator);
|
||||
const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels());
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_onSimulatorChanged(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels());
|
||||
this->setSimulator(simulator);
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
|
||||
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
|
||||
this->ps_changeSimulator(simulator);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_onRowCountChanged(int count, bool withFilter)
|
||||
@@ -212,12 +228,12 @@ namespace BlackGui
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
int realUnfilteredCount = ui->tvp_OwnModelSet->container().size();
|
||||
bool canSave = this->m_simulator.isSingleSimulator() && (realUnfilteredCount > 0);
|
||||
bool canSave = this->getModelSetSimulator().isSingleSimulator() && (realUnfilteredCount > 0);
|
||||
this->ui->pb_SaveAsSetForSimulator->setEnabled(canSave);
|
||||
if (canSave)
|
||||
{
|
||||
this->setSaveFileName(this->m_simulator);
|
||||
ui->pb_SaveAsSetForSimulator->setText("save for " + this->m_simulator.toQString(true));
|
||||
this->setSaveFileName(this->getModelSetSimulator());
|
||||
ui->pb_SaveAsSetForSimulator->setText("save for " + this->getModelSetSimulator().toQString(true));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -243,6 +259,11 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_modelChanged()
|
||||
{
|
||||
ui->pb_SaveAsSetForSimulator->setEnabled(true);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &sim)
|
||||
{
|
||||
Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
@@ -250,10 +271,11 @@ namespace BlackGui
|
||||
this->ui->tvp_OwnModelSet->setSaveFileName(name);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &sim)
|
||||
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->m_simulator = sim;
|
||||
this->ui->le_Simulator->setText(sim.toQString(true));
|
||||
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
|
||||
this->m_modelSetLoader.changeSimulator(simulator);
|
||||
this->ui->le_Simulator->setText(simulator.toQString(true));
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)
|
||||
|
||||
@@ -67,15 +67,15 @@ namespace BlackGui
|
||||
const BlackMisc::Simulation::CAircraftModelList &getModelSet() const;
|
||||
|
||||
//! Model set is for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getModelSetSimulator() const { return m_simulator; }
|
||||
const Simulation::CSimulatorInfo getModelSetSimulator() const;
|
||||
|
||||
//! \copydoc CDbMappingComponentAware::setMappingComponent
|
||||
virtual void setMappingComponent(CDbMappingComponent *component) override;
|
||||
|
||||
//! \name Implementations of the models interfaces
|
||||
//! @{
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setModelSet(models, this->m_simulator); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->replaceOrAddModelSet(models, this->m_simulator); }
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setModelSet(models, this->getModelSetSimulator()); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->replaceOrAddModelSet(models, this->getModelSetSimulator()); }
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { this->setModelSet(models, simulator); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { this->replaceOrAddModelSet(models, simulator); }
|
||||
//! @}
|
||||
@@ -109,19 +109,21 @@ namespace BlackGui
|
||||
//! Preferences changed
|
||||
void ps_preferencesChanged();
|
||||
|
||||
//! Model has been changed
|
||||
void ps_modelChanged();
|
||||
|
||||
private:
|
||||
//! Default file name
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
|
||||
//! Simulator
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
void setSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Update distributor order
|
||||
void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
|
||||
QScopedPointer<CDbOwnModelSetDialog> m_modelSetDialog;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator;
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this };
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::ps_preferencesChanged };
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
|
||||
#include "registermetadatacomponents.h"
|
||||
#include "blackgui/components/data/lastselections.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -16,8 +15,7 @@ namespace BlackGui
|
||||
{
|
||||
void registerMetadata()
|
||||
{
|
||||
Data::CDbOwnModelsComponent::registerMetadata();
|
||||
}
|
||||
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user