mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T515, added validation dialog for model view
This commit is contained in:
committed by
Mat Sutcliffe
parent
5c1f6d9029
commit
bb9b5e8e97
59
src/blackgui/views/aircraftmodelvalidationdialog.cpp
Normal file
59
src/blackgui/views/aircraftmodelvalidationdialog.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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 "aircraftmodelvalidationdialog.h"
|
||||
#include "ui_aircraftmodelvalidationdialog.h"
|
||||
#include "blackmisc/simulation/aircraftmodelutils.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftModelValidationDialog::CAircraftModelValidationDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAircraftModelValidationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
QPushButton *validateButton = new QPushButton("Validate", ui->bb_ValidationDialog);
|
||||
ui->bb_ValidationDialog->addButton(validateButton, QDialogButtonBox::ActionRole);
|
||||
connect(validateButton, &QPushButton::released, this, &CAircraftModelValidationDialog::validate);
|
||||
}
|
||||
|
||||
CAircraftModelValidationDialog::~CAircraftModelValidationDialog()
|
||||
{ }
|
||||
|
||||
void CAircraftModelValidationDialog::validate()
|
||||
{
|
||||
ui->comp_StatusMessage->clear();
|
||||
if (m_models.isEmpty()) { return; }
|
||||
|
||||
CAircraftModelList valid;
|
||||
CAircraftModelList invalid;
|
||||
const CCountPerSimulator counts = m_models.countPerSimulator();
|
||||
const double fsFamilyCount = counts.getCountForFsFamilySimulators();
|
||||
const double fsRatio = fsFamilyCount / m_models.size();
|
||||
const bool ignoreEmpty = false;
|
||||
const int maxFailedFiles = 25;
|
||||
const CStatusMessageList msgs = fsRatio > 0.9 ?
|
||||
CFsCommonUtil::validateConfigFiles(m_models, valid, invalid, ignoreEmpty, maxFailedFiles) :
|
||||
m_models.validateFiles(valid, invalid, ignoreEmpty, maxFailedFiles);
|
||||
ui->comp_StatusMessage->clear();
|
||||
ui->comp_StatusMessage->appendStatusMessagesToList(msgs);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
51
src/blackgui/views/aircraftmodelvalidationdialog.h
Normal file
51
src/blackgui/views/aircraftmodelvalidationdialog.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 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_VIEWS_AIRCRAFTMODELVALIDATIONDIALOG_H
|
||||
#define BLACKGUI_VIEWS_AIRCRAFTMODELVALIDATIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
|
||||
namespace Ui { class CAircraftModelValidationDialog; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
/**
|
||||
* Model validation
|
||||
*/
|
||||
class CAircraftModelValidationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftModelValidationDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAircraftModelValidationDialog();
|
||||
|
||||
//! Models
|
||||
void setModels(const BlackMisc::Simulation::CAircraftModelList &models) { m_models = models; }
|
||||
|
||||
private:
|
||||
//! Validate
|
||||
void validate();
|
||||
|
||||
QScopedPointer<Ui::CAircraftModelValidationDialog> ui;
|
||||
BlackMisc::Simulation::CAircraftModelList m_models;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
73
src/blackgui/views/aircraftmodelvalidationdialog.ui
Normal file
73
src/blackgui/views/aircraftmodelvalidationdialog.ui
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAircraftModelValidationDialog</class>
|
||||
<widget class="QDialog" name="CAircraftModelValidationDialog">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Validation dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_ValidationDialog">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CStatusMessagesDetail" name="comp_StatusMessage"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_ValidationDialog">
|
||||
<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::CStatusMessagesDetail</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/statusmessagesdetail.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_ValidationDialog</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CAircraftModelValidationDialog</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_ValidationDialog</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CAircraftModelValidationDialog</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>
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "aircraftmodelview.h"
|
||||
#include "viewbase.h"
|
||||
#include "aircraftmodelstatisticsdialog.h"
|
||||
#include "aircraftmodelvalidationdialog.h"
|
||||
#include "blackgui/filters/aircraftmodelfilterdialog.h"
|
||||
#include "blackgui/menus/menuaction.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
@@ -290,10 +291,11 @@ namespace BlackGui
|
||||
|
||||
void CAircraftModelView::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
// Statistics
|
||||
// Statistics and validation
|
||||
if (!this->isEmpty())
|
||||
{
|
||||
menuActions.addAction(CIcons::appAircraft16(), "Model statistics", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelStatisticsDialog });
|
||||
menuActions.addAction(CIcons::disk16(), "Model validation", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelValidationDialog });
|
||||
}
|
||||
|
||||
// Stash menus
|
||||
@@ -428,13 +430,16 @@ namespace BlackGui
|
||||
|
||||
void CAircraftModelView::displayModelStatisticsDialog()
|
||||
{
|
||||
if (!m_statisticsDialog)
|
||||
{
|
||||
m_statisticsDialog = new CAircraftModelStatisticsDialog(this);
|
||||
}
|
||||
|
||||
if (!m_statisticsDialog) { m_statisticsDialog = new CAircraftModelStatisticsDialog(this); }
|
||||
m_statisticsDialog->analyzeModels(this->container());
|
||||
m_statisticsDialog->exec();
|
||||
}
|
||||
|
||||
void CAircraftModelView::displayModelValidationDialog()
|
||||
{
|
||||
if (!m_fileValidationDialog) { m_fileValidationDialog = new CAircraftModelValidationDialog(this); }
|
||||
m_fileValidationDialog->setModels(this->selectedObjects());
|
||||
m_fileValidationDialog->exec();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -43,10 +43,11 @@ namespace BlackMisc { namespace Simulation { class CAircraftModel; } }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Filters { class CAircraftModelFilterDialog; }
|
||||
namespace Menus { class CMenuActions; }
|
||||
namespace Menus { class CMenuActions; }
|
||||
namespace Views
|
||||
{
|
||||
class CAircraftModelStatisticsDialog;
|
||||
class CAircraftModelValidationDialog;
|
||||
|
||||
//! Aircraft view
|
||||
class BLACKGUI_EXPORT CAircraftModelView :
|
||||
@@ -157,8 +158,12 @@ namespace BlackGui
|
||||
//! Dialog about model statistics
|
||||
void displayModelStatisticsDialog();
|
||||
|
||||
//! File validation dialog
|
||||
void displayModelValidationDialog();
|
||||
|
||||
bool m_stashingClearsSelection = true; //!< stashing unselects
|
||||
CAircraftModelStatisticsDialog *m_statisticsDialog = nullptr;
|
||||
CAircraftModelStatisticsDialog *m_statisticsDialog = nullptr;
|
||||
CAircraftModelValidationDialog *m_fileValidationDialog = nullptr;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_loadingRequiresSimulator; //!< simulator required when loading
|
||||
};
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user