From 2e307555a20f2fbc0e3b2781ef2264853d8bfc0d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 28 Oct 2017 16:41:23 +0200 Subject: [PATCH] Ref T177, clear highlighting once new models are stashed --- src/blackgui/components/dbstashcomponent.cpp | 25 ++++++++++++++++---- src/blackgui/components/dbstashcomponent.h | 7 ++++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/blackgui/components/dbstashcomponent.cpp b/src/blackgui/components/dbstashcomponent.cpp index 890e1b777..87f3335ef 100644 --- a/src/blackgui/components/dbstashcomponent.cpp +++ b/src/blackgui/components/dbstashcomponent.cpp @@ -97,12 +97,13 @@ namespace BlackGui return CStatusMessage(); } - CStatusMessage CDbStashComponent::stashModel(const CAircraftModel &model, bool replace, bool consolidateWithDbData) + CStatusMessage CDbStashComponent::stashModel(const CAircraftModel &model, bool replace, bool consolidateWithDbData, bool clearHighlighting) { const CAircraftModel stashModel(consolidateWithDbData ? this->consolidateModel(model) : model); - const CStatusMessage m(validateStashModel(stashModel, replace)); + const CStatusMessage m(this->validateStashModel(stashModel, replace)); if (!m.isWarningOrAbove()) { + if (clearHighlighting) { this->clearValidationHighlighting(); } if (replace) { ui->tvp_StashAircraftModels->replaceOrAdd(&CAircraftModel::getModelString, stashModel.getModelString(), stashModel); @@ -115,15 +116,24 @@ namespace BlackGui return m; } - CStatusMessageList CDbStashComponent::stashModels(const CAircraftModelList &models) + CStatusMessageList CDbStashComponent::stashModels(const CAircraftModelList &models, bool replace, bool consolidateWithDbData, bool clearHighlighting) { if (models.isEmpty()) { return CStatusMessageList(); } CStatusMessageList msgs; + int successfullyAdded = 0; for (const CAircraftModel &model : models) { - const CStatusMessage m(stashModel(model)); - if (m.isWarningOrAbove()) { msgs.push_back(m); } + const CStatusMessage m(this->stashModel(model, replace, consolidateWithDbData, false)); + if (m.isWarningOrAbove()) + { + msgs.push_back(m); + } + else + { + successfullyAdded++; + } } + if (successfullyAdded > 0 && clearHighlighting) { this->clearValidationHighlighting(); } return msgs; } @@ -448,6 +458,11 @@ namespace BlackGui this->showOverlayMessages(msgs); } + void CDbStashComponent::clearValidationHighlighting() + { + ui->tvp_StashAircraftModels->clearHighlighting(); + } + void CDbStashComponent::ps_copyOverValuesToSelectedModels() { const QObject *sender = QObject::sender(); diff --git a/src/blackgui/components/dbstashcomponent.h b/src/blackgui/components/dbstashcomponent.h index 4843b0de7..9e15348b4 100644 --- a/src/blackgui/components/dbstashcomponent.h +++ b/src/blackgui/components/dbstashcomponent.h @@ -121,12 +121,15 @@ namespace BlackGui //! Show changed attributes of selected models void showChangedAttributes(); + //! Clear highlighting set by validations + void clearValidationHighlighting(); + public slots: //! Stash given model (includes validation and consolidation with DB data) - BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false, bool consolidateWithDbData = true); + BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false, bool consolidateWithDbData = true, bool clearHighlighting = true); //! Stash given models (includes validation and consolidation with DB data) - BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models); + BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models, bool replace = false, bool consolidateWithDbData = true, bool clearHighlighting = true); //! Replace models, no validation void replaceModelsUnvalidated(const BlackMisc::Simulation::CAircraftModelList &models);