mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T362, workbench component
- temp. models - can be stashed and consolidated
This commit is contained in:
113
src/blackgui/components/dbmodelworkbenchcomponent.cpp
Normal file
113
src/blackgui/components/dbmodelworkbenchcomponent.cpp
Normal file
@@ -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 <QAction>
|
||||
#include <QIcon>
|
||||
#include <QDir>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
#include <QFileDialog>
|
||||
|
||||
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
|
||||
93
src/blackgui/components/dbmodelworkbenchcomponent.h
Normal file
93
src/blackgui/components/dbmodelworkbenchcomponent.h
Normal file
@@ -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 <QFrame>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
#include <QStringList>
|
||||
|
||||
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::CDbModelWorkbenchComponent> ui;
|
||||
BlackMisc::CSetting<BlackMisc::Settings::TDirectorySettings> m_directorySettings { this }; //!< the swift directories
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
49
src/blackgui/components/dbmodelworkbenchcomponent.ui
Normal file
49
src/blackgui/components/dbmodelworkbenchcomponent.ui
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDbModelWorkbenchComponent</class>
|
||||
<widget class="QFrame" name="CDbModelWorkbenchComponent">
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_WorkbenchComponent">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Workbench">
|
||||
<property name="text">
|
||||
<string>You can use the workbench to temporary load models and modify them.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Views::CAircraftModelView" name="tvp_Models">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Views::CAircraftModelView</class>
|
||||
<extends>QTableView</extends>
|
||||
<header>blackgui/views/aircraftmodelview.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user