Ref T515, model validation dialog/component

This commit is contained in:
Klaus Basan
2019-01-22 21:35:52 +01:00
committed by Mat Sutcliffe
parent faddf40ba7
commit 7ef7fb3449
6 changed files with 451 additions and 0 deletions

View File

@@ -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

View File

@@ -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 <QDialog>
#include <QScopedPointer>
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::CAircraftModelSetValidationDialog> ui;
};
} // ms
} // ns
#endif // guard

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAircraftModelSetValidationDialog</class>
<widget class="QDialog" name="CAircraftModelSetValidationDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Model validation</string>
</property>
<layout class="QVBoxLayout" name="vl_AircraaftModelValidation">
<item>
<widget class="BlackGui::Components::CAircraftModelValidationComponent" name="comp_AircraftModelValidation">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="bb_CAircraftModelSetValidationDialog">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CAircraftModelValidationComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/aircraftmodelvalidationcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>bb_CAircraftModelSetValidationDialog</sender>
<signal>accepted()</signal>
<receiver>CAircraftModelSetValidationDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>bb_CAircraftModelSetValidationDialog</sender>
<signal>rejected()</signal>
<receiver>CAircraftModelSetValidationDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
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::CAircraftModelValidationComponent> ui;
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModelMatching> 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

View File

@@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAircraftModelValidationComponent</class>
<widget class="QFrame" name="CAircraftModelValidationComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Model validation</string>
</property>
<layout class="QVBoxLayout" name="vl_AircraftModelValidation" stretch="0,1,0">
<item>
<widget class="QLabel" name="lbl_Summay">
<property name="text">
<string>Summary will go here</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tw_CAircraftModelValidationComponent">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tb_InvalidModels">
<attribute name="title">
<string>Invalid models</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_InvalidModels">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Messages">
<attribute name="title">
<string>Messages</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="BlackGui::Components::CLogComponent" name="comp_Messages">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QWidget" name="wi_Buttons" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="cb_EnableStartupCheck">
<property name="text">
<string>check at startup</string>
</property>
</widget>
</item>
<item>
<spacer name="hs_Buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_TempDisableInvalid">
<property name="text">
<string>temp.disable invalid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_TempDisableSelected">
<property name="text">
<string>temp.disable selected</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CAircraftModelView</class>
<extends>QTableView</extends>
<header>blackgui/views/aircraftmodelview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Components::CLogComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/logcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>