mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T441, integrated CDbReduceModelDuplicates with own model set component
* some members renamed * context menu for "model reduction" * adjusted model statistics
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "blackgui/components/dbmappingcomponent.h"
|
||||
#include "blackgui/components/dbownmodelsetcomponent.h"
|
||||
#include "blackgui/components/dbownmodelsetformdialog.h"
|
||||
#include "blackgui/components/dbreducemodelduplicates.h"
|
||||
#include "blackgui/components/firstmodelsetdialog.h"
|
||||
#include "blackgui/components/copymodelsfromotherswiftversionsdialog.h"
|
||||
#include "blackgui/menus/aircraftmodelmenus.h"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include "blackgui/models/aircraftmodellistmodel.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackgui/views/viewbase.h"
|
||||
#include "blackgui/views/aircraftmodelstatisticsdialog.h"
|
||||
#include "blackmisc/simulation/aircraftmodelutils.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
@@ -81,7 +83,7 @@ namespace BlackGui
|
||||
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_ShowMatrix, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_ShowStatistics, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_CopyFromAnotherSwift, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->pb_FirstSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::buttonClicked);
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::setSimulator, Qt::QueuedConnection);
|
||||
@@ -236,9 +238,9 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender == ui->pb_ShowMatrix)
|
||||
if (sender == ui->pb_ShowStatistics)
|
||||
{
|
||||
this->showAirlineAircraftMatrix();
|
||||
this->showModelStatistics();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -292,6 +294,27 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::reduceModels()
|
||||
{
|
||||
if (!m_reduceModelsDialog)
|
||||
{
|
||||
m_reduceModelsDialog.reset(new CDbReduceModelDuplicates(this));
|
||||
}
|
||||
|
||||
// CAircraftModelList models = this->getModelSet(); // saved set
|
||||
CAircraftModelList models = ui->tvp_OwnModelSet->containerOrFilteredContainer();
|
||||
const CSimulatorInfo simulator = this->getModelSetSimulator();
|
||||
m_reduceModelsDialog->setModels(models, simulator);
|
||||
QDialog::DialogCode ret = static_cast<QDialog::DialogCode>(m_reduceModelsDialog->exec());
|
||||
if (ret != QDialog::Accepted) { return; }
|
||||
const CAircraftModelList removeModels = m_reduceModelsDialog->getRemoveCandidates();
|
||||
const CSimulatorInfo removeSimulator = m_reduceModelsDialog->getSimulator();
|
||||
if (removeModels.isEmpty()) { return; }
|
||||
const QSet<int> keys = removeModels.toDbKeySet();
|
||||
models.removeObjectsWithKeys(keys);
|
||||
this->setModelSet(models, removeSimulator);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::viewModelChanged()
|
||||
{
|
||||
const bool hasData = ui->tvp_OwnModelSet->rowCount() > 0;
|
||||
@@ -349,20 +372,20 @@ namespace BlackGui
|
||||
|
||||
void CDbOwnModelSetComponent::firstSet()
|
||||
{
|
||||
if (!m_firstModelSet)
|
||||
if (!m_firstModelSetDialog)
|
||||
{
|
||||
m_firstModelSet.reset(new CFirstModelSetDialog(this));
|
||||
m_firstModelSetDialog.reset(new CFirstModelSetDialog(this));
|
||||
}
|
||||
m_firstModelSet->show();
|
||||
m_firstModelSetDialog->show();
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::copyFromAnotherSwift()
|
||||
{
|
||||
if (!m_copyFromAnotherSwift)
|
||||
if (!m_copyFromAnotherSwiftDialog)
|
||||
{
|
||||
m_copyFromAnotherSwift.reset(new CCopyModelsFromOtherSwiftVersionsDialog(this));
|
||||
m_copyFromAnotherSwiftDialog.reset(new CCopyModelsFromOtherSwiftVersionsDialog(this));
|
||||
}
|
||||
m_copyFromAnotherSwift->show();
|
||||
m_copyFromAnotherSwiftDialog->show();
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &simulator)
|
||||
@@ -392,12 +415,15 @@ namespace BlackGui
|
||||
});
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::showAirlineAircraftMatrix() const
|
||||
void CDbOwnModelSetComponent::showModelStatistics()
|
||||
{
|
||||
const CAircraftModelList set(this->getModelSetFromView());
|
||||
const QString file = CAircraftModelUtilities::createIcaoAirlineAircraftHtmlMatrixFile(set, CGuiApplication::getTemporaryDirectory());
|
||||
if (file.isEmpty()) { return; }
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
|
||||
if (!m_modelStatisticsDialog)
|
||||
{
|
||||
m_modelStatisticsDialog.reset(new CAircraftModelStatisticsDialog(this));
|
||||
}
|
||||
m_modelStatisticsDialog->analyzeModels(set);
|
||||
m_modelStatisticsDialog->show();
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)
|
||||
@@ -505,6 +531,10 @@ namespace BlackGui
|
||||
QAction *a = new QAction(CIcons::appDistributors16(), "Apply distributor preferences", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::distributorPreferencesChanged);
|
||||
m_setActions.append(a);
|
||||
|
||||
a = new QAction(CIcons::delete16(), "Reduce models (remove duplicates)", this);
|
||||
connect(a, &QAction::triggered, ownModelSetComp, &CDbOwnModelSetComponent::reduceModels);
|
||||
m_setActions.append(a);
|
||||
}
|
||||
menuActions.addMenuModelSet();
|
||||
menuActions.addActions(m_setActions, CMenuAction::pathModelSet());
|
||||
|
||||
@@ -33,11 +33,16 @@ namespace BlackMisc { namespace Simulation { class CAircraftModel; } }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Menus { class CMenuActions; }
|
||||
namespace Views { class CAircraftModelView; }
|
||||
namespace Views
|
||||
{
|
||||
class CAircraftModelView;
|
||||
class CAircraftModelStatisticsDialog;
|
||||
}
|
||||
namespace Components
|
||||
{
|
||||
class CDbMappingComponent;
|
||||
class CDbOwnModelSetFormDialog;
|
||||
class CDbReduceModelDuplicates;
|
||||
class CCopyModelsFromOtherSwiftVersionsDialog;
|
||||
class CFirstModelSetDialog;
|
||||
|
||||
@@ -140,6 +145,9 @@ namespace BlackGui
|
||||
//! Preferences changed
|
||||
void distributorPreferencesChanged();
|
||||
|
||||
//! Reduce models
|
||||
void reduceModels();
|
||||
|
||||
//! Default file name
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
@@ -156,15 +164,18 @@ namespace BlackGui
|
||||
void copyFromAnotherSwift();
|
||||
|
||||
//! Show the airline/aircraft matrix
|
||||
void showAirlineAircraftMatrix() const;
|
||||
void showModelStatistics();
|
||||
|
||||
//! Update distributor order
|
||||
void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
|
||||
QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
|
||||
QScopedPointer<CFirstModelSetDialog> m_firstModelSet;
|
||||
QScopedPointer<CCopyModelsFromOtherSwiftVersionsDialog> m_copyFromAnotherSwift;
|
||||
QScopedPointer<CFirstModelSetDialog> m_firstModelSetDialog;
|
||||
QScopedPointer<CDbReduceModelDuplicates> m_reduceModelsDialog;
|
||||
QScopedPointer<CCopyModelsFromOtherSwiftVersionsDialog> m_copyFromAnotherSwiftDialog;
|
||||
QScopedPointer<Views::CAircraftModelStatisticsDialog> m_modelStatisticsDialog;
|
||||
|
||||
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< currently set simulator
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TDistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::distributorPreferencesChanged }; //!< distributor preferences
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModel> m_modelSettings { this }; //!< settings for models
|
||||
|
||||
@@ -110,9 +110,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_ShowMatrix">
|
||||
<widget class="QPushButton" name="pb_ShowStatistics">
|
||||
<property name="text">
|
||||
<string>matrix</string>
|
||||
<string>statistics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user