From 1f00c71feade84463da87e5e7629e8164b38dedf Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 4 Jun 2018 11:18:15 +0200 Subject: [PATCH] Ref T246, allow to copy model set or create 1st model set as dialog from mapping tool --- ...copymodelsfromotherswiftversionsdialog.cpp | 28 +++++++ .../copymodelsfromotherswiftversionsdialog.h | 43 ++++++++++ .../copymodelsfromotherswiftversionsdialog.ui | 39 +++++++++ .../components/dbownmodelsetcomponent.cpp | 57 +++++++++++-- .../components/dbownmodelsetcomponent.h | 14 +++- .../components/dbownmodelsetcomponent.ui | 28 +++++-- .../components/firstmodelsetcomponent.ui | 18 ++-- .../components/firstmodelsetdialog.cpp | 28 +++++++ src/blackgui/components/firstmodelsetdialog.h | 42 ++++++++++ .../components/firstmodelsetdialog.ui | 82 +++++++++++++++++++ 10 files changed, 353 insertions(+), 26 deletions(-) create mode 100644 src/blackgui/components/copymodelsfromotherswiftversionsdialog.cpp create mode 100644 src/blackgui/components/copymodelsfromotherswiftversionsdialog.h create mode 100644 src/blackgui/components/copymodelsfromotherswiftversionsdialog.ui create mode 100644 src/blackgui/components/firstmodelsetdialog.cpp create mode 100644 src/blackgui/components/firstmodelsetdialog.h create mode 100644 src/blackgui/components/firstmodelsetdialog.ui diff --git a/src/blackgui/components/copymodelsfromotherswiftversionsdialog.cpp b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.cpp new file mode 100644 index 000000000..4f75d92cb --- /dev/null +++ b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.cpp @@ -0,0 +1,28 @@ +/* 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 "copymodelsfromotherswiftversionsdialog.h" +#include "ui_copymodelsfromotherswiftversionsdialog.h" + +namespace BlackGui +{ + namespace Components + { + CCopyModelsFromOtherSwiftVersionsDialog::CCopyModelsFromOtherSwiftVersionsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CCopyModelsFromOtherSwiftVersionsDialog) + { + ui->setupUi(this); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); + } + + CCopyModelsFromOtherSwiftVersionsDialog::~CCopyModelsFromOtherSwiftVersionsDialog() + { } + } // ns +} // ns diff --git a/src/blackgui/components/copymodelsfromotherswiftversionsdialog.h b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.h new file mode 100644 index 000000000..1e8ce4732 --- /dev/null +++ b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.h @@ -0,0 +1,43 @@ +/* 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_COMPONENTS_COPYMODELSFROMOTHERSWIFTVERSIONSDIALOG_H +#define BLACKGUI_COMPONENTS_COPYMODELSFROMOTHERSWIFTVERSIONSDIALOG_H + +#include +#include + +namespace Ui { class CCopyModelsFromOtherSwiftVersionsDialog; } +namespace BlackGui +{ + namespace Components + { + /** + * Copy models from other swift versions as dialog + */ + class CCopyModelsFromOtherSwiftVersionsDialog : public QDialog + { + Q_OBJECT + + public: + //! Constructor + explicit CCopyModelsFromOtherSwiftVersionsDialog(QWidget *parent = nullptr); + + //! Destructor + virtual ~CCopyModelsFromOtherSwiftVersionsDialog(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/copymodelsfromotherswiftversionsdialog.ui b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.ui new file mode 100644 index 000000000..2a6619c40 --- /dev/null +++ b/src/blackgui/components/copymodelsfromotherswiftversionsdialog.ui @@ -0,0 +1,39 @@ + + + CCopyModelsFromOtherSwiftVersionsDialog + + + + 0 + 0 + 640 + 480 + + + + Copy models from another swift version + + + + + + + + + QDialogButtonBox::Close + + + + + + + + BlackGui::Components::CCopyModelsFromOtherSwiftVersionsComponent + QFrame +
blackgui/components/copymodelsfromotherswiftversionscomponent.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp index 04ecb4877..da180242e 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.cpp +++ b/src/blackgui/components/dbownmodelsetcomponent.cpp @@ -11,19 +11,21 @@ #include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbownmodelsetcomponent.h" #include "blackgui/components/dbownmodelsetformdialog.h" +#include "blackgui/components/firstmodelsetdialog.h" +#include "blackgui/components/copymodelsfromotherswiftversionsdialog.h" #include "blackgui/menus/aircraftmodelmenus.h" #include "blackgui/menus/menuaction.h" #include "blackgui/models/aircraftmodellistmodel.h" #include "blackgui/views/aircraftmodelview.h" #include "blackgui/views/viewbase.h" -#include "blackmisc/compare.h" -#include "blackmisc/icons.h" -#include "blackmisc/logmessage.h" -#include "blackmisc/orderable.h" #include "blackmisc/simulation/aircraftmodelutils.h" #include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/distributorlist.h" #include "blackmisc/simulation/distributorlistpreferences.h" +#include "blackmisc/compare.h" +#include "blackmisc/icons.h" +#include "blackmisc/logmessage.h" +#include "blackmisc/orderable.h" #include "ui_dbownmodelsetcomponent.h" #include @@ -76,6 +78,8 @@ namespace BlackGui 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_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); connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::changeSimulator, Qt::QueuedConnection); connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::onRowCountChanged); @@ -216,12 +220,16 @@ namespace BlackGui if (sender == ui->pb_CreateNewSet) { this->createNewSet(); + return; } - else if (sender == ui->pb_LoadExistingSet) + + if (sender == ui->pb_LoadExistingSet) { ui->tvp_OwnModelSet->showFileLoadDialog(); + return; } - else if (sender == ui->pb_SaveAsSetForSimulator) + + if (sender == ui->pb_SaveAsSetForSimulator) { const CAircraftModelList ml(ui->tvp_OwnModelSet->container()); if (!ml.isEmpty()) @@ -229,10 +237,25 @@ namespace BlackGui const CStatusMessage m = m_modelSetLoader.setCachedModels(ml); CLogMessage::preformatted(m); } + return; } - else if (sender == ui->pb_ShowMatrix) + + if (sender == ui->pb_ShowMatrix) { this->showAirlineAircraftMatrix(); + return; + } + + if (sender == ui->pb_FirstSet) + { + this->firstSet(); + return; + } + + if (sender == ui->pb_CopyFromAnotherSwift) + { + this->copyFromAnotherSwift(); + return; } } @@ -317,11 +340,29 @@ namespace BlackGui } else { - static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << simulator.toQString(true); + const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << simulator.toQString(true); if (mc) { mc->showOverlayMessage(m); } } } + void CDbOwnModelSetComponent::firstSet() + { + if (!m_firstModelSet) + { + m_firstModelSet.reset(new CFirstModelSetDialog(this)); + } + m_firstModelSet->show(); + } + + void CDbOwnModelSetComponent::copyFromAnotherSwift() + { + if (!m_copyFromAnotherSwift) + { + m_copyFromAnotherSwift.reset(new CCopyModelsFromOtherSwiftVersionsDialog(this)); + } + m_copyFromAnotherSwift->show(); + } + void CDbOwnModelSetComponent::changeSimulator(const CSimulatorInfo &simulator) { m_modelSetLoader.setSimulator(simulator); diff --git a/src/blackgui/components/dbownmodelsetcomponent.h b/src/blackgui/components/dbownmodelsetcomponent.h index 92f5eeac4..1dea105bf 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.h +++ b/src/blackgui/components/dbownmodelsetcomponent.h @@ -39,6 +39,8 @@ namespace BlackGui { class CDbMappingComponent; class CDbOwnModelSetFormDialog; + class CCopyModelsFromOtherSwiftVersionsDialog; + class CFirstModelSetDialog; /*! * Handling of the own model set @@ -143,6 +145,12 @@ namespace BlackGui //! Create new set void createNewSet(); + //! First set wizard + void firstSet(); + + //! Copy from another swift version + void copyFromAnotherSwift(); + //! Unchecked version of setSimulator void changeSimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator); @@ -152,8 +160,10 @@ namespace BlackGui //! Update distributor order void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator); - QScopedPointer ui; - QScopedPointer m_modelSetFormDialog; + QScopedPointer ui; + QScopedPointer m_modelSetFormDialog; + QScopedPointer m_firstModelSet; + QScopedPointer m_copyFromAnotherSwift; BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; BlackMisc::CSettingReadOnly m_distributorPreferences { this, &CDbOwnModelSetComponent::distributorPreferencesChanged }; //!< distributor preferences BlackMisc::CSettingReadOnly m_modelSettings { this }; //!< settings for models diff --git a/src/blackgui/components/dbownmodelsetcomponent.ui b/src/blackgui/components/dbownmodelsetcomponent.ui index 5c7e43dee..3af2cf4f2 100644 --- a/src/blackgui/components/dbownmodelsetcomponent.ui +++ b/src/blackgui/components/dbownmodelsetcomponent.ui @@ -6,8 +6,8 @@ 0 0 - 796 - 224 + 1019 + 223 @@ -132,6 +132,20 @@ + + + + first set + + + + + + + copy + + + @@ -170,17 +184,17 @@ - - BlackGui::Views::CAircraftModelView - QTableView -
blackgui/views/aircraftmodelview.h
-
BlackGui::Components::CSimulatorSelector QFrame
blackgui/components/simulatorselector.h
1
+ + BlackGui::Views::CAircraftModelView + QTableView +
blackgui/views/aircraftmodelview.h
+
diff --git a/src/blackgui/components/firstmodelsetcomponent.ui b/src/blackgui/components/firstmodelsetcomponent.ui index 39595c054..24ff8bb36 100644 --- a/src/blackgui/components/firstmodelsetcomponent.ui +++ b/src/blackgui/components/firstmodelsetcomponent.ui @@ -16,8 +16,15 @@ - - + + + + + <html><img src=":/own/icons/own/swift3D/sw3DOrange-32.png"></html> + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600; color:#ff0000;">WORK IN PROGRESS (experimental) </span><span style=" font-size:9pt;">The model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.</span></p></body></html> @@ -30,13 +37,6 @@ - - - - <html><img src=":/own/icons/own/swift3D/sw3DOrange-32.png"></html> - - - diff --git a/src/blackgui/components/firstmodelsetdialog.cpp b/src/blackgui/components/firstmodelsetdialog.cpp new file mode 100644 index 000000000..64c0cf4d7 --- /dev/null +++ b/src/blackgui/components/firstmodelsetdialog.cpp @@ -0,0 +1,28 @@ +/* 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 "firstmodelsetdialog.h" +#include "ui_firstmodelsetdialog.h" + +namespace BlackGui +{ + namespace Components + { + CFirstModelSetDialog::CFirstModelSetDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::CFirstModelSetDialog) + { + ui->setupUi(this); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); + } + + CFirstModelSetDialog::~CFirstModelSetDialog() + { } + } // ns +} // ns diff --git a/src/blackgui/components/firstmodelsetdialog.h b/src/blackgui/components/firstmodelsetdialog.h new file mode 100644 index 000000000..b595f8ffd --- /dev/null +++ b/src/blackgui/components/firstmodelsetdialog.h @@ -0,0 +1,42 @@ +/* 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_COMPONENTS_FIRSTMODELSETDIALOG_H +#define BLACKGUI_COMPONENTS_FIRSTMODELSETDIALOG_H + +#include +#include + +namespace Ui { class CFirstModelSetDialog; } +namespace BlackGui +{ + namespace Components + { + /** + * First model set dialog + */ + class CFirstModelSetDialog : public QDialog + { + Q_OBJECT + + public: + //! Constructor + explicit CFirstModelSetDialog(QWidget *parent = nullptr); + + //! Destructor + virtual ~CFirstModelSetDialog(); + + private: + QScopedPointer ui; + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/firstmodelsetdialog.ui b/src/blackgui/components/firstmodelsetdialog.ui new file mode 100644 index 000000000..8c5b3fdd0 --- /dev/null +++ b/src/blackgui/components/firstmodelsetdialog.ui @@ -0,0 +1,82 @@ + + + CFirstModelSetDialog + + + + 0 + 0 + 640 + 480 + + + + First model set + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + BlackGui::Components::CFirstModelSetComponent + QFrame +
blackgui/components/firstmodelsetcomponent.h
+ 1 +
+
+ + + + bb_FirstModelSetDialog + accepted() + CFirstModelSetDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_FirstModelSetDialog + rejected() + CFirstModelSetDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +