From 78c618e589daee44b8322e8ae152e559514a30ad Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 8 Apr 2017 18:51:51 +0200 Subject: [PATCH] Allow to add to model set from stash --- src/blackgui/components/dbmappingcomponent.cpp | 12 +++++++++--- src/blackgui/components/dbmappingcomponent.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/blackgui/components/dbmappingcomponent.cpp b/src/blackgui/components/dbmappingcomponent.cpp index e647f0e75..01356b411 100644 --- a/src/blackgui/components/dbmappingcomponent.cpp +++ b/src/blackgui/components/dbmappingcomponent.cpp @@ -91,6 +91,7 @@ namespace BlackGui ui->comp_StashAircraft->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_StashAircraft->view(), this, true)); ui->comp_StashAircraft->view()->setCustomMenu(new CApplyDbDataMenu(this, true)); + ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this, true)); ui->comp_StashAircraft->view()->setCustomMenu(new CModelStashToolsMenu(this, false)); // connects @@ -343,6 +344,12 @@ namespace BlackGui return currentTabIndex() == TabStash; } + bool CDbMappingComponent::canAddToModelSetTab() const + { + const bool allowed = this->currentTabIndex() == CDbMappingComponent::TabOwnModels || this->currentTabIndex() == CDbMappingComponent::TabStash; + return allowed && this->currentModelView()->hasSelection(); + } + CStatusMessageList CDbMappingComponent::validateCurrentModel(bool withNestedForms) const { CStatusMessageList msgs(ui->editor_ModelMapping->validate(!withNestedForms)); @@ -647,8 +654,7 @@ namespace BlackGui void CDbMappingComponent::ps_addToOwnModelSet() { - if (this->currentTabIndex() != CDbMappingComponent::TabOwnModels) { return; } - if (!currentModelView()->hasSelection()) { return; } + if (!this->canAddToModelSetTab()) { return; } const CAircraftModelList models(this->currentModelView()->selectedObjects()); const CStatusMessage m = this->addToOwnModelSet(models, this->getOwnModelsSimulator()); CLogMessage::preformatted(m); @@ -954,7 +960,7 @@ namespace BlackGui { CDbMappingComponent *mapComp = mappingComponent(); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); - if (mapComp->currentTabIndex() == CDbMappingComponent::TabOwnModels && mapComp->currentModelView()->hasSelection()) + if (mapComp->canAddToModelSetTab()) { menuActions.addMenuModelSet(); this->m_menuAction = menuActions.addAction(this->m_menuAction, CIcons::appModels16(), "Add to own model set", CMenuAction::pathModelSet(), this, { mapComp, &CDbMappingComponent::ps_addToOwnModelSet }); diff --git a/src/blackgui/components/dbmappingcomponent.h b/src/blackgui/components/dbmappingcomponent.h index 0e7f9f8ea..aee43cca2 100644 --- a/src/blackgui/components/dbmappingcomponent.h +++ b/src/blackgui/components/dbmappingcomponent.h @@ -107,6 +107,9 @@ namespace BlackGui //! Is stashed view bool isStashTab() const; + //! Tab can contribute to model set + bool canAddToModelSetTab() const; + //! Current model view BlackGui::Views::CAircraftModelView *currentModelView() const;