From 9bd2d294a3b7ffef0ebd4f64a0fc5140297cdcef Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 6 Sep 2019 19:20:11 +0200 Subject: [PATCH] Validation dialog allows to directly removed from model set There is some moderate riks involved here, as this allows to change the model set in the client, but many users have asked for this --- .../aircraftmodelvalidationcomponent.cpp | 61 ++++-- .../aircraftmodelvalidationcomponent.h | 5 +- .../aircraftmodelvalidationcomponent.ui | 194 ++++++++++++------ 3 files changed, 179 insertions(+), 81 deletions(-) diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.cpp b/src/blackgui/components/aircraftmodelvalidationcomponent.cpp index 38df054b2..ca6434ae6 100644 --- a/src/blackgui/components/aircraftmodelvalidationcomponent.cpp +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.cpp @@ -6,8 +6,8 @@ * or distributed except according to the terms contained in the LICENSE file. */ -#include "aircraftmodelvalidationcomponent.h" #include "ui_aircraftmodelvalidationcomponent.h" +#include "aircraftmodelvalidationcomponent.h" #include "blackgui/guiapplication.h" #include "blackcore/context/contextsimulator.h" @@ -38,10 +38,13 @@ namespace BlackGui connect(ui->cb_EnableStartupCheck, &QCheckBox::toggled, this, &CAircraftModelValidationComponent::onCheckAtStartupChanged); connect(ui->cb_OnlyIfErrorsOrWarnings, &QCheckBox::toggled, this, &CAircraftModelValidationComponent::onOnlyErrorWarningChanged); - connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked); - connect(ui->pb_TempDisableSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked); - connect(ui->pb_TriggerValidation, &QPushButton::released, this, &CAircraftModelValidationComponent::triggerValidation); - connect(ui->pb_help, &QPushButton::released, this, &CAircraftModelValidationComponent::showHelp); + connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onTempDisabledButtonClicked, Qt::QueuedConnection); + connect(ui->pb_TempDisableSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onTempDisabledButtonClicked, Qt::QueuedConnection); + connect(ui->pb_RemoveInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onRemoveButtonClicked, Qt::QueuedConnection); + connect(ui->pb_RemoveSelected, &QPushButton::released, this, &CAircraftModelValidationComponent::onRemoveButtonClicked, Qt::QueuedConnection); + + connect(ui->pb_TriggerValidation, &QPushButton::released, this, &CAircraftModelValidationComponent::triggerValidation, Qt::QueuedConnection); + connect(ui->pb_Help, &QPushButton::released, this, &CAircraftModelValidationComponent::showHelp, Qt::QueuedConnection); // 1st init when running in distributed environment QPointer myself(this); @@ -85,6 +88,8 @@ namespace BlackGui ui->cb_EnableStartupCheck->setChecked(setup.doVerificationAtStartup()); ui->pb_TempDisableInvalid->setEnabled(!invalid.isEmpty()); ui->pb_TempDisableSelected->setEnabled(!invalid.isEmpty()); + ui->pb_RemoveInvalid->setEnabled(!invalid.isEmpty()); + ui->pb_RemoveSelected->setEnabled(!invalid.isEmpty()); const QString msg = stopped ? QStringLiteral("Validation for '%1' stopped, maybe your models are not accessible or too many issues").arg(simulator.toQString(true)) : @@ -164,22 +169,50 @@ namespace BlackGui sGui->getIContextSimulator()->triggerModelSetValidation(CSimulatorInfo()); } - void CAircraftModelValidationComponent::onButtonClicked() + void CAircraftModelValidationComponent::onTempDisabledButtonClicked() { + if (!sGui || sGui->isShuttingDown()) { return; } + + CAircraftModelList disableModels; const QObject *sender = QObject::sender(); - CAircraftModelList disabledModels; - if (sender == ui->pb_TempDisableInvalid) { disabledModels = ui->tvp_InvalidModels->container(); } - else if (sender == ui->pb_TempDisableSelected) { disabledModels = ui->tvp_InvalidModels->selectedObjects(); } + if (sender == ui->pb_TempDisableInvalid) { disableModels = ui->tvp_InvalidModels->container(); } + else if (sender == ui->pb_TempDisableSelected) { disableModels = ui->tvp_InvalidModels->selectedObjects(); } - this->tempDisableModels(disabledModels); - - if (disabledModels.isEmpty()) + if (disableModels.isEmpty()) { - this->showOverlayHTMLMessage("No models disabled"); + this->showOverlayHTMLMessage("No models disabled", 4000); } else { - this->showOverlayHTMLMessage(QStringLiteral("%1 models disabled").arg(disabledModels.size())); + this->tempDisableModels(disableModels); + this->showOverlayHTMLMessage(QStringLiteral("%1 models disabled").arg(disableModels.size())); + } + } + + void CAircraftModelValidationComponent::onRemoveButtonClicked() + { + if (!sGui || sGui->isShuttingDown()) { return; } + if (!sGui->getIContextSimulator()) { return; } + + CAircraftModelList removeModels; + const QObject *sender = QObject::sender(); + if (sender == ui->pb_RemoveInvalid) { removeModels = ui->tvp_InvalidModels->container(); } + else if (sender == ui->pb_RemoveSelected) { removeModels = ui->tvp_InvalidModels->selectedObjects(); } + + if (removeModels.isEmpty()) + { + this->showOverlayHTMLMessage("No models removed", 4000); + } + else + { + const QMessageBox::StandardButton ret = QMessageBox::question(this, + tr("Model validation"), + tr("Do you really want to delete %1 models from model set?").arg(removeModels.sizeInt()), + QMessageBox::Ok | QMessageBox::Cancel); + if (ret != QMessageBox::Ok) { return; } + + const int r = sGui->getIContextSimulator()->removeModelsFromSet(removeModels); + this->showOverlayHTMLMessage(QStringLiteral("%1 models removed").arg(r)); } } diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.h b/src/blackgui/components/aircraftmodelvalidationcomponent.h index 4be3bbe09..f522634f9 100644 --- a/src/blackgui/components/aircraftmodelvalidationcomponent.h +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.h @@ -72,7 +72,10 @@ namespace BlackGui void requestLastResults(); //! Button has been clicked - void onButtonClicked(); + void onTempDisabledButtonClicked(); + + //! Remove from model set + void onRemoveButtonClicked(); //! Show help void showHelp(); diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.ui b/src/blackgui/components/aircraftmodelvalidationcomponent.ui index 41aa926f6..f825abfd4 100644 --- a/src/blackgui/components/aircraftmodelvalidationcomponent.ui +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.ui @@ -13,7 +13,7 @@ Model validation - + @@ -26,6 +26,9 @@ + + 0 + Invalid models @@ -41,6 +44,127 @@ + + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + + 75 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + remove invalid + + + + + + + trigger validation + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + check at startup + + + + + + + only if errors/warnings + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + remove selected + + + + + + + temp.disable invalid + + + + + + + temp.disable selected + + + + + + + help + + + + + + @@ -62,70 +186,6 @@ - - - - - - - temp.disable selected - - - - - - - - 75 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - trigger validation - - - - - - - temp.disable invalid - - - - - - - help - - - - - - - check at startup - - - - - - - only if errors/warnings - - - - - - @@ -150,12 +210,14 @@ tw_CAircraftModelValidationComponent tvp_InvalidModels - pb_help + pb_Help pb_TriggerValidation pb_TempDisableInvalid pb_TempDisableSelected cb_EnableStartupCheck cb_OnlyIfErrorsOrWarnings + pb_RemoveInvalid + pb_RemoveSelected