mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Ref T310, added model statistics dialog
* UI for statistics * renamed to "coverageSummaryForModel" * model list "htmlStatistics"
This commit is contained in:
35
src/blackgui/views/aircraftmodelstatisticsdialog.cpp
Normal file
35
src/blackgui/views/aircraftmodelstatisticsdialog.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 "aircraftmodelstatisticsdialog.h"
|
||||
#include "ui_aircraftmodelstatisticsdialog.h"
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CAircraftModelStatisticsDialog::CAircraftModelStatisticsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CAircraftModelStatisticsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
CAircraftModelStatisticsDialog::~CAircraftModelStatisticsDialog()
|
||||
{ }
|
||||
|
||||
void CAircraftModelStatisticsDialog::analyzeModels(const CAircraftModelList &models)
|
||||
{
|
||||
ui->te_Statistics->setHtml(models.htmlStatistics());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
45
src/blackgui/views/aircraftmodelstatisticsdialog.h
Normal file
45
src/blackgui/views/aircraftmodelstatisticsdialog.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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_VIEW_AIRCRAFTMODELSTATISTICSDIALOG_H
|
||||
#define BLACKGUI_VIEW_AIRCRAFTMODELSTATISTICSDIALOG_H
|
||||
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAircraftModelStatisticsDialog; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
//! Info about the models
|
||||
class CAircraftModelStatisticsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftModelStatisticsDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CAircraftModelStatisticsDialog();
|
||||
|
||||
//! Set and analyze the models
|
||||
void analyzeModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftModelStatisticsDialog> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
80
src/blackgui/views/aircraftmodelstatisticsdialog.ui
Normal file
80
src/blackgui/views/aircraftmodelstatisticsdialog.ui
Normal file
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAircraftModelStatisticsDialog</class>
|
||||
<widget class="QDialog" name="CAircraftModelStatisticsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Aircraft model statistics</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="te_Statistics">
|
||||
<property name="documentTitle">
|
||||
<string>Statistics</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_AircraftModelStatistics">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_AircraftModelStatistics</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CAircraftModelStatisticsDialog</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_AircraftModelStatistics</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CAircraftModelStatisticsDialog</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>
|
||||
@@ -7,9 +7,10 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "aircraftmodelview.h"
|
||||
#include "viewbase.h"
|
||||
#include "aircraftmodelstatisticsdialog.h"
|
||||
#include "blackgui/filters/aircraftmodelfilterdialog.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackgui/views/viewbase.h"
|
||||
#include "blackgui/menus/menuaction.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
@@ -206,7 +207,7 @@ namespace BlackGui
|
||||
{
|
||||
if (valueVariant.canConvert<CAircraftModel>())
|
||||
{
|
||||
CAircraftModel model = valueVariant.value<CAircraftModel>();
|
||||
const CAircraftModel model = valueVariant.value<CAircraftModel>();
|
||||
if (!model.hasModelString()) { return; }
|
||||
const CAircraftModelList models({model});
|
||||
this->derivedModel()->replaceOrAddByModelString(models);
|
||||
@@ -214,7 +215,7 @@ namespace BlackGui
|
||||
}
|
||||
else if (valueVariant.canConvert<CAircraftModelList>())
|
||||
{
|
||||
CAircraftModelList models(valueVariant.value<CAircraftModelList>());
|
||||
const CAircraftModelList models(valueVariant.value<CAircraftModelList>());
|
||||
if (models.isEmpty()) { return; }
|
||||
this->derivedModel()->replaceOrAddByModelString(models);
|
||||
return;
|
||||
@@ -266,7 +267,7 @@ namespace BlackGui
|
||||
}
|
||||
else if (valueVariant.canConvert<CAirlineIcaoCode>())
|
||||
{
|
||||
CAirlineIcaoCode airline = valueVariant.value<CAirlineIcaoCode>();
|
||||
const CAirlineIcaoCode airline = valueVariant.value<CAirlineIcaoCode>();
|
||||
if (airline.validate().hasErrorMessages()) { return; }
|
||||
emit requestHandlingOfStashDrop(airline); // I need to convert to stanard livery, which I can`t do here
|
||||
}
|
||||
@@ -288,7 +289,11 @@ namespace BlackGui
|
||||
|
||||
void CAircraftModelView::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
bool used = false;
|
||||
// Statistics
|
||||
menuActions.addAction(CIcons::appAircraft16(), "Model statistics", CMenuAction::pathModel(), { this, &CAircraftModelView::displayModelStatisticsDialog });
|
||||
|
||||
// Stash menus
|
||||
bool addStashMenu = false;
|
||||
if (m_menus.testFlag(MenuCanStashModels))
|
||||
{
|
||||
if (!m_menuFlagActions.contains(MenuCanStashModels))
|
||||
@@ -308,7 +313,7 @@ namespace BlackGui
|
||||
a->setEnabled(canStash);
|
||||
a = menuActions.addActions(initMenuActions(MenuCanStashModels)).last();
|
||||
a->setChecked(m_stashingClearsSelection);
|
||||
used = true;
|
||||
addStashMenu = true;
|
||||
}
|
||||
if (m_menus.testFlag(MenuHighlightStashed))
|
||||
{
|
||||
@@ -322,9 +327,11 @@ namespace BlackGui
|
||||
}
|
||||
QAction *a = menuActions.addActions(initMenuActions(CViewBaseNonTemplate::MenuHighlightStashed)).first();
|
||||
a->setChecked(this->derivedModel()->highlightModelStrings());
|
||||
used = true;
|
||||
addStashMenu = true;
|
||||
}
|
||||
if (used) { menuActions.addMenuStash();}
|
||||
if (addStashMenu) { menuActions.addMenuStash(); }
|
||||
|
||||
// base class menus
|
||||
COrderableViewWithDbObjects::customMenu(menuActions);
|
||||
}
|
||||
|
||||
@@ -392,5 +399,16 @@ namespace BlackGui
|
||||
}
|
||||
sGui->displayInStatusBar(CStatusMessage(CStatusMessage::SeverityInfo, "Stashed " + models.getModelStringList(true).join(" ")));
|
||||
}
|
||||
|
||||
void CAircraftModelView::displayModelStatisticsDialog()
|
||||
{
|
||||
if (!m_statisticsDialog)
|
||||
{
|
||||
m_statisticsDialog = new CAircraftModelStatisticsDialog(this);
|
||||
}
|
||||
|
||||
m_statisticsDialog->analyzeModels(this->container());
|
||||
m_statisticsDialog->exec();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -46,6 +46,8 @@ namespace BlackGui
|
||||
namespace Menus { class CMenuActions; }
|
||||
namespace Views
|
||||
{
|
||||
class CAircraftModelStatisticsDialog;
|
||||
|
||||
//! Aircraft view
|
||||
class BLACKGUI_EXPORT CAircraftModelView :
|
||||
public COrderableViewWithDbObjects<Models::CAircraftModelListModel, BlackMisc::Simulation::CAircraftModelList, BlackMisc::Simulation::CAircraftModel, int>
|
||||
@@ -146,7 +148,11 @@ namespace BlackGui
|
||||
//! Stash shortcut pressed
|
||||
void requestedStash();
|
||||
|
||||
//! Dialog about model statistics
|
||||
void displayModelStatisticsDialog();
|
||||
|
||||
bool m_stashingClearsSelection = true; //!< stashing unselects
|
||||
CAircraftModelStatisticsDialog *m_statisticsDialog = nullptr;
|
||||
BlackMisc::Simulation::CSimulatorInfo m_loadingRequiresSimulator; //!< simulator required when loading
|
||||
};
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user