From b07234562fe545b702a6d0ffd998416550f7de27 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 19 Sep 2018 03:57:28 +0200 Subject: [PATCH] Ref T362, workbench component - temp. models - can be stashed and consolidated --- .../components/dbmodelworkbenchcomponent.cpp | 113 ++++++++++++++++++ .../components/dbmodelworkbenchcomponent.h | 93 ++++++++++++++ .../components/dbmodelworkbenchcomponent.ui | 49 ++++++++ 3 files changed, 255 insertions(+) create mode 100644 src/blackgui/components/dbmodelworkbenchcomponent.cpp create mode 100644 src/blackgui/components/dbmodelworkbenchcomponent.h create mode 100644 src/blackgui/components/dbmodelworkbenchcomponent.ui diff --git a/src/blackgui/components/dbmodelworkbenchcomponent.cpp b/src/blackgui/components/dbmodelworkbenchcomponent.cpp new file mode 100644 index 000000000..38f0ccae2 --- /dev/null +++ b/src/blackgui/components/dbmodelworkbenchcomponent.cpp @@ -0,0 +1,113 @@ +/* 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 "blackgui/components/dbownmodelscomponent.h" +#include "blackgui/components/simulatorselector.h" +#include "blackgui/menus/aircraftmodelmenus.h" +#include "blackgui/menus/menuaction.h" +#include "blackgui/views/aircraftmodelview.h" +#include "blackgui/models/aircraftmodellistmodel.h" +#include "blackgui/guiapplication.h" +#include "blackcore/webdataservices.h" +#include "blackcore/db/databaseutils.h" +#include "blackmisc/icons.h" +#include "blackmisc/logmessage.h" +#include "blackmisc/statusmessage.h" +#include "dbmodelworkbenchcomponent.h" +#include "ui_dbmodelworkbenchcomponent.h" + +#include +#include +#include +#include +#include +#include + +using namespace BlackMisc; +using namespace BlackMisc::Simulation; +using namespace BlackCore::Db; +using namespace BlackGui::Menus; +using namespace BlackGui::Views; +using namespace BlackGui::Models; + +namespace BlackGui +{ + namespace Components + { + CDbModelWorkbenchComponent::CDbModelWorkbenchComponent(QWidget *parent) : + COverlayMessagesFrame(parent), + ui(new Ui::CDbModelWorkbenchComponent) + { + ui->setupUi(this); + + ui->tvp_Models->menuAddItems(CAircraftModelView::MenuStashing); + ui->tvp_Models->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelMappingTool); + ui->tvp_Models->addFilterDialog(); + ui->tvp_Models->setDisplayAutomatically(true); + ui->tvp_Models->allowDragDrop(false, true, true); + ui->tvp_Models->setAcceptedMetaTypeIds(); + + // menu + ui->tvp_Models->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_Models, this)); + } + + CDbModelWorkbenchComponent::~CDbModelWorkbenchComponent() + { + // void + } + + const CLogCategoryList &CDbModelWorkbenchComponent::getLogCategories() + { + static const CLogCategoryList l({ CLogCategory::modelGui(), CLogCategory::guiComponent() }); + return l; + } + + CAircraftModelView *CDbModelWorkbenchComponent::view() const + { + return ui->tvp_Models; + } + + CAircraftModelListModel *CDbModelWorkbenchComponent::model() const + { + return ui->tvp_Models->derivedModel(); + } + + CAircraftModel CDbModelWorkbenchComponent::getOwnModelForModelString(const QString &modelString) const + { + return this->getModels().findFirstByModelStringOrDefault(modelString); + } + + CAircraftModelList CDbModelWorkbenchComponent::getSelectedModels() const + { + return ui->tvp_Models->selectedObjects(); + } + + CAircraftModelList CDbModelWorkbenchComponent::getModels() const + { + return ui->tvp_Models->container(); + } + + int CDbModelWorkbenchComponent::getModelsCount() const + { + return ui->tvp_Models->rowCount(); + } + + void CDbModelWorkbenchComponent::setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator) + { + Q_UNUSED(simulator); + ui->tvp_Models->replaceOrAddModelsWithString(models); + } + + int CDbModelWorkbenchComponent::updateModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator) + { + Q_UNUSED(simulator); + return ui->tvp_Models->replaceOrAddModelsWithString(models); + } + } // ns +} // ns diff --git a/src/blackgui/components/dbmodelworkbenchcomponent.h b/src/blackgui/components/dbmodelworkbenchcomponent.h new file mode 100644 index 000000000..627b4e1c6 --- /dev/null +++ b/src/blackgui/components/dbmodelworkbenchcomponent.h @@ -0,0 +1,93 @@ +/* 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_DBMODELSWORKBENCHCOMPONENT_H +#define BLACKGUI_COMPONENTS_DBMODELSWORKBENCHCOMPONENT_H + +#include "blackgui/overlaymessagesframe.h" +#include "blackmisc/simulation/aircraftmodelinterfaces.h" +#include "blackmisc/simulation/aircraftmodellist.h" +#include "blackmisc/directories.h" +#include "blackmisc/statusmessage.h" + +#include +#include +#include +#include +#include + +namespace Ui { class CDbModelWorkbenchComponent; } +namespace BlackGui +{ + namespace Menus { class CMenuActions; } + namespace Models { class CAircraftModelListModel; } + namespace Views { class CAircraftModelView; } + namespace Components + { + /*! + * Handling of own models on disk (the models installed for the simulator) + */ + class CDbModelWorkbenchComponent : + public COverlayMessagesFrame, + public BlackMisc::Simulation::IModelsSetable, + public BlackMisc::Simulation::IModelsUpdatable, + public BlackMisc::Simulation::IModelsForSimulatorSetable, + public BlackMisc::Simulation::IModelsForSimulatorUpdatable + { + Q_OBJECT + Q_INTERFACES(BlackMisc::Simulation::IModelsSetable) + Q_INTERFACES(BlackMisc::Simulation::IModelsUpdatable) + Q_INTERFACES(BlackMisc::Simulation::IModelsForSimulatorSetable) + Q_INTERFACES(BlackMisc::Simulation::IModelsForSimulatorUpdatable) + + public: + //! Constructor + explicit CDbModelWorkbenchComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CDbModelWorkbenchComponent() override; + + //! Log categories + static const BlackMisc::CLogCategoryList &getLogCategories(); + + //! Own (installed) model for given model string + BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const; + + //! Own models selected in view + BlackMisc::Simulation::CAircraftModelList getSelectedModels() const; + + //! Models + BlackMisc::Simulation::CAircraftModelList getModels() const; + + //! Number of own models + int getModelsCount() const; + + //! Models view + BlackGui::Views::CAircraftModelView *view() const; + + //! Access to aircraft model + Models::CAircraftModelListModel *model() const; + + //! \name Implementations of the models interfaces + //! @{ + virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setModelsForSimulator(models, BlackMisc::Simulation::CSimulatorInfo()); } + virtual void setModelsForSimulator(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; + virtual int updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { return this->updateModelsForSimulator(models, BlackMisc::Simulation::CSimulatorInfo()); } + virtual int updateModelsForSimulator(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override; + //! @} + + private: + QScopedPointer ui; + BlackMisc::CSetting m_directorySettings { this }; //!< the swift directories + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/dbmodelworkbenchcomponent.ui b/src/blackgui/components/dbmodelworkbenchcomponent.ui new file mode 100644 index 000000000..c7ca04217 --- /dev/null +++ b/src/blackgui/components/dbmodelworkbenchcomponent.ui @@ -0,0 +1,49 @@ + + + CDbModelWorkbenchComponent + + + Frame + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + You can use the workbench to temporary load models and modify them. + + + + + + + QAbstractItemView::SelectRows + + + false + + + + + + + + BlackGui::Views::CAircraftModelView + QTableView +
blackgui/views/aircraftmodelview.h
+
+
+ + +