diff --git a/src/blackgui/components/dbmappingcomponent.cpp b/src/blackgui/components/dbmappingcomponent.cpp index fb80cc30a..a4b1555e5 100644 --- a/src/blackgui/components/dbmappingcomponent.cpp +++ b/src/blackgui/components/dbmappingcomponent.cpp @@ -96,6 +96,10 @@ namespace BlackGui ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this)); ui->comp_StashAircraft->view()->setCustomMenu(new CStashToolsMenu(this)); + ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this)); + ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this)); + ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this)); + // connects connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::stashCurrentModel); @@ -104,6 +108,11 @@ namespace BlackGui connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels); connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::onStashedModelsChangedTriggerDigest); + connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::onModelRowSelected); + connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::modelDataChangedDigest, this, &CDbMappingComponent::onWorkbenchDataChanged, Qt::QueuedConnection); + connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels); + connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::onStashedModelsChangedTriggerDigest); + connect(ui->comp_StashAircraft->view(), &CAircraftModelView::modelDataChangedDigest, this, &CDbMappingComponent::onStashedModelsDataChangedDigest); connect(ui->comp_StashAircraft->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::onModelRowSelected); connect(ui->comp_StashAircraft->view(), &CAircraftModelView::requestHandlingOfStashDrop, this, &CDbMappingComponent::handleStashDropRequest); @@ -129,6 +138,7 @@ namespace BlackGui ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16()); ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16()); ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModelSet, CIcons::appModels16()); + ui->tw_ModelsToBeMapped->setTabIcon(TabWorkbench, CIcons::wrench16()); // custom menu and shortcut this->setContextMenuPolicy(Qt::CustomContextMenu); @@ -203,9 +213,9 @@ namespace BlackGui if (sender == ui->comp_OwnModelSet->view()) { return ui->comp_OwnModelSet->view()->at(index); } // no sender, use current tab - const CAircraftModelView *v = this->currentModelView(); - if (!v) { return CAircraftModel(); } - return v->at(index); + const CAircraftModelView *mv = this->currentModelView(); + if (!mv) { return CAircraftModel(); } + return mv->at(index); } void CDbMappingComponent::gracefulShutdown() @@ -217,20 +227,19 @@ namespace BlackGui bool CDbMappingComponent::hasSelectedModelsToStash() const { - const TabIndex tab = currentTabIndex(); - switch (tab) - { - case TabOwnModels: return ui->comp_OwnAircraftModels->view()->hasSelectedModelsToStash(); - case TabOwnModelSet: return ui->comp_OwnModelSet->view()->hasSelectedModelsToStash(); - case TabVPilot: return ui->tvp_AircraftModelsForVPilot->hasSelectedModelsToStash(); - default: break; - } - return false; + const CAircraftModelView *mv = this->currentModelView(); + if (!mv) { return false; } + return mv->hasSelectedModelsToStash(); } CAircraftModelView *CDbMappingComponent::currentModelView() const { const TabIndex tab = currentTabIndex(); + return this->modelView(tab); + } + + CAircraftModelView *CDbMappingComponent::modelView(TabIndex tab) const + { switch (tab) { case TabOwnModels: return ui->comp_OwnAircraftModels->view(); @@ -285,16 +294,9 @@ namespace BlackGui CAircraftModelList CDbMappingComponent::getSelectedModelsToStash() const { - if (!hasSelectedModelsToStash()) { return CAircraftModelList(); } - const TabIndex tab = currentTabIndex(); - switch (tab) - { - case TabOwnModels: return ui->comp_OwnAircraftModels->view()->selectedObjects(); - case TabOwnModelSet: return ui->comp_OwnModelSet->view()->selectedObjects(); - case TabVPilot: return ui->tvp_AircraftModelsForVPilot->selectedObjects(); - default: break; - } - return CAircraftModelList(); + const CAircraftModelView *mv = this->currentModelView(); + if (!mv || !mv->hasSelectedModelsToStash()) { return CAircraftModelList(); } + return mv->selectedObjects(); } const CAircraftModelList &CDbMappingComponent::getStashedModels() const @@ -388,17 +390,8 @@ namespace BlackGui { const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings()); if (modelStrings.isEmpty()) { return; } - switch (currentTabIndex()) - { - case TabVPilot: - case TabOwnModels: - case TabOwnModelSet: - case TabStash: - this->currentModelView()->removeModelsWithModelString(modelStrings); - break; - default: - break; - } + CAircraftModelView *mv = this->currentModelView(); + if (mv) { mv->removeModelsWithModelString(modelStrings); } } void CDbMappingComponent::showChangedAttributes() @@ -627,17 +620,22 @@ namespace BlackGui { Q_UNUSED(count); Q_UNUSED(withFilter); - const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot); - QString o = ui->tw_ModelsToBeMapped->tabText(i); - const QString f = ui->tvp_AircraftModelsForVPilot->hasFilter() ? "F" : ""; - o = CGuiUtility::replaceTabCountValue(o, ui->tvp_AircraftModelsForVPilot->rowCount()) + f; - ui->tw_ModelsToBeMapped->setTabText(i, o); + ui->tvp_AircraftModelsForVPilot->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot)); + } + + void CDbMappingComponent::onWorkbenchDataChanged(int count, bool withFilter) + { + Q_UNUSED(count); + Q_UNUSED(withFilter); + ui->comp_ModelWorkbench->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_Workbench)); } void CDbMappingComponent::onOwnModelsChangedDigest(int count, bool withFilter) { Q_UNUSED(count); Q_UNUSED(withFilter); + + // non standard with sim const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModels); static const QString ot(ui->tw_ModelsToBeMapped->tabText(i)); QString o(ot); @@ -702,11 +700,7 @@ namespace BlackGui { Q_UNUSED(count); Q_UNUSED(withFilter); - int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels); - QString o = ui->tw_ModelsToBeMapped->tabText(i); - const QString f = ui->comp_StashAircraft->view()->hasFilter() ? "F" : ""; - o = CGuiUtility::replaceTabCountValue(o, ui->comp_StashAircraft->view()->rowCount()) + f; - ui->tw_ModelsToBeMapped->setTabText(i, o); + ui->comp_StashAircraft->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels)); // update editors this->updateEditorsWhenApplicable(); @@ -716,6 +710,8 @@ namespace BlackGui { Q_UNUSED(count); Q_UNUSED(withFilter); + + // none standard with simulator int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModelSet); QString o = "Model set " + ui->comp_OwnModelSet->getModelSetSimulator().toQString(true); const QString f = ui->comp_OwnModelSet->view()->hasFilter() ? "F" : ""; diff --git a/src/blackgui/components/dbmappingcomponent.h b/src/blackgui/components/dbmappingcomponent.h index 4a0331e91..080ccdef0 100644 --- a/src/blackgui/components/dbmappingcomponent.h +++ b/src/blackgui/components/dbmappingcomponent.h @@ -72,15 +72,16 @@ namespace BlackGui public: //! Tab index. - //! Must match real tab index + //! \remark Must match real tab index enum TabIndex { NoValidTab = -1, TabOwnModelSet = 0, TabOwnModels = 1, - TabStash = 2, - TabModelMatcher = 3, - TabVPilot = 4 + TabWorkbench = 2, + TabStash = 3, + TabModelMatcher = 4, + TabVPilot = 5 }; //! Constructor @@ -113,6 +114,9 @@ namespace BlackGui //! Current model view Views::CAircraftModelView *currentModelView() const; + //! Current model view + Views::CAircraftModelView *modelView(TabIndex tab) const; + //! Unvalidated consolidated aircraft model from the editor subparts (icao, distributor) //! \note not guaranteed to be valid, just a snapshot of its current editor state BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const; @@ -247,6 +251,9 @@ namespace BlackGui //! vPilot data changed void onVPilotDataChanged(int count, bool withFilter); + //! Workbench data changed + void onWorkbenchDataChanged(int count, bool withFilter); + //! Tab index changed void onTabIndexChanged(int index); diff --git a/src/blackgui/components/dbmappingcomponent.ui b/src/blackgui/components/dbmappingcomponent.ui index 9b4d4382c..18530691f 100644 --- a/src/blackgui/components/dbmappingcomponent.ui +++ b/src/blackgui/components/dbmappingcomponent.ui @@ -138,6 +138,38 @@ + + + Workbench + + + + 4 + + + 0 + + + 2 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + Stashed models @@ -287,7 +319,7 @@ 0 0 - 882 + 885 450 @@ -378,6 +410,12 @@
blackgui/components/modelmatchercomponent.h
1 + + BlackGui::Components::CDbModelWorkbenchComponent + QFrame +
blackgui/components/dbmodelworkbenchcomponent.h
+ 1 +