From 71a51bbd6677c1a80336986b8b6d4da779a297b8 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 9 Feb 2018 04:11:58 +0100 Subject: [PATCH] Ref T246, renaming and using renamed dialog in CDbOwnModelSetComponent --- .../components/dbownmodelscomponent.h | 4 +- .../components/dbownmodelsetcomponent.cpp | 83 +++++++++---------- .../components/dbownmodelsetcomponent.h | 17 ++-- 3 files changed, 48 insertions(+), 56 deletions(-) diff --git a/src/blackgui/components/dbownmodelscomponent.h b/src/blackgui/components/dbownmodelscomponent.h index 12f8b7647..f04fd8c0e 100644 --- a/src/blackgui/components/dbownmodelscomponent.h +++ b/src/blackgui/components/dbownmodelscomponent.h @@ -35,9 +35,9 @@ class QWidget; namespace Ui { class CDbOwnModelsComponent; } namespace BlackGui { - namespace Menus { class CMenuActions; } + namespace Menus { class CMenuActions; } namespace Models { class CAircraftModelListModel; } - namespace Views { class CAircraftModelView; } + namespace Views { class CAircraftModelView; } namespace Components { /*! diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index 8e979e970..413817e5d 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -10,7 +10,7 @@ #include "blackgui/guiapplication.h" #include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbownmodelsetcomponent.h" -#include "blackgui/components/dbownmodelsetdialog.h" +#include "blackgui/components/dbownmodelsetformdialog.h" #include "blackgui/menus/aircraftmodelmenus.h" #include "blackgui/menus/menuaction.h" #include "blackgui/models/aircraftmodellistmodel.h" @@ -77,12 +77,12 @@ namespace BlackGui connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); connect(ui->pb_ShowMatrix, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged); - connect(&this->m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged); + connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged); connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged); connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::ps_viewModelChanged); connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::ps_onJsonDataLoaded); - const CSimulatorInfo simulator = this->m_modelSetLoader.getSimulator(); + const CSimulatorInfo simulator = m_modelSetLoader.getSimulator(); if (simulator.isSingleSimulator()) { ui->comp_SimulatorSelector->setValue(simulator); @@ -149,7 +149,7 @@ namespace BlackGui const CSimulatorInfo CDbOwnModelSetComponent::getModelSetSimulator() const { - return this->m_modelSetLoader.getSimulator(); + return m_modelSetLoader.getSimulator(); } CStatusMessage CDbOwnModelSetComponent::addToModelSet(const CAircraftModel &model, const CSimulatorInfo &simulator) @@ -173,7 +173,7 @@ namespace BlackGui "Cannot add data for " + simulator.toQString(true) + " to " + this->getModelSetSimulator().toQString(true), true); } - const bool allowExcludedModels = this->m_modelSettings.get().getAllowExcludedModels(); + const bool allowExcludedModels = m_modelSettings.get().getAllowExcludedModels(); CAircraftModelList updateModels(this->getModelSet()); int d = updateModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive); if (d > 0) @@ -219,7 +219,7 @@ namespace BlackGui const CAircraftModelList ml(ui->tvp_OwnModelSet->container()); if (!ml.isEmpty()) { - const CStatusMessage m = this->m_modelSetLoader.setCachedModels(ml); + const CStatusMessage m = m_modelSetLoader.setCachedModels(ml); CLogMessage::preformatted(m); } } @@ -249,8 +249,8 @@ namespace BlackGui { Q_UNUSED(count); Q_UNUSED(withFilter); - int realUnfilteredCount = ui->tvp_OwnModelSet->container().size(); - bool canSave = this->getModelSetSimulator().isSingleSimulator() && (realUnfilteredCount > 0); + const int realUnfilteredCount = ui->tvp_OwnModelSet->container().size(); + const bool canSave = this->getModelSetSimulator().isSingleSimulator() && (realUnfilteredCount > 0); ui->pb_SaveAsSetForSimulator->setEnabled(canSave); if (canSave) { @@ -271,9 +271,9 @@ namespace BlackGui } } - void CDbOwnModelSetComponent::ps_distributorPreferencesChanged() + void CDbOwnModelSetComponent::distributorPreferencesChanged() { - const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal(); + const CDistributorListPreferences preferences = m_distributorPreferences.getThreadLocal(); const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator(); if (simuulator.isSingleSimulator()) { @@ -281,11 +281,6 @@ namespace BlackGui } } - void CDbOwnModelSetComponent::ps_modelSettingsChanged() - { - // void - } - void CDbOwnModelSetComponent::ps_viewModelChanged() { ui->pb_SaveAsSetForSimulator->setEnabled(true); @@ -300,7 +295,7 @@ namespace BlackGui void CDbOwnModelSetComponent::updateViewToCurrentModels() { - const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels()); + const CAircraftModelList models(m_modelSetLoader.getAircraftModels()); ui->tvp_OwnModelSet->updateContainerMaybeAsync(models); } @@ -308,27 +303,27 @@ namespace BlackGui { // make sure both tabs display the same simulator Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component"); - const CSimulatorInfo sim(this->getModelSetSimulator()); - this->getMappingComponent()->setOwnModelsSimulator(sim); - if (!this->m_modelSetDialog) + const CSimulatorInfo simulator(this->getModelSetSimulator()); + this->getMappingComponent()->setOwnModelsSimulator(simulator); + if (!m_modelSetFormDialog) { - this->m_modelSetDialog.reset(new CDbOwnModelSetDialog(this)); - this->m_modelSetDialog->setMappingComponent(this->getMappingComponent()); + m_modelSetFormDialog.reset(new CDbOwnModelSetFormDialog(this)); + m_modelSetFormDialog->setMappingComponent(this->getMappingComponent()); } if (this->getMappingComponent()->getOwnModelsCount() > 0) { - this->m_modelSetDialog->setModal(true); - this->m_modelSetDialog->reloadData(); - QDialog::DialogCode rc = static_cast(this->m_modelSetDialog->exec()); + m_modelSetFormDialog->setModal(true); + m_modelSetFormDialog->reloadData(); + const QDialog::DialogCode rc = static_cast(m_modelSetFormDialog->exec()); if (rc == QDialog::Accepted) { - this->setModelSet(this->m_modelSetDialog->getModelSet(), this->m_modelSetDialog->getSimulatorInfo()); + this->setModelSet(m_modelSetFormDialog->getModelSet(), m_modelSetFormDialog->getSimulatorInfo()); } } else { - static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << sim.toQString(true); + static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << simulator.toQString(true); this->getMappingComponent()->showOverlayMessage(m); } } @@ -343,8 +338,8 @@ namespace BlackGui void CDbOwnModelSetComponent::setModelSetSimulator(const CSimulatorInfo &simulator) { - if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals - this->m_modelSetLoader.changeSimulator(simulator); + if (m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals + m_modelSetLoader.changeSimulator(simulator); ui->tvp_OwnModelSet->setSimulatorForLoading(simulator); ui->le_Simulator->setText(simulator.toQString(true)); ui->comp_SimulatorSelector->setValue(simulator); @@ -352,13 +347,13 @@ namespace BlackGui void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator) { - CAircraftModelList modelSet = this->m_modelSetLoader.getAircraftModels(simulator); + CAircraftModelList modelSet = m_modelSetLoader.getAircraftModels(simulator); if (modelSet.isEmpty()) { return; } - const CDistributorListPreferences preferences = this->m_distributorPreferences.getThreadLocal(); + const CDistributorListPreferences preferences = m_distributorPreferences.getThreadLocal(); const CDistributorList distributors = preferences.getDistributors(simulator); if (distributors.isEmpty()) { return; } modelSet.updateDistributorOrder(distributors); - this->m_modelSetLoader.setModels(modelSet, simulator); + m_modelSetLoader.setModels(modelSet, simulator); // display? const CSimulatorInfo currentSimulator(this->getModelSetSimulator()); @@ -377,7 +372,7 @@ namespace BlackGui { CDbOwnModelSetComponent *ownModelSetComp = qobject_cast(this->parent()); Q_ASSERT_X(ownModelSetComp, Q_FUNC_INFO, "Cannot access parent"); - if (this->m_setActions.isEmpty()) + if (m_setActions.isEmpty()) { if (sims.fsx()) { @@ -387,7 +382,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FSX)); }); - this->m_setActions.append(a); + m_setActions.append(a); a = new QAction(CIcons::appModels16(), "New set FSX models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) @@ -395,7 +390,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FSX)); }); - this->m_setNewActions.append(a); + m_setNewActions.append(a); } if (sims.p3d()) { @@ -405,7 +400,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::P3D)); }); - this->m_setActions.append(a); + m_setActions.append(a); a = new QAction(CIcons::appModels16(), "New set P3D models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) @@ -413,7 +408,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::P3D)); }); - this->m_setNewActions.append(a); + m_setNewActions.append(a); } if (sims.fs9()) { @@ -423,7 +418,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::FS9)); }); - this->m_setActions.append(a); + m_setActions.append(a); a = new QAction(CIcons::appModels16(), "New set FS9 models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) @@ -431,7 +426,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::FS9)); }); - this->m_setNewActions.append(a); + m_setNewActions.append(a); } if (sims.xplane()) { @@ -441,7 +436,7 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->ps_changeSimulator(CSimulatorInfo(CSimulatorInfo::XPLANE)); }); - this->m_setActions.append(a); + m_setActions.append(a); a = new QAction(CIcons::appModels16(), "New set XPlane models", this); connect(a, &QAction::triggered, ownModelSetComp, [ownModelSetComp](bool checked) @@ -449,16 +444,16 @@ namespace BlackGui Q_UNUSED(checked); ownModelSetComp->setModelSet(CAircraftModelList(), CSimulatorInfo(CSimulatorInfo::XPLANE)); }); - this->m_setNewActions.append(a); + m_setNewActions.append(a); } QAction *a = new QAction(CIcons::appDistributors16(), "Apply distributor preferences", this); - connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::ps_distributorPreferencesChanged); - this->m_setActions.append(a); + connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::distributorPreferencesChanged); + m_setActions.append(a); } menuActions.addMenuModelSet(); - menuActions.addActions(this->m_setActions, CMenuAction::pathModelSet()); - menuActions.addActions(this->m_setNewActions, CMenuAction::pathModelSetNew()); + menuActions.addActions(m_setActions, CMenuAction::pathModelSet()); + menuActions.addActions(m_setNewActions, CMenuAction::pathModelSetNew()); } this->nestedCustomMenu(menuActions); } diff --git a/src/blackgui/components/dbownmodelsetcomponent.h b/src/blackgui/components/dbownmodelsetcomponent.h index 1e7526e23..8d0bb8d51 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.h +++ b/src/blackgui/components/dbownmodelsetcomponent.h @@ -38,7 +38,7 @@ namespace BlackGui namespace Components { class CDbMappingComponent; - class CDbOwnModelSetDialog; + class CDbOwnModelSetFormDialog; /*! * Handling of the own model set @@ -123,16 +123,13 @@ namespace BlackGui //! JSON data have been loaded from disk void ps_onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator); - //! Preferences changed - void ps_distributorPreferencesChanged(); - - //! Model settings changed - void ps_modelSettingsChanged(); - //! Model (of view) has been changed void ps_viewModelChanged(); private: + //! Preferences changed + void distributorPreferencesChanged(); + //! Default file name void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim); @@ -149,10 +146,10 @@ namespace BlackGui void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator); QScopedPointer ui; - QScopedPointer m_modelSetDialog; + QScopedPointer m_modelSetFormDialog; BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; - BlackMisc::CSettingReadOnly m_distributorPreferences { this, &CDbOwnModelSetComponent::ps_distributorPreferencesChanged }; //!< distributor preferences - BlackMisc::CSettingReadOnly m_modelSettings { this, &CDbOwnModelSetComponent::ps_modelSettingsChanged }; //!< settings for models + BlackMisc::CSettingReadOnly m_distributorPreferences { this, &CDbOwnModelSetComponent::distributorPreferencesChanged }; //!< distributor preferences + BlackMisc::CSettingReadOnly m_modelSettings { this }; //!< settings for models // -------------------------- custom menus -----------------------------------