From 7ef7fb34491b0ca5ce059df0d886b8d001164c63 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 22 Jan 2019 21:35:52 +0100 Subject: [PATCH] Ref T515, model validation dialog/component --- .../aircraftmodelsetvalidationdialog.cpp | 38 ++++++ .../aircraftmodelsetvalidationdialog.h | 57 ++++++++ .../aircraftmodelsetvalidationdialog.ui | 82 ++++++++++++ .../aircraftmodelvalidationcomponent.cpp | 79 +++++++++++ .../aircraftmodelvalidationcomponent.h | 70 ++++++++++ .../aircraftmodelvalidationcomponent.ui | 125 ++++++++++++++++++ 6 files changed, 451 insertions(+) create mode 100644 src/blackgui/components/aircraftmodelsetvalidationdialog.cpp create mode 100644 src/blackgui/components/aircraftmodelsetvalidationdialog.h create mode 100644 src/blackgui/components/aircraftmodelsetvalidationdialog.ui create mode 100644 src/blackgui/components/aircraftmodelvalidationcomponent.cpp create mode 100644 src/blackgui/components/aircraftmodelvalidationcomponent.h create mode 100644 src/blackgui/components/aircraftmodelvalidationcomponent.ui diff --git a/src/blackgui/components/aircraftmodelsetvalidationdialog.cpp b/src/blackgui/components/aircraftmodelsetvalidationdialog.cpp new file mode 100644 index 000000000..bf67c9319 --- /dev/null +++ b/src/blackgui/components/aircraftmodelsetvalidationdialog.cpp @@ -0,0 +1,38 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "aircraftmodelsetvalidationdialog.h" +#include "blackmisc/simulation/simulatorinfo.h" +#include "ui_aircraftmodelsetvalidationdialog.h" + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Components + { + CAircraftModelSetValidationDialog::CAircraftModelSetValidationDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CAircraftModelSetValidationDialog) + { + ui->setupUi(this); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); + } + + CAircraftModelSetValidationDialog::~CAircraftModelSetValidationDialog() + { } + + void CAircraftModelSetValidationDialog::validatedModelSet(const CSimulatorInfo &simulator, const CAircraftModelList &valid, const CAircraftModelList &invalid, bool stopped, const CStatusMessageList &msgs) + { + ui->comp_AircraftModelValidation->validatedModelSet(simulator, valid, invalid, stopped, msgs); + this->setWindowTitle(QStringLiteral("Model validation for '%1'").arg(simulator.toQString(true))); + } + } // ns +} // ns diff --git a/src/blackgui/components/aircraftmodelsetvalidationdialog.h b/src/blackgui/components/aircraftmodelsetvalidationdialog.h new file mode 100644 index 000000000..4bbc9031c --- /dev/null +++ b/src/blackgui/components/aircraftmodelsetvalidationdialog.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_AIRCRAFTMODELSETVALIDATIONDIALOG_H +#define BLACKGUI_COMPONENTS_AIRCRAFTMODELSETVALIDATIONDIALOG_H + +#include "blackgui/blackguiexport.h" + +#include +#include + +namespace Ui { class CAircraftModelSetValidationDialog; } +namespace BlackMisc +{ + class CStatusMessageList; + namespace Simulation + { + class CSimulatorInfo; + class CAircraftModelList; + } +} +namespace BlackGui +{ + namespace Components + { + /** + * Dialog for CAircraftModelValidationComponent + */ + class BLACKGUI_EXPORT CAircraftModelSetValidationDialog : public QDialog + { + Q_OBJECT + + public: + //! Constructor + explicit CAircraftModelSetValidationDialog(QWidget *parent = nullptr); + + //! Destructor + virtual ~CAircraftModelSetValidationDialog(); + + //! \copydoc CAircraftModelValidationComponent::validatedModelSet + void validatedModelSet(const BlackMisc::Simulation::CSimulatorInfo &simulator, const BlackMisc::Simulation::CAircraftModelList &valid, const BlackMisc::Simulation::CAircraftModelList &invalid, bool stopped, const BlackMisc::CStatusMessageList &msgs); + + private: + QScopedPointer ui; + }; + } // ms +} // ns + +#endif // guard diff --git a/src/blackgui/components/aircraftmodelsetvalidationdialog.ui b/src/blackgui/components/aircraftmodelsetvalidationdialog.ui new file mode 100644 index 000000000..3f9b37964 --- /dev/null +++ b/src/blackgui/components/aircraftmodelsetvalidationdialog.ui @@ -0,0 +1,82 @@ + + + CAircraftModelSetValidationDialog + + + + 0 + 0 + 640 + 480 + + + + Model validation + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + BlackGui::Components::CAircraftModelValidationComponent + QFrame +
blackgui/components/aircraftmodelvalidationcomponent.h
+ 1 +
+
+ + + + bb_CAircraftModelSetValidationDialog + accepted() + CAircraftModelSetValidationDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_CAircraftModelSetValidationDialog + rejected() + CAircraftModelSetValidationDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.cpp b/src/blackgui/components/aircraftmodelvalidationcomponent.cpp new file mode 100644 index 000000000..916d8db73 --- /dev/null +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.cpp @@ -0,0 +1,79 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "aircraftmodelvalidationcomponent.h" +#include "ui_aircraftmodelvalidationcomponent.h" +#include "blackgui/guiapplication.h" +#include "blackcore/context/contextsimulator.h" + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackCore::Context; + +namespace BlackGui +{ + namespace Components + { + CAircraftModelValidationComponent::CAircraftModelValidationComponent(QWidget *parent) : + COverlayMessagesFrame(parent), + ui(new Ui::CAircraftModelValidationComponent) + { + ui->setupUi(this); + connect(ui->cb_EnableStartupCheck, &QCheckBox::toggled, this, &CAircraftModelValidationComponent::onCheckAtStartupChanged); + connect(ui->pb_TempDisableInvalid, &QPushButton::released, this, &CAircraftModelValidationComponent::onButtonClicked); + } + + CAircraftModelValidationComponent::~CAircraftModelValidationComponent() + { } + + void CAircraftModelValidationComponent::validatedModelSet(const CSimulatorInfo &simulator, const CAircraftModelList &valid, const CAircraftModelList &invalid, bool stopped, const CStatusMessageList &msgs) + { + Q_UNUSED(simulator); + Q_UNUSED(valid); + ui->tvp_InvalidModels->updateContainerMaybeAsync(invalid); + ui->comp_Messages->clear(); + ui->comp_Messages->appendStatusMessagesToList(msgs); + + const QString msg = stopped ? + QStringLiteral("Validation for '%1' stopped, maybe your models are not accessible").arg(simulator.toQString(true)) : + QStringLiteral("Validated for '%1'. Valid: %2 Invalid: %3").arg(simulator.toQString(true)).arg(valid.size()).arg(invalid.size()); + ui->lbl_Summay->setText(msg); + if (stopped) { this->showOverlayHTMLMessage(msg, 5000); } + + const CAircraftMatcherSetup setup = m_matchingSettings.get(); + ui->cb_EnableStartupCheck->setChecked(setup.doVerificationAtStartup()); + ui->pb_TempDisableInvalid->setEnabled(!invalid.isEmpty()); + ui->pb_TempDisableSelected->setEnabled(!invalid.isEmpty()); + } + + void CAircraftModelValidationComponent::tempDisableModels(const CAircraftModelList &models) + { + if (models.isEmpty()) { return; } + if (!sGui || sGui->isShuttingDown() || !sGui->supportsContexts()) { return; } + if (!sGui->getIContextSimulator()) { return; } + sGui->getIContextSimulator()->disableModelsForMatching(models, true); + } + + void CAircraftModelValidationComponent::onCheckAtStartupChanged(bool checked) + { + CAircraftMatcherSetup setup = m_matchingSettings.get(); + if (setup.doVerificationAtStartup() == checked) { return; } + setup.setVerificationAtStartup(checked); + CStatusMessage msg = m_matchingSettings.setAndSave(setup); + Q_UNUSED(msg); + } + + void CAircraftModelValidationComponent::onButtonClicked() + { + const QObject *sender = QObject::sender(); + if (sender == ui->pb_TempDisableInvalid) { this->tempDisableModels(ui->tvp_InvalidModels->container()); } + else if (sender == ui->pb_TempDisableSelected) { this->tempDisableModels(ui->tvp_InvalidModels->selectedObjects()); } + } + } // ns +} // ns diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.h b/src/blackgui/components/aircraftmodelvalidationcomponent.h new file mode 100644 index 000000000..0eff68327 --- /dev/null +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.h @@ -0,0 +1,70 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_AIRCRAFTMODELVALIDATIONCOMPONENT_H +#define BLACKGUI_COMPONENTS_AIRCRAFTMODELVALIDATIONCOMPONENT_H + +#include "blackmisc/simulation/settings/modelmatchersettings.h" +#include "blackmisc/settingscache.h" +#include "blackgui/overlaymessagesframe.h" +#include "blackgui/blackguiexport.h" + +#include +#include + +namespace Ui { class CAircraftModelValidationComponent; } +namespace BlackMisc +{ + class CStatusMessageList; + namespace Simulation + { + class CSimulatorInfo; + class CAircraftModelList; + } +} +namespace BlackGui +{ + namespace Components + { + /** + * Handle validation result + * \sa BlackMisc::Views:: + */ + class BLACKGUI_EXPORT CAircraftModelValidationComponent : public COverlayMessagesFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CAircraftModelValidationComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CAircraftModelValidationComponent(); + + //! Validated a model set + void validatedModelSet(const BlackMisc::Simulation::CSimulatorInfo &simulator, const BlackMisc::Simulation::CAircraftModelList &valid, const BlackMisc::Simulation::CAircraftModelList &invalid, bool stopped, const BlackMisc::CStatusMessageList &msgs); + + private: + QScopedPointer ui; + BlackMisc::CSetting m_matchingSettings { this }; //!< settings + + //! Invalid models + void tempDisableModels(const BlackMisc::Simulation::CAircraftModelList &models); + + //! Enable/disable startup check + void onCheckAtStartupChanged(bool checked); + + //! Button has been clicked + void onButtonClicked(); + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/aircraftmodelvalidationcomponent.ui b/src/blackgui/components/aircraftmodelvalidationcomponent.ui new file mode 100644 index 000000000..79a798d22 --- /dev/null +++ b/src/blackgui/components/aircraftmodelvalidationcomponent.ui @@ -0,0 +1,125 @@ + + + CAircraftModelValidationComponent + + + + 0 + 0 + 640 + 480 + + + + Model validation + + + + + + Summary will go here + + + true + + + + + + + 0 + + + + Invalid models + + + + + + QAbstractItemView::SelectRows + + + false + + + + + + + + Messages + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + check at startup + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + temp.disable invalid + + + + + + + temp.disable selected + + + + + + + + + + + BlackGui::Views::CAircraftModelView + QTableView +
blackgui/views/aircraftmodelview.h
+
+ + BlackGui::Components::CLogComponent + QFrame +
blackgui/components/logcomponent.h
+ 1 +
+
+ + +