From 608e39ee9a449ef1f36f4b7d7a9c273c28e65570 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 9 Dec 2016 03:38:12 +0100 Subject: [PATCH] refs #828, added function to show matrix from ui --- .../components/dbownmodelsetcomponent.cpp | 72 ++++++++++++------- .../components/dbownmodelsetcomponent.h | 6 ++ .../components/dbownmodelsetcomponent.ui | 7 ++ 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index 8f899f891..bd0ecd660 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -7,6 +7,7 @@ * contained in the LICENSE file. */ +#include "blackgui/guiapplication.h" #include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbownmodelsetcomponent.h" #include "blackgui/components/dbownmodelsetdialog.h" @@ -19,7 +20,7 @@ #include "blackmisc/icons.h" #include "blackmisc/logmessage.h" #include "blackmisc/orderable.h" -#include "blackmisc/simulation/aircraftmodel.h" +#include "blackmisc/simulation/aircraftmodelutils.h" #include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/distributorlist.h" #include "blackmisc/simulation/distributorlistpreferences.h" @@ -35,6 +36,7 @@ #include #include #include +#include using namespace BlackMisc; using namespace BlackMisc::Simulation; @@ -69,6 +71,7 @@ namespace BlackGui connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); + connect(ui->pb_ShowMatrix, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked); connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged); connect(&this->m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged); connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged); @@ -198,31 +201,7 @@ namespace BlackGui const QObject *sender = QObject::sender(); if (sender == ui->pb_CreateNewSet) { - // make sure both tabs display the same simulator - Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component"); - const CSimulatorInfo sim(this->getModelSetSimulator()); - this->getMappingComponent()->setOwnModelsSimulator(sim); - if (!this->m_modelSetDialog) - { - this->m_modelSetDialog.reset(new CDbOwnModelSetDialog(this)); - this->m_modelSetDialog->setMappingComponent(this->getMappingComponent()); - } - - if (this->getMappingComponent()->getOwnModelsCount() > 0) - { - this->m_modelSetDialog->setModal(true); - this->m_modelSetDialog->reloadData(); - QDialog::DialogCode rc = static_cast(this->m_modelSetDialog->exec()); - if (rc == QDialog::Accepted) - { - this->setModelSet(this->m_modelSetDialog->getModelSet(), this->m_modelSetDialog->getSimulatorInfo()); - } - } - else - { - static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << sim.toQString(true); - this->getMappingComponent()->showOverlayMessage(m); - } + this->createNewSet(); } else if (sender == ui->pb_LoadExistingSet) { @@ -237,6 +216,10 @@ namespace BlackGui CLogMessage::preformatted(m); } } + else if (sender == ui->pb_ShowMatrix) + { + this->showAirlineAircraftMatrix(); + } } void CDbOwnModelSetComponent::ps_changeSimulator(const CSimulatorInfo &simulator) @@ -309,6 +292,43 @@ namespace BlackGui ui->tvp_OwnModelSet->updateContainerMaybeAsync(models); } + void CDbOwnModelSetComponent::createNewSet() + { + // make sure both tabs display the same simulator + Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component"); + const CSimulatorInfo sim(this->getModelSetSimulator()); + this->getMappingComponent()->setOwnModelsSimulator(sim); + if (!this->m_modelSetDialog) + { + this->m_modelSetDialog.reset(new CDbOwnModelSetDialog(this)); + this->m_modelSetDialog->setMappingComponent(this->getMappingComponent()); + } + + if (this->getMappingComponent()->getOwnModelsCount() > 0) + { + this->m_modelSetDialog->setModal(true); + this->m_modelSetDialog->reloadData(); + QDialog::DialogCode rc = static_cast(this->m_modelSetDialog->exec()); + if (rc == QDialog::Accepted) + { + this->setModelSet(this->m_modelSetDialog->getModelSet(), this->m_modelSetDialog->getSimulatorInfo()); + } + } + else + { + static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << sim.toQString(true); + this->getMappingComponent()->showOverlayMessage(m); + } + } + + void CDbOwnModelSetComponent::showAirlineAircraftMatrix() const + { + const CAircraftModelList set(this->getModelSet()); + const QString file = CAircraftModelUtilities::createIcaoAirlineAircraftHtmlMatrixFile(set, sGui->getTemporaryDirectory()); + if (file.isEmpty()) { return; } + QDesktopServices::openUrl(QUrl::fromLocalFile(file)); + } + void CDbOwnModelSetComponent::setModelSetSimulator(const CSimulatorInfo &simulator) { if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals diff --git a/src/blackgui/components/dbownmodelsetcomponent.h b/src/blackgui/components/dbownmodelsetcomponent.h index 57d502a93..c99e93639 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.h +++ b/src/blackgui/components/dbownmodelsetcomponent.h @@ -133,6 +133,12 @@ namespace BlackGui //! Update view to current models void updateViewToCurrentModels(); + //! Create new set + void createNewSet(); + + //! Show the airline/aircraft matrix + void showAirlineAircraftMatrix() const; + //! Update distributor order void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator); diff --git a/src/blackgui/components/dbownmodelsetcomponent.ui b/src/blackgui/components/dbownmodelsetcomponent.ui index 0f0aedf78..5c7e43dee 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.ui +++ b/src/blackgui/components/dbownmodelsetcomponent.ui @@ -109,6 +109,13 @@ + + + + matrix + + +