mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #618, own component for GUI own model handling
* moved to own component * ajdjusted last selections * some renaming such as getView() -> view()
This commit is contained in:
@@ -17,13 +17,13 @@ namespace BlackGui
|
||||
{
|
||||
namespace Data
|
||||
{
|
||||
QString CDbMappingComponent::convertToQString(bool i18n) const
|
||||
QString CDbOwnModelsComponent::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s(this->m_simulator.toQString(i18n));
|
||||
return s;
|
||||
}
|
||||
|
||||
CVariant CDbMappingComponent::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
CVariant CDbOwnModelsComponent::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
@@ -36,9 +36,9 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbMappingComponent::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
void CDbOwnModelsComponent::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CDbMappingComponent>(); return; }
|
||||
if (index.isMyself()) { (*this) = variant.to<CDbOwnModelsComponent>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
int CDbMappingComponent::comparePropertyByIndex(const CDbMappingComponent &compareValue, const CPropertyIndex &index) const
|
||||
int CDbOwnModelsComponent::comparePropertyByIndex(const CDbOwnModelsComponent &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->toQString().compare(compareValue.toQString()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackGui
|
||||
/*!
|
||||
* Store last selections/interactions with this component
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbMappingComponent : public BlackMisc::CValueObject<CDbMappingComponent>
|
||||
class BLACKGUI_EXPORT CDbOwnModelsComponent : public BlackMisc::CValueObject<CDbOwnModelsComponent>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
@@ -51,32 +51,32 @@ namespace BlackGui
|
||||
void setPropertyByIndex(const BlackMisc::CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CDbMappingComponent &compareValue, const BlackMisc::CPropertyIndex &index) const;
|
||||
int comparePropertyByIndex(const CDbOwnModelsComponent &compareValue, const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CDbMappingComponent)
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CDbOwnModelsComponent)
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< Last simulator selection
|
||||
};
|
||||
|
||||
//! Trait for model cache
|
||||
struct DbMappingComponent : public BlackMisc::CDataTrait<CDbMappingComponent>
|
||||
struct DbOwnModelsComponent : public BlackMisc::CDataTrait<CDbOwnModelsComponent>
|
||||
{
|
||||
//! Default value
|
||||
static const CDbMappingComponent &defaultValue()
|
||||
static const CDbOwnModelsComponent &defaultValue()
|
||||
{
|
||||
static const CDbMappingComponent ls;
|
||||
static const CDbOwnModelsComponent ls;
|
||||
return ls;
|
||||
}
|
||||
|
||||
//! Key in data cache
|
||||
static const char *key() { return "dbmappingcomponent"; }
|
||||
static const char *key() { return "dbownmodelscomponent"; }
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Q_DECLARE_METATYPE(BlackGui::Components::Data::CDbMappingComponent)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackGui::Components::Data::CDbMappingComponent, (
|
||||
Q_DECLARE_METATYPE(BlackGui::Components::Data::CDbOwnModelsComponent)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackGui::Components::Data::CDbOwnModelsComponent, (
|
||||
attr(o.m_simulator)
|
||||
))
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QFile>
|
||||
#include <QShortcut>
|
||||
#include <QDesktopServices>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
@@ -47,41 +46,27 @@ namespace BlackGui
|
||||
|
||||
this->ui->tvp_AircraftModelsForVPilot->setAircraftModelMode(CAircraftModelListModel::VPilotRuleModel);
|
||||
this->ui->tvp_AircraftModelsForVPilot->addFilterDialog();
|
||||
this->ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
|
||||
this->ui->tvp_OwnAircraftModels->addFilterDialog();
|
||||
|
||||
// own models
|
||||
ui->comp_OwnAircraftModels->view()->setCustomMenu(new CModelStashTools(this, false));
|
||||
|
||||
// connects
|
||||
connect(ui->editor_Model, &CModelMappingForm::requestStash, this, &CDbMappingComponent::ps_stashCurrentModel);
|
||||
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onOwnModelsCountChanged);
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbMappingComponent::ps_requestOwnModelsUpdate);
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onOwnModelsCountChanged);
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
||||
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||
|
||||
connect(ui->comp_StashAircraft->getView(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onStashCountChanged);
|
||||
connect(ui->comp_StashAircraft->getView(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
connect(ui->comp_StashAircraft->getView(), &CAircraftModelView::requestHandlingOfStashDrop, this, &CDbMappingComponent::ps_handleStashDropRequest);
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onStashCountChanged);
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
connect(ui->comp_StashAircraft->view(), &CAircraftModelView::requestHandlingOfStashDrop, this, &CDbMappingComponent::ps_handleStashDropRequest);
|
||||
connect(ui->comp_StashAircraft, &CDbStashComponent::stashedModelsChanged, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||
connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this, &CDbMappingComponent::ps_onModelsSuccessfullyPublished);
|
||||
|
||||
connect(ui->comp_OwnModelSet->getView(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onModelSetCountChanged);
|
||||
connect(ui->comp_OwnModelSet->view(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onModelSetCountChanged);
|
||||
connect(ui->tw_ModelsToBeMapped, &QTabWidget::currentChanged, this, &CDbMappingComponent::tabIndexChanged);
|
||||
|
||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CShowSimulatorFile(this), false);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingOwnSimulatorModelMenu(this));
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CModelStashTools(this, false));
|
||||
|
||||
this->m_lastInteractions.synchronize();
|
||||
const CSimulatorInfo sim = this->m_lastInteractions.get().getLastSimulatorSelection();
|
||||
if (sim.isSingleSimulator())
|
||||
{
|
||||
// if we have already use this before, use it again, but only from cache
|
||||
this->initModelLoader(sim);
|
||||
this->m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
|
||||
}
|
||||
|
||||
// how to display forms
|
||||
ui->editor_AircraftIcao->setSelectOnly();
|
||||
ui->editor_Distributor->setSelectOnly();
|
||||
@@ -89,7 +74,7 @@ namespace BlackGui
|
||||
|
||||
this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
|
||||
this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
|
||||
this->ui->comp_StashAircraft->getView()->setCustomMenu(new CApplyDbDataMenu(this));
|
||||
this->ui->comp_StashAircraft->view()->setCustomMenu(new CApplyDbDataMenu(this));
|
||||
|
||||
// vPilot
|
||||
this->initVPilotLoading();
|
||||
@@ -141,34 +126,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
bool CDbMappingComponent::initModelLoader(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
// already loaded
|
||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simInfo))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// unload old
|
||||
if (this->m_modelLoader) { this->m_modelLoader->cancelLoading(); }
|
||||
|
||||
this->m_modelLoader = IAircraftModelLoader::createModelLoader(simInfo);
|
||||
if (!this->m_modelLoader || !this->m_modelLoader->supportsSimulator(simInfo))
|
||||
{
|
||||
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
||||
this->m_modelLoader.reset();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool c = connect(this->m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbMappingComponent::ps_onOwnModelsLoadingFinished);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
||||
Q_UNUSED(c);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftModel CDbMappingComponent::getModelFromView(const QModelIndex &index) const
|
||||
{
|
||||
if (!index.isValid()) { return CAircraftModel(); }
|
||||
@@ -177,13 +134,13 @@ namespace BlackGui
|
||||
{
|
||||
return this->ui->tvp_AircraftModelsForVPilot->at(index);
|
||||
}
|
||||
else if (sender == this->ui->tvp_OwnAircraftModels)
|
||||
else if (sender == this->ui->comp_OwnAircraftModels->view())
|
||||
{
|
||||
return this->ui->tvp_OwnAircraftModels->at(index);
|
||||
return this->ui->comp_OwnAircraftModels->view()->at(index);
|
||||
}
|
||||
else if (sender == this->ui->comp_StashAircraft || sender == this->ui->comp_StashAircraft->getView())
|
||||
else if (sender == this->ui->comp_StashAircraft || sender == this->ui->comp_StashAircraft->view())
|
||||
{
|
||||
return this->ui->comp_StashAircraft->getView()->at(index);
|
||||
return this->ui->comp_StashAircraft->view()->at(index);
|
||||
}
|
||||
|
||||
// no sender, use current tab
|
||||
@@ -196,7 +153,7 @@ namespace BlackGui
|
||||
{
|
||||
this->disconnect();
|
||||
this->m_vPilotReader.gracefulShutdown();
|
||||
if (this->m_modelLoader) { this->m_modelLoader->gracefulShutdown(); }
|
||||
ui->comp_OwnAircraftModels->gracefulShutdown();
|
||||
}
|
||||
|
||||
bool CDbMappingComponent::hasSelectedModelsToStash() const
|
||||
@@ -205,7 +162,7 @@ namespace BlackGui
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels:
|
||||
return ui->tvp_OwnAircraftModels->hasSelectedModelsToStash();
|
||||
return ui->comp_OwnAircraftModels->view()->hasSelectedModelsToStash();
|
||||
case TabVPilot:
|
||||
return ui->tvp_AircraftModelsForVPilot->hasSelectedModelsToStash();
|
||||
default:
|
||||
@@ -220,13 +177,13 @@ namespace BlackGui
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels:
|
||||
return ui->tvp_OwnAircraftModels;
|
||||
return ui->comp_OwnAircraftModels->view();
|
||||
case TabVPilot:
|
||||
return ui->tvp_AircraftModelsForVPilot;
|
||||
case TabStash:
|
||||
return ui->comp_StashAircraft->getView();
|
||||
return ui->comp_StashAircraft->view();
|
||||
case TabOwnModelSet:
|
||||
return ui->comp_OwnModelSet->getView();
|
||||
return ui->comp_OwnModelSet->view();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
@@ -245,7 +202,7 @@ namespace BlackGui
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels:
|
||||
return ui->tvp_OwnAircraftModels->selectedObjects();
|
||||
return ui->comp_OwnAircraftModels->view()->selectedObjects();
|
||||
case TabVPilot:
|
||||
return ui->tvp_AircraftModelsForVPilot->selectedObjects();
|
||||
default:
|
||||
@@ -264,32 +221,6 @@ namespace BlackGui
|
||||
return ui->comp_StashAircraft->getStashedModelStrings();
|
||||
}
|
||||
|
||||
CAircraftModel CDbMappingComponent::getOwnModelForModelString(const QString &modelString) const
|
||||
{
|
||||
if (!this->m_modelLoader) { return CAircraftModel(); }
|
||||
return this->m_modelLoader->getAircraftModels().findFirstByModelString(modelString);
|
||||
}
|
||||
|
||||
CAircraftModelList CDbMappingComponent::getOwnModels() const
|
||||
{
|
||||
static const CAircraftModelList empty;
|
||||
if (!this->m_modelLoader) { return empty; }
|
||||
return this->m_modelLoader->getAircraftModels();
|
||||
}
|
||||
|
||||
const CSimulatorInfo &CDbMappingComponent::getOwnModelsSimulator() const
|
||||
{
|
||||
static const CSimulatorInfo noSim;
|
||||
if (!this->m_modelLoader) { return noSim; }
|
||||
return this->m_modelLoader->getSimulator();
|
||||
}
|
||||
|
||||
int CDbMappingComponent::getOwnModelsCount() const
|
||||
{
|
||||
if (!this->m_modelLoader) { return 0; }
|
||||
return this->m_modelLoader->getAircraftModelsCount();
|
||||
}
|
||||
|
||||
CDbMappingComponent::TabIndex CDbMappingComponent::currentTabIndex() const
|
||||
{
|
||||
if (!ui->tw_ModelsToBeMapped) { return CDbMappingComponent::NoValidTab; }
|
||||
@@ -363,7 +294,7 @@ namespace BlackGui
|
||||
if (!sender) { return; }
|
||||
QString cn(sender->data().toString());
|
||||
if (cn.isEmpty()) { return; }
|
||||
if (this->ui->comp_StashAircraft->getView()->selectedRowCount() < 1) { return; }
|
||||
if (this->ui->comp_StashAircraft->view()->selectedRowCount() < 1) { return; }
|
||||
|
||||
CStatusMessageList msgs;
|
||||
if (CLivery().getClassName() == cn)
|
||||
@@ -409,9 +340,9 @@ namespace BlackGui
|
||||
void CDbMappingComponent::ps_modifyModelDialog()
|
||||
{
|
||||
// only one model selected, use as default
|
||||
if (this->ui->comp_StashAircraft->getView()->hasSingleSelectedRow())
|
||||
if (this->ui->comp_StashAircraft->view()->hasSingleSelectedRow())
|
||||
{
|
||||
this->m_modelModifyDialog->setValue(this->ui->comp_StashAircraft->getView()->selectedObject());
|
||||
this->m_modelModifyDialog->setValue(this->ui->comp_StashAircraft->view()->selectedObject());
|
||||
}
|
||||
|
||||
QDialog::DialogCode s = static_cast<QDialog::DialogCode>(this->m_modelModifyDialog->exec());
|
||||
@@ -420,26 +351,6 @@ namespace BlackGui
|
||||
this->ui->comp_StashAircraft->applyToSelected(vm);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_showSimulatorFile()
|
||||
{
|
||||
if (!this->currentModelView()->hasSelection()) { return; }
|
||||
const CAircraftModelList models(this->currentModelView()->selectedObjects().findWithFileName());
|
||||
if (models.isEmpty()) { return; }
|
||||
int trails = 0;
|
||||
|
||||
for (const CAircraftModel &model : models)
|
||||
{
|
||||
trails++;
|
||||
if (QFile::exists(model.getFileName()))
|
||||
{
|
||||
const QString url("file:///" + model.getFileName());
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
break;
|
||||
}
|
||||
if (trails > 10) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
void CDbMappingComponent::resizeForSelect()
|
||||
{
|
||||
this->maxTableView();
|
||||
@@ -515,7 +426,7 @@ namespace BlackGui
|
||||
{
|
||||
CLogMessage(this).error("Loading vPilot ruleset failed");
|
||||
}
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
this->ui->comp_OwnAircraftModels->view()->hideLoadIndicator();
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_onVPilotCacheChanged()
|
||||
@@ -531,18 +442,10 @@ namespace BlackGui
|
||||
this->ps_onVPilotCacheChanged();
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_requestOwnModelsUpdate()
|
||||
{
|
||||
if (!this->m_modelLoader) { return; }
|
||||
this->ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(
|
||||
this->m_modelLoader->getAircraftModels()
|
||||
);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_onStashedModelsChanged()
|
||||
{
|
||||
const bool hlvp = this->ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModelStrings();
|
||||
const bool hlom = this->ui->tvp_OwnAircraftModels->derivedModel()->highlightModelStrings();
|
||||
const bool hlom = this->ui->comp_OwnAircraftModels->view()->derivedModel()->highlightModelStrings();
|
||||
const bool highlight = hlom || hlvp;
|
||||
if (!highlight) { return; }
|
||||
const QStringList stashedModels(this->ui->comp_StashAircraft->getStashedModelStrings());
|
||||
@@ -552,7 +455,7 @@ namespace BlackGui
|
||||
}
|
||||
if (hlom)
|
||||
{
|
||||
this->ui->tvp_OwnAircraftModels->derivedModel()->setHighlightModelStrings(stashedModels);
|
||||
this->ui->comp_OwnAircraftModels->view()->derivedModel()->setHighlightModelStrings(stashedModels);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,13 +483,10 @@ namespace BlackGui
|
||||
const int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_OwnModels);
|
||||
static const QString ot(this->ui->tw_ModelsToBeMapped->tabText(i));
|
||||
QString o(ot);
|
||||
if (this->m_modelLoader)
|
||||
{
|
||||
QString sims(this->m_modelLoader->getSimulatorAsString());
|
||||
if (!sims.isEmpty()) { o = o.append(" ").append(sims); }
|
||||
}
|
||||
QString f = this->ui->tvp_OwnAircraftModels->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->tvp_OwnAircraftModels->rowCount()) + f;
|
||||
const QString sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator().toQString(true));
|
||||
if (!sim.isEmpty()) { o = o.append(" ").append(sim); }
|
||||
QString f = this->ui->comp_OwnAircraftModels->view()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_OwnAircraftModels->view()->rowCount()) + f;
|
||||
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||
}
|
||||
|
||||
@@ -596,8 +496,8 @@ namespace BlackGui
|
||||
Q_UNUSED(withFilter);
|
||||
int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_StashAircraftModels);
|
||||
QString o = this->ui->tw_ModelsToBeMapped->tabText(i);
|
||||
QString f = this->ui->comp_StashAircraft->getView()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_StashAircraft->getView()->rowCount()) + f;
|
||||
const QString f = this->ui->comp_StashAircraft->view()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_StashAircraft->view()->rowCount()) + f;
|
||||
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||
}
|
||||
|
||||
@@ -606,17 +506,12 @@ namespace BlackGui
|
||||
Q_UNUSED(count);
|
||||
Q_UNUSED(withFilter);
|
||||
int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_OwnModelSet);
|
||||
QString o = this->ui->tw_ModelsToBeMapped->tabText(i);
|
||||
QString f = this->ui->comp_StashAircraft->getView()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_OwnModelSet->getView()->rowCount()) + f;
|
||||
QString o = "Model set " + ui->comp_OwnModelSet->getModelSetSimulator().toQString(true);
|
||||
const QString f = this->ui->comp_StashAircraft->view()->hasFilter() ? "F" : "";
|
||||
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_OwnModelSet->view()->rowCount()) + f;
|
||||
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_requestSimulatorModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
this->ps_loadInstalledModels(simInfo, mode);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_userChanged()
|
||||
{
|
||||
this->initVPilotLoading();
|
||||
@@ -684,58 +579,6 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
if (!this->initModelLoader(simInfo))
|
||||
{
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simInfo.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->m_modelLoader->isLoadingFinished())
|
||||
{
|
||||
CLogMessage(this).info("Loading for %1 already in progress") << simInfo.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
CLogMessage(this).info("Starting loading for %1") << simInfo.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 CDbMappingComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simInfo)
|
||||
{
|
||||
Q_ASSERT_X(simInfo.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::CDbMappingComponent mc(this->m_lastInteractions.get());
|
||||
if (simInfo.isSingleSimulator() && mc.getLastSimulatorSelection() != simInfo)
|
||||
{
|
||||
mc.setLastSimulatorSelection(simInfo);
|
||||
this->m_lastInteractions.set(mc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loading ok, but no data
|
||||
CLogMessage(this).warning("Loading completed, but no models");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
CLogMessage(this).error("Loading of models failed, simulator %1") << simInfo.toQString();
|
||||
}
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
}
|
||||
|
||||
CAircraftModel CDbMappingComponent::getEditorAircraftModel() const
|
||||
{
|
||||
CAircraftModel model(ui->editor_Model->getValue());
|
||||
@@ -745,6 +588,26 @@ namespace BlackGui
|
||||
return model;
|
||||
}
|
||||
|
||||
CAircraftModelList CDbMappingComponent::getOwnModels() const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModels();
|
||||
}
|
||||
|
||||
CAircraftModel CDbMappingComponent::getOwnModelForModelString(const QString &modelString) const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelForModelString(modelString);
|
||||
}
|
||||
|
||||
const CSimulatorInfo &CDbMappingComponent::getOwnModelsSimulator() const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
|
||||
}
|
||||
|
||||
int CDbMappingComponent::getOwnModelsCount() const
|
||||
{
|
||||
return this->ui->comp_OwnAircraftModels->getOwnModelsCount();
|
||||
}
|
||||
|
||||
CStatusMessage CDbMappingComponent::stashModel(const CAircraftModel &model, bool replace)
|
||||
{
|
||||
return this->ui->comp_StashAircraft->stashModel(model, replace);
|
||||
@@ -765,82 +628,6 @@ namespace BlackGui
|
||||
this->ui->comp_StashAircraft->replaceModelsUnvalidated(models);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::CMappingOwnSimulatorModelMenu::customMenu(QMenu &menu) const
|
||||
{
|
||||
CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
|
||||
bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||
if (!noSims)
|
||||
{
|
||||
this->addSeparator(menu);
|
||||
QMenu *load = menu.addMenu(CIcons::appModels16(), "Load installed models");
|
||||
CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
|
||||
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access parent");
|
||||
if (sims.fsx())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "FSX models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.p3d())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "P3D models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.fs9())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.xplane())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "XP models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
|
||||
// with models loaded I allow a refresh reload
|
||||
if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0)
|
||||
{
|
||||
QMenu *reloadMenu = load->addMenu("Force reload");
|
||||
if (sims.fsx())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "FSX models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.p3d())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "P3D models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.fs9())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.xplane())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "XP models", mapComp, [mapComp]()
|
||||
{
|
||||
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this->nestedCustomMenu(menu);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::CMappingVPilotMenu::customMenu(QMenu &menu) const
|
||||
{
|
||||
CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
|
||||
@@ -873,22 +660,22 @@ namespace BlackGui
|
||||
int dbModels = sGui->getWebDataServices()->getModelsCount();
|
||||
if (dbModels > 0)
|
||||
{
|
||||
// we have keys and data where we could delete them from
|
||||
// we have keys and data where we could delete them from view
|
||||
const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from " + mapComp->currentTabText());
|
||||
menu.addAction(CIcons::delete16(), msgDelete, mapComp, SLOT(ps_removeDbModelsFromView()));
|
||||
menu.addAction(CIcons::delete16(), msgDelete, mapComp, &CDbMappingComponent::ps_removeDbModelsFromView);
|
||||
}
|
||||
|
||||
// we have keys and data where we could delete them from
|
||||
const QString msgAutoStash("Auto stashing");
|
||||
menu.addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, SLOT(ps_displayAutoStashingDialog()));
|
||||
menu.addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog);
|
||||
|
||||
if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted())
|
||||
{
|
||||
menu.addAction(CIcons::appDbStash16(), "Last auto stash run", mapComp->m_autoStashDialog.data(), SLOT(showLastResults()));
|
||||
menu.addAction(CIcons::appDbStash16(), "Last auto stash run", mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults);
|
||||
}
|
||||
|
||||
// auto filter in DB views
|
||||
QAction *a = menu.addAction(CIcons::filter16(), "Auto filtering in DB views (on/off)", mapComp, SLOT(ps_toggleAutoFiltering()));
|
||||
QAction *a = menu.addAction(CIcons::filter16(), "Auto filtering in DB views (on/off)", mapComp, &CDbMappingComponent::ps_toggleAutoFiltering);
|
||||
a->setCheckable(true);
|
||||
a->setChecked(mapComp->m_autoFilterInDbViews);
|
||||
}
|
||||
@@ -914,16 +701,20 @@ namespace BlackGui
|
||||
QMenu *subMenu = menu.addMenu(CIcons::database16(), "Apply DB data (to selected)");
|
||||
QAction *a = nullptr;
|
||||
|
||||
a = subMenu->addAction(CIcons::appAircraftIcao16(), "Current aircraft ICAO", mapComp, SLOT(ps_applyDbData()));
|
||||
a = subMenu->addAction(CIcons::appAircraftIcao16(), "Current aircraft ICAO", mapComp, &CDbMappingComponent::ps_applyDbData);
|
||||
a->setData(CAircraftIcaoCode().getClassName());
|
||||
|
||||
a = subMenu->addAction(CIcons::appDistributors16(), "Current distributor", mapComp, SLOT(ps_applyDbData()));
|
||||
a = subMenu->addAction(CIcons::appDistributors16(), "Current distributor", mapComp, &CDbMappingComponent::ps_applyDbData);
|
||||
a->setData(CDistributor().getClassName());
|
||||
|
||||
a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, SLOT(ps_applyDbData()));
|
||||
a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, &CDbMappingComponent::ps_applyDbData);
|
||||
a->setData(CLivery().getClassName());
|
||||
|
||||
menu.addAction(CIcons::databaseTable16(), "Modify model data", mapComp, SLOT(ps_modifyModelDialog()));
|
||||
// a = subMenu->addAction(CIcons::appAirlineIcao16(), "Current airline ICAO", mapComp, &CDbMappingComponent::ps_applyDbData);
|
||||
// a->setData(CAirlineIcaoCode().getClassName());
|
||||
|
||||
menu.addAction(CIcons::databaseTable16(), "Modify model data", mapComp, &CDbMappingComponent::ps_applyDbData);
|
||||
a->setData(CAircraftModel().getClassName());
|
||||
}
|
||||
this->nestedCustomMenu(menu);
|
||||
}
|
||||
@@ -932,25 +723,5 @@ namespace BlackGui
|
||||
{
|
||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||
}
|
||||
|
||||
void CDbMappingComponent::CShowSimulatorFile::customMenu(QMenu &menu) const
|
||||
{
|
||||
CDbMappingComponent *mapComp = mappingComponent();
|
||||
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
|
||||
|
||||
if (mapComp->currentTabIndex() == CDbMappingComponent::TabOwnModels && mapComp->currentModelView()->hasSelection())
|
||||
{
|
||||
this->addSeparator(menu);
|
||||
menu.addAction(CIcons::text16(), "Open simulator file", mapComp, SLOT(ps_showSimulatorFile()));
|
||||
}
|
||||
|
||||
this->nestedCustomMenu(menu);
|
||||
}
|
||||
|
||||
CDbMappingComponent *CDbMappingComponent::CShowSimulatorFile::mappingComponent() const
|
||||
{
|
||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "blackcore/data/authenticateduser.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/menus/menudelegate.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/data/lastselections.h"
|
||||
@@ -83,18 +83,6 @@ namespace BlackGui
|
||||
//! Stashed model strings
|
||||
QStringList getStashedModelStrings() const;
|
||||
|
||||
//! Own (installed) model for given model string
|
||||
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! Own models
|
||||
BlackMisc::Simulation::CAircraftModelList getOwnModels() const;
|
||||
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
|
||||
//! Current tab index
|
||||
TabIndex currentTabIndex() const;
|
||||
|
||||
@@ -108,6 +96,22 @@ namespace BlackGui
|
||||
//! \note not guaranteed to be valid, just a snapshot of its current editor state
|
||||
BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const;
|
||||
|
||||
//! \name Own models from BlackGui::Components::CDbOwnModelsComponent
|
||||
//! @{
|
||||
|
||||
//! Own models
|
||||
BlackMisc::Simulation::CAircraftModelList getOwnModels() const;
|
||||
|
||||
//! Own (installed) model for given model string
|
||||
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
//! @}
|
||||
|
||||
public slots:
|
||||
//! \copydoc CDbStashComponent::stashModel
|
||||
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
||||
@@ -165,9 +169,6 @@ namespace BlackGui
|
||||
//! Request update of vPilot data
|
||||
void ps_requestVPilotDataUpdate();
|
||||
|
||||
//! Request own models
|
||||
void ps_requestOwnModelsUpdate();
|
||||
|
||||
//! Stashed models changed
|
||||
void ps_onStashedModelsChanged();
|
||||
|
||||
@@ -189,18 +190,6 @@ namespace BlackGui
|
||||
//! Row has been selected
|
||||
void ps_onModelRowSelected(const QModelIndex &index);
|
||||
|
||||
//! Load the models
|
||||
void ps_loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
//! Model loading finished
|
||||
void ps_onOwnModelsLoadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! Own model count changed
|
||||
void ps_onOwnModelsCountChanged(int count, bool withFilter);
|
||||
|
||||
//! Request simulator models
|
||||
void ps_requestSimulatorModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
//! User object changed
|
||||
void ps_userChanged();
|
||||
|
||||
@@ -222,18 +211,16 @@ namespace BlackGui
|
||||
//! Open model modify dialog
|
||||
void ps_modifyModelDialog();
|
||||
|
||||
//! Open simulator file
|
||||
void ps_showSimulatorFile();
|
||||
//! Own models have been changed
|
||||
void ps_onOwnModelsCountChanged(int count, bool withFilter);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing
|
||||
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog; //!< dialog when modifying models
|
||||
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
|
||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
|
||||
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
|
||||
BlackMisc::CData<BlackGui::Components::Data::DbMappingComponent> m_lastInteractions {this}; //!< last interactions
|
||||
bool m_vPilot1stInit = true;
|
||||
bool m_withVPilot = false;
|
||||
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
|
||||
@@ -241,9 +228,6 @@ namespace BlackGui
|
||||
//! Init vPilot if rights and suitable
|
||||
void initVPilotLoading();
|
||||
|
||||
//! Init model loader
|
||||
bool initModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! Model for given index from sender/current view
|
||||
BlackMisc::Simulation::CAircraftModel getModelFromView(const QModelIndex &index) const;
|
||||
|
||||
@@ -252,28 +236,14 @@ namespace BlackGui
|
||||
|
||||
// -------------------- component specific menus --------------------------
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
class CMappingOwnSimulatorModelMenu : public BlackGui::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CMappingOwnSimulatorModelMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
};
|
||||
|
||||
//! The menu for loading and handling VPilot rules for mapping tasks
|
||||
//! \note This is a specific menu for that very component
|
||||
class CMappingVPilotMenu : public BlackGui::IMenuDelegate
|
||||
class CMappingVPilotMenu : public BlackGui::Menus::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CMappingVPilotMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||
BlackGui::Menus::IMenuDelegate(mappingComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
@@ -289,12 +259,12 @@ namespace BlackGui
|
||||
//! -# for auto stashing
|
||||
//! -# toggle auto filtering
|
||||
//! \note This is a specific menu for that very component
|
||||
class CModelStashTools : public BlackGui::IMenuDelegate
|
||||
class CModelStashTools : public BlackGui::Menus::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CModelStashTools(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||
BlackGui::Menus::IMenuDelegate(mappingComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
@@ -306,29 +276,12 @@ namespace BlackGui
|
||||
};
|
||||
|
||||
//! Apply DB data to selected models
|
||||
class CApplyDbDataMenu : public BlackGui::IMenuDelegate
|
||||
class CApplyDbDataMenu : public BlackGui::Menus::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CApplyDbDataMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
|
||||
private:
|
||||
//! Mapping component
|
||||
CDbMappingComponent *mappingComponent() const;
|
||||
};
|
||||
|
||||
//! Open up the simulator file (e.g. aircraft.cfg) in the standard text editor
|
||||
class CShowSimulatorFile : public BlackGui::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CShowSimulatorFile(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||
BlackGui::Menus::IMenuDelegate(mappingComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tw_ModelsToBeMapped">
|
||||
<property name="currentIndex">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_StashAircraftModels">
|
||||
<attribute name="title">
|
||||
@@ -104,7 +104,7 @@
|
||||
<attribute name="title">
|
||||
<string>Own models</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="hl_OwnModels">
|
||||
<layout class="QHBoxLayout" name="hl_OwnAircraftModels">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
@@ -121,22 +121,13 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_OwnAircraftModels">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<widget class="BlackGui::Components::CDbOwnModelsComponent" name="comp_OwnAircraftModels">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -442,6 +433,12 @@
|
||||
<header>blackgui/components/dbownmodelsetcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbOwnModelsComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbownmodelscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/menus/menudelegate.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
@@ -28,7 +28,7 @@ namespace BlackGui
|
||||
namespace Components
|
||||
{
|
||||
/**
|
||||
* Database models from DB
|
||||
* Database models. Those are the models loaaded from the DB.
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbModelComponent :
|
||||
public QFrame,
|
||||
|
||||
271
src/blackgui/components/dbownmodelscomponent.cpp
Normal file
271
src/blackgui/components/dbownmodelscomponent.cpp
Normal file
@@ -0,0 +1,271 @@
|
||||
/* 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 "dbownmodelscomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/menus/aircraftmodelmenus.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "ui_dbownmodelscomponent.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Menus;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CDbOwnModelsComponent::CDbOwnModelsComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CDbOwnModelsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
|
||||
ui->tvp_OwnAircraftModels->addFilterDialog();
|
||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CShowSimulatorFileMenu(ui->tvp_OwnAircraftModels, false), true);
|
||||
|
||||
connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this, &CDbOwnModelsComponent::ps_requestOwnModelsUpdate);
|
||||
|
||||
this->m_lastInteractions.synchronize();
|
||||
const CSimulatorInfo sim = this->m_lastInteractions.get().getLastSimulatorSelection();
|
||||
if (sim.isSingleSimulator())
|
||||
{
|
||||
// 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->m_modelLoader.get(), false));
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this, true));
|
||||
}
|
||||
|
||||
CDbOwnModelsComponent::~CDbOwnModelsComponent()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
CAircraftModelView *CDbOwnModelsComponent::view() const
|
||||
{
|
||||
return ui->tvp_OwnAircraftModels;
|
||||
}
|
||||
|
||||
CAircraftModelListModel *CDbOwnModelsComponent::model() const
|
||||
{
|
||||
return ui->tvp_OwnAircraftModels->derivedModel();
|
||||
}
|
||||
|
||||
CAircraftModel CDbOwnModelsComponent::getOwnModelForModelString(const QString &modelString) const
|
||||
{
|
||||
if (!this->m_modelLoader) { return CAircraftModel(); }
|
||||
return this->m_modelLoader->getAircraftModels().findFirstByModelStringOrDefault(modelString);
|
||||
}
|
||||
|
||||
CAircraftModelList CDbOwnModelsComponent::getOwnModels() const
|
||||
{
|
||||
static const CAircraftModelList empty;
|
||||
if (!this->m_modelLoader) { return empty; }
|
||||
return this->m_modelLoader->getAircraftModels();
|
||||
}
|
||||
|
||||
const CSimulatorInfo &CDbOwnModelsComponent::getOwnModelsSimulator() const
|
||||
{
|
||||
static const CSimulatorInfo noSim;
|
||||
if (!this->m_modelLoader) { return noSim; }
|
||||
return this->m_modelLoader->getSimulator();
|
||||
}
|
||||
|
||||
int CDbOwnModelsComponent::getOwnModelsCount() const
|
||||
{
|
||||
if (!this->m_modelLoader) { return 0; }
|
||||
return this->m_modelLoader->getAircraftModelsCount();
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::gracefulShutdown()
|
||||
{
|
||||
if (this->m_modelLoader) { this->m_modelLoader->gracefulShutdown(); }
|
||||
}
|
||||
|
||||
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
// already loaded
|
||||
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
if (this->m_modelLoader && this->m_modelLoader->supportsSimulator(simInfo))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// unload old
|
||||
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))
|
||||
{
|
||||
CLogMessage(this).error("Failed to init model loader %1") << simInfo.toQString();
|
||||
this->m_modelLoader.reset();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(QMenu &menu) const
|
||||
{
|
||||
CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
|
||||
bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||
if (!noSims)
|
||||
{
|
||||
this->addSeparator(menu);
|
||||
QMenu *load = menu.addMenu(CIcons::appModels16(), "Load installed models");
|
||||
CDbOwnModelsComponent *ownModelsComp = qobject_cast<CDbOwnModelsComponent *>(this->parent());
|
||||
Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent");
|
||||
if (sims.fsx())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.p3d())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.fs9())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
if (sims.xplane())
|
||||
{
|
||||
load->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundWithCache);
|
||||
});
|
||||
}
|
||||
|
||||
// with models loaded I allow a refresh reload
|
||||
if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0)
|
||||
{
|
||||
QMenu *reloadMenu = load->addMenu("Force reload");
|
||||
if (sims.fsx())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "FSX models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.p3d())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "P3D models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.fs9())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "FS9 models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FS9), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
if (sims.xplane())
|
||||
{
|
||||
reloadMenu->addAction(CIcons::appModels16(), "XP models", ownModelsComp, [ownModelsComp]()
|
||||
{
|
||||
ownModelsComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::XPLANE), IAircraftModelLoader::InBackgroundNoCache);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
this->nestedCustomMenu(menu);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_requestOwnModelsUpdate()
|
||||
{
|
||||
if (!this->m_modelLoader) { return; }
|
||||
this->ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(
|
||||
this->m_modelLoader->getAircraftModels()
|
||||
);
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
if (!this->initModelLoader(simInfo))
|
||||
{
|
||||
CLogMessage(this).error("Cannot load model loader for %1") << simInfo.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->m_modelLoader->isLoadingFinished())
|
||||
{
|
||||
CLogMessage(this).info("Loading for %1 already in progress") << simInfo.toQString();
|
||||
return;
|
||||
}
|
||||
|
||||
CLogMessage(this).info("Starting loading for %1") << simInfo.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)
|
||||
{
|
||||
Q_ASSERT_X(simInfo.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
|
||||
{
|
||||
// loading ok, but no data
|
||||
CLogMessage(this).warning("Loading completed, but no models");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
CLogMessage(this).error("Loading of models failed, simulator %1") << simInfo.toQString();
|
||||
}
|
||||
this->ui->tvp_OwnAircraftModels->hideLoadIndicator();
|
||||
}
|
||||
|
||||
void CDbOwnModelsComponent::ps_requestSimulatorModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
|
||||
{
|
||||
this->ps_loadInstalledModels(simInfo, mode);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
101
src/blackgui/components/dbownmodelscomponent.h
Normal file
101
src/blackgui/components/dbownmodelscomponent.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* 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_DBOWNMODELSCOMPONENT_H
|
||||
#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>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CDbOwnModelsComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views { class CAircraftModelView; }
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
* Handling of own models on disk (the models installed for the simulator)
|
||||
*/
|
||||
class CDbOwnModelsComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CDbOwnModelsComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CDbOwnModelsComponent();
|
||||
|
||||
//! Own (installed) model for given model string
|
||||
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
|
||||
|
||||
//! Own models
|
||||
BlackMisc::Simulation::CAircraftModelList getOwnModels() const;
|
||||
|
||||
//! Own models for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
|
||||
|
||||
//! Number of own models
|
||||
int getOwnModelsCount() const;
|
||||
|
||||
//! Models view
|
||||
BlackGui::Views::CAircraftModelView *view() const;
|
||||
|
||||
//! Access to aircraft model
|
||||
Models::CAircraftModelListModel *model() const;
|
||||
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
private slots:
|
||||
//! Request own models
|
||||
void ps_requestOwnModelsUpdate();
|
||||
|
||||
//! Load the models
|
||||
void ps_loadInstalledModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, BlackMisc::Simulation::IAircraftModelLoader::LoadMode mode);
|
||||
|
||||
//! Model loading finished
|
||||
void ps_onOwnModelsLoadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! Request simulator models
|
||||
void ps_requestSimulatorModels(const BlackMisc::Simulation::CSimulatorInfo &simInfo, 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
|
||||
|
||||
//! Init model loader
|
||||
bool initModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
class CLoadModelsMenu : public BlackGui::Menus::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CLoadModelsMenu(CDbOwnModelsComponent *ownModelsComponent, bool separator = true) :
|
||||
BlackGui::Menus::IMenuDelegate(ownModelsComponent, separator)
|
||||
{}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
56
src/blackgui/components/dbownmodelscomponent.ui
Normal file
56
src/blackgui/components/dbownmodelscomponent.ui
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDbOwnModelsComponent</class>
|
||||
<widget class="QFrame" name="CDbOwnModelsComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_OwnModelsComponent">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_OwnAircraftModels">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAircraftModelView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/aircraftmodelview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -41,7 +41,7 @@ namespace BlackGui
|
||||
// void
|
||||
}
|
||||
|
||||
Views::CAircraftModelView *CDbOwnModelSetComponent::getView() const
|
||||
Views::CAircraftModelView *CDbOwnModelSetComponent::view() const
|
||||
{
|
||||
return ui->tvp_OwnModelSet;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_DBOWNMODELSETCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_DBOWNMODELSETCOMPONENT_H
|
||||
|
||||
@@ -15,7 +17,6 @@
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
|
||||
namespace Ui { class CDbOwnModelSetComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
@@ -42,7 +43,7 @@ namespace BlackGui
|
||||
virtual ~CDbOwnModelSetComponent();
|
||||
|
||||
//! Corresponding view
|
||||
Views::CAircraftModelView *getView() const;
|
||||
Views::CAircraftModelView *view() const;
|
||||
|
||||
//! Set the model set
|
||||
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
@@ -50,6 +51,9 @@ namespace BlackGui
|
||||
//! \copydoc CDbMappingComponentAware::setMappingComponent
|
||||
virtual void setMappingComponent(CDbMappingComponent *component) override;
|
||||
|
||||
//! Model set is for simulator
|
||||
const BlackMisc::Simulation::CSimulatorInfo &getModelSetSimulator() const { return m_simulator; }
|
||||
|
||||
private slots:
|
||||
//! Tab has been changed
|
||||
void ps_tabChanged(int index);
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace BlackGui
|
||||
return this->ui->tvp_StashAircraftModels->removeModelsWithModelString(modelStrings);
|
||||
}
|
||||
|
||||
Views::CAircraftModelView *CDbStashComponent::getView() const
|
||||
CAircraftModelView *CDbStashComponent::view() const
|
||||
{
|
||||
return ui->tvp_StashAircraftModels;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/menus/menudelegate.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
@@ -60,7 +60,7 @@ namespace BlackGui
|
||||
int unstashModels(QStringList modelStrings);
|
||||
|
||||
//! The embedded view
|
||||
BlackGui::Views::CAircraftModelView *getView() const;
|
||||
BlackGui::Views::CAircraftModelView *view() const;
|
||||
|
||||
//! Has stashed models
|
||||
bool hasStashedModels() const;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace BlackGui
|
||||
{
|
||||
void registerMetadata()
|
||||
{
|
||||
Data::CDbMappingComponent::registerMetadata();
|
||||
Data::CDbOwnModelsComponent::registerMetadata();
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user