Allow to add to model set from stash

This commit is contained in:
Klaus Basan
2017-04-08 18:51:51 +02:00
committed by Mathew Sutcliffe
parent eec33847b2
commit 78c618e589
2 changed files with 12 additions and 3 deletions

View File

@@ -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 });

View File

@@ -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;