From e7e82c3ab1d6ee0366a428d876b93432dc37056d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 25 Nov 2018 18:23:01 +0100 Subject: [PATCH] Style, minor fixes --- src/blackcore/db/databaseutils.cpp | 3 +- .../dbautosimulatorstashingcomponent.cpp | 28 +-- .../dbautosimulatorstashingcomponent.h | 4 +- .../dbautosimulatorstashingcomponent.ui | 166 +++++++++++------- .../dbdistributorselectorcomponent.h | 2 +- 5 files changed, 121 insertions(+), 82 deletions(-) diff --git a/src/blackcore/db/databaseutils.cpp b/src/blackcore/db/databaseutils.cpp index 6233eadb4..9c833b293 100644 --- a/src/blackcore/db/databaseutils.cpp +++ b/src/blackcore/db/databaseutils.cpp @@ -294,6 +294,7 @@ namespace BlackCore CAircraftModelList CDatabaseUtils::updateSimulatorForFsFamily(const CAircraftModelList &ownModels, int maxToStash, IProgressIndicator *progressIndicator, bool processEvents) { + if (!sApp || !sApp->getWebDataServices()) { return CAircraftModelList(); } CAircraftModelList dbFsFamilyModels(sApp->getWebDataServices()->getModels().getAllFsFamilyModels()); CAircraftModelList stashModels; if (dbFsFamilyModels.isEmpty() || ownModels.isEmpty()) { return stashModels; } @@ -328,7 +329,7 @@ namespace BlackCore // in DB CAircraftModel dbModel = dbFsFamilyModels.findFirstByModelStringOrDefault(ownModel.getModelString()); if (!dbModel.isLoadedFromDb()) {continue; } - if (dbModel.getSimulator() == ownModel.getSimulator()) {continue; } + if (dbModel.getSimulator() == ownModel.getSimulator()) { continue; } // update simulator and add CSimulatorInfo simulator(dbModel.getSimulator()); diff --git a/src/blackgui/components/dbautosimulatorstashingcomponent.cpp b/src/blackgui/components/dbautosimulatorstashingcomponent.cpp index 48d5639ce..f73ee6387 100644 --- a/src/blackgui/components/dbautosimulatorstashingcomponent.cpp +++ b/src/blackgui/components/dbautosimulatorstashingcomponent.cpp @@ -41,18 +41,18 @@ namespace BlackGui void CDbAutoSimulatorStashingComponent::accept() { - switch (this->m_state) + switch (m_state) { case Running: return; case Completed: { - if (!this->m_modelsToStash.isEmpty()) + if (!m_modelsToStash.isEmpty()) { // this removes previously stashed models - this->getMappingComponent()->replaceStashedModelsUnvalidated(this->m_modelsToStash); - const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Stashed %1 models").arg(this->m_modelsToStash.size())); + this->getMappingComponent()->replaceStashedModelsUnvalidated(m_modelsToStash); + const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Stashed %1 models").arg(m_modelsToStash.size())); this->addStatusMessage(stashedMsg); - this->m_modelsToStash.clear(); + m_modelsToStash.clear(); } QDialog::accept(); break; @@ -84,7 +84,7 @@ namespace BlackGui { ui->bb_OkCancel->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); ui->tvp_StatusMessages->clear(); - this->m_state = Idle; + m_state = Idle; this->updateProgressIndicator(0); const QString infoAll = this->getMappingComponent()->getOwnModelsInfoStringFsFamily(); @@ -128,7 +128,7 @@ namespace BlackGui Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component"); if (!this->currentModelView()) { return; } - this->m_state = Running; + m_state = Running; int maxObjectsStashed = -1; if (!ui->le_MaxModelsStashed->text().isEmpty()) { @@ -141,29 +141,31 @@ namespace BlackGui int ownModelsCount = 0; if (selected) { - const QString intro("Checking %1 selected models"); + static const QString intro("Checking %1 selected models"); const CAircraftModelList selectedModels(this->currentModelView()->selectedObjects()); ownModelsCount = selectedModels.size(); this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityInfo, intro.arg(ownModelsCount))); - this->m_modelsToStash = CDatabaseUtils::updateSimulatorForFsFamily(selectedModels, maxObjectsStashed, this, true); + m_modelsToStash = CDatabaseUtils::updateSimulatorForFsFamily(selectedModels, maxObjectsStashed, this, true); } else { const CDbMappingComponent *mappincComponent = this->getMappingComponent(); const QSet fsFamilySims(CSimulatorInfo::allFsFamilySimulators().asSingleSimulatorSet()); - const QString intro("Checking %1 models for %2"); + static const QString intro("Checking %1 models for %2"); + + // check all own models for (const CSimulatorInfo &simulator : fsFamilySims) { const CAircraftModelList ownModels = mappincComponent->getOwnCachedModels(simulator); const QString sim = simulator.toQString(); ownModelsCount += ownModels.size(); this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityInfo, intro.arg(ownModels.size()).arg(sim))); - this->m_modelsToStash.push_back(CDatabaseUtils::updateSimulatorForFsFamily(ownModels, maxObjectsStashed, this, true)); + m_modelsToStash.push_back(CDatabaseUtils::updateSimulatorForFsFamily(ownModels, maxObjectsStashed, this, true)); } } const QString result("Tested %1 own models, %2 models should be updated in DB"); - this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityInfo, result.arg(ownModelsCount).arg(this->m_modelsToStash.size()))); - this->m_state = Completed; + this->addStatusMessage(CStatusMessage(this, CStatusMessage::SeverityInfo, result.arg(ownModelsCount).arg(m_modelsToStash.size()))); + m_state = Completed; } } // ns } // ns diff --git a/src/blackgui/components/dbautosimulatorstashingcomponent.h b/src/blackgui/components/dbautosimulatorstashingcomponent.h index aed530a8a..e8e479de8 100644 --- a/src/blackgui/components/dbautosimulatorstashingcomponent.h +++ b/src/blackgui/components/dbautosimulatorstashingcomponent.h @@ -27,12 +27,12 @@ namespace BlackGui namespace Components { /** - * Allows to automatically updated models if found in own model set, but already existing + * Allows to automatically update models if found in own model set, but already existing * for a sibling simulator (ie. FSX/P3D/FS9) */ class BLACKGUI_EXPORT CDbAutoSimulatorStashingComponent : public QDialog, - public BlackGui::Components::CDbMappingComponentAware, + public Components::CDbMappingComponentAware, public BlackCore::IProgressIndicator { Q_OBJECT diff --git a/src/blackgui/components/dbautosimulatorstashingcomponent.ui b/src/blackgui/components/dbautosimulatorstashingcomponent.ui index f01dbeab8..9082be05a 100644 --- a/src/blackgui/components/dbautosimulatorstashingcomponent.ui +++ b/src/blackgui/components/dbautosimulatorstashingcomponent.ui @@ -7,7 +7,7 @@ 0 0 600 - 400 + 402 @@ -19,42 +19,104 @@ Cross simulator updating (FSX-P3D-FS9) - - + + + + + Info + + + + + + This tool checks the DB models simulator info against your local simulator info. For instance, if a model is locally found in P3D, the DB should also reflect that fact.You can easily update the sibling simulators by running the tool here. It will automatically stash the changes for you. + + + true + + + + + + + + + + Update models + + + + + + true + + + + + + + scan all models + + + true + + + bg_ScanAllOrSelected + + + + + + + true + + + + + + + Max.stashed: + + + + + + + selected + + + bg_ScanAllOrSelected + + + + + + + max.models to be stashed + + + + + + + QAbstractItemView::NoSelection + + + false + + + + + + + 24 - - - - QAbstractItemView::NoSelection - - - false - - - - - - - true - - - - - - - selected - - - bg_ScanAllOrSelected - - - - + Qt::Horizontal @@ -64,40 +126,6 @@ - - - - scan all models - - - true - - - bg_ScanAllOrSelected - - - - - - - true - - - - - - - Max.stashed: - - - - - - - max.models to be stashed - - - @@ -107,6 +135,14 @@
blackgui/views/statusmessageview.h
+ + rb_SelectedOnly + le_Selected + rb_ScanAllModels + le_AllSets + tvp_StatusMessages + le_MaxModelsStashed + diff --git a/src/blackgui/components/dbdistributorselectorcomponent.h b/src/blackgui/components/dbdistributorselectorcomponent.h index 641bbb888..e9d525306 100644 --- a/src/blackgui/components/dbdistributorselectorcomponent.h +++ b/src/blackgui/components/dbdistributorselectorcomponent.h @@ -40,7 +40,7 @@ namespace BlackGui */ class BLACKGUI_EXPORT CDbDistributorSelectorComponent : public QFrame, - public BlackGui::CDropBase + public CDropBase { Q_OBJECT