refs #618, GUI dialog to create own model set

* new tab in model mapping component
* form + dialog to select appropriate models
This commit is contained in:
Klaus Basan
2016-03-14 20:27:46 +01:00
parent 17cbd31095
commit 42d5ceff32
14 changed files with 992 additions and 74 deletions

View File

@@ -43,6 +43,7 @@ namespace BlackGui
{
ui->setupUi(this);
this->ui->comp_StashAircraft->setMappingComponent(this);
this->ui->comp_OwnModelSet->setMappingComponent(this);
this->ui->tvp_AircraftModelsForVPilot->setAircraftModelMode(CAircraftModelListModel::VPilotRuleModel);
this->ui->tvp_AircraftModelsForVPilot->addFilterDialog();
@@ -64,13 +65,21 @@ namespace BlackGui
connect(ui->comp_StashAircraft, &CDbStashComponent::stashedModelsChanged, this, &CDbMappingComponent::ps_onStashedModelsChanged);
connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this, &CDbMappingComponent::ps_onModelsSuccessfullyPublished);
connect(ui->comp_OwnModelSet->getView(), &CAircraftModelView::rowCountChanged, this, &CDbMappingComponent::ps_onModelSetCountChanged);
connect(ui->tw_ModelsToBeMapped, &QTabWidget::currentChanged, this, &CDbMappingComponent::tabIndexChanged);
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
ui->tvp_OwnAircraftModels->setCustomMenu(new CShowSimulatorFile(this), false);
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingOwnSimulatorModelMenu(this));
ui->tvp_OwnAircraftModels->setCustomMenu(new CModelStashTools(this, false));
if (this->m_modelLoader)
this->m_lastInteractions.synchronize();
const CSimulatorInfo sim = this->m_lastInteractions.get().getLastSimulatorSelection();
if (sim.isSingleSimulator())
{
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->m_modelLoader->getAircraftModels());
// if we have already use this before, use it again, but only from cache
this->initModelLoader(sim);
this->m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
}
// how to display forms
@@ -84,21 +93,6 @@ namespace BlackGui
// vPilot
this->initVPilotLoading();
QTimer::singleShot(1000, this, &CDbMappingComponent::ps_deferredInit);
}
void CDbMappingComponent::ps_deferredInit()
{
// deferred
this->m_lastInteractions.synchronize();
const CSimulatorInfo sim = this->m_lastInteractions.get().getLastSimulatorSelection();
if (sim.isSingleSimulator())
{
// if we have already use this before, use it again, but only from cache
this->initModelLoader(sim);
this->m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
}
}
CDbMappingComponent::~CDbMappingComponent()
@@ -169,7 +163,6 @@ namespace BlackGui
else
{
bool c = connect(this->m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbMappingComponent::ps_onOwnModelsLoadingFinished);
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
Q_UNUSED(c);
return true;
@@ -221,23 +214,7 @@ namespace BlackGui
return false;
}
const CAircraftModelView *CDbMappingComponent::currentModelView() const
{
TabIndex tab = currentTabIndex();
switch (tab)
{
case TabOwnModels:
return ui->tvp_OwnAircraftModels;
case TabVPilot:
return ui->tvp_AircraftModelsForVPilot;
case TabStash:
return ui->comp_StashAircraft->getView();
default:
return nullptr;
}
}
CAircraftModelView *CDbMappingComponent::currentModelView()
CAircraftModelView *CDbMappingComponent::currentModelView() const
{
TabIndex tab = currentTabIndex();
switch (tab)
@@ -248,6 +225,8 @@ namespace BlackGui
return ui->tvp_AircraftModelsForVPilot;
case TabStash:
return ui->comp_StashAircraft->getView();
case TabOwnModelSet:
return ui->comp_OwnModelSet->getView();
default:
return nullptr;
}
@@ -291,6 +270,26 @@ namespace BlackGui
return this->m_modelLoader->getAircraftModels().findFirstByModelString(modelString);
}
CAircraftModelList CDbMappingComponent::getOwnModels() const
{
static const CAircraftModelList empty;
if (!this->m_modelLoader) { return empty; }
return this->m_modelLoader->getAircraftModels();
}
const CSimulatorInfo &CDbMappingComponent::getOwnModelsSimulator() const
{
static const CSimulatorInfo noSim;
if (!this->m_modelLoader) { return noSim; }
return this->m_modelLoader->getSimulator();
}
int CDbMappingComponent::getOwnModelsCount() const
{
if (!this->m_modelLoader) { return 0; }
return this->m_modelLoader->getAircraftModelsCount();
}
CDbMappingComponent::TabIndex CDbMappingComponent::currentTabIndex() const
{
if (!ui->tw_ModelsToBeMapped) { return CDbMappingComponent::NoValidTab; }
@@ -583,7 +582,7 @@ namespace BlackGui
QString o(ot);
if (this->m_modelLoader)
{
QString sims(this->m_modelLoader->supportedSimulatorsAsString());
QString sims(this->m_modelLoader->getSimulatorAsString());
if (!sims.isEmpty()) { o = o.append(" ").append(sims); }
}
QString f = this->ui->tvp_OwnAircraftModels->hasFilter() ? "F" : "";
@@ -602,6 +601,17 @@ namespace BlackGui
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
}
void CDbMappingComponent::ps_onModelSetCountChanged(int count, bool withFilter)
{
Q_UNUSED(count);
Q_UNUSED(withFilter);
int i = this->ui->tw_ModelsToBeMapped->indexOf(this->ui->tab_OwnModelSet);
QString o = this->ui->tw_ModelsToBeMapped->tabText(i);
QString f = this->ui->comp_StashAircraft->getView()->hasFilter() ? "F" : "";
o = CGuiUtility::replaceTabCountValue(o, this->ui->comp_OwnModelSet->getView()->rowCount()) + f;
this->ui->tw_ModelsToBeMapped->setTabText(i, o);
}
void CDbMappingComponent::ps_requestSimulatorModels(const CSimulatorInfo &simInfo, IAircraftModelLoader::LoadMode mode)
{
this->ps_loadInstalledModels(simInfo, mode);
@@ -696,6 +706,7 @@ namespace BlackGui
void CDbMappingComponent::ps_onOwnModelsLoadingFinished(bool success, const CSimulatorInfo &simInfo)
{
Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
if (success && this->m_modelLoader)
{
const CAircraftModelList models(this->m_modelLoader->getAircraftModels());
@@ -764,21 +775,21 @@ namespace BlackGui
QMenu *load = menu.addMenu(CIcons::appModels16(), "Load installed models");
CDbMappingComponent *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access parent");
if (sims.fs9())
if (sims.fsx())
{
load->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
load->addAction(CIcons::appModels16(), "FSX models", mapComp, [mapComp]()
{
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundWithCache);
});
}
if (sims.fsx())
if (sims.p3d())
{
load->addAction(CIcons::appModels16(), "P3D models", mapComp, [mapComp]()
{
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundWithCache);
});
}
if (sims.p3d())
if (sims.fs9())
{
load->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
{
@@ -797,21 +808,21 @@ namespace BlackGui
if (sGui->getWebDataServices() && sGui->getWebDataServices()->getModelsCount() > 0)
{
QMenu *reloadMenu = load->addMenu("Force reload");
if (sims.fs9())
if (sims.fsx())
{
reloadMenu->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
reloadMenu->addAction(CIcons::appModels16(), "FSX models", mapComp, [mapComp]()
{
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::FSX), IAircraftModelLoader::InBackgroundNoCache);
});
}
if (sims.fsx())
if (sims.p3d())
{
reloadMenu->addAction(CIcons::appModels16(), "P3D models", mapComp, [mapComp]()
{
mapComp->ps_requestSimulatorModels(CSimulatorInfo(CSimulatorInfo::P3D), IAircraftModelLoader::InBackgroundNoCache);
});
}
if (sims.p3d())
if (sims.fs9())
{
reloadMenu->addAction(CIcons::appModels16(), "FS9 models", mapComp, [mapComp]()
{
@@ -912,9 +923,6 @@ namespace BlackGui
a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, SLOT(ps_applyDbData()));
a->setData(CLivery().getClassName());
// a = subMenu->addAction(CIcons::appAirlineIcao16(), "Current airline ICAO", mapComp, SLOT(ps_applyDbData()));
// a->setData(CAirlineIcaoCode().getClassName());
menu.addAction(CIcons::databaseTable16(), "Modify model data", mapComp, SLOT(ps_modifyModelDialog()));
}
this->nestedCustomMenu(menu);

View File

@@ -13,7 +13,6 @@
#define BLACKGUI_COMPONENTS_DBMAPPINGCOMPONENT_H
#include "blackcore/data/authenticateduser.h"
#include "blackcore/data/aircraftmodels.h"
#include "blackgui/blackguiexport.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/menudelegate.h"
@@ -23,6 +22,7 @@
#include "blackgui/views/aircraftmodelview.h"
#include "blackmisc/simulation/aircraftmodelloader.h"
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
#include "blackmisc/simulation/data/modelcaches.h"
#include "blackmisc/network/entityflags.h"
#include "blackmisc/statusmessagelist.h"
#include <QFrame>
@@ -52,10 +52,11 @@ namespace BlackGui
//! Must match real tab index
enum TabIndex
{
NoValidTab = -1,
TabStash = 0,
TabOwnModels = 1,
TabVPilot = 2
NoValidTab = -1,
TabStash = 0,
TabOwnModels = 1,
TabOwnModelSet = 2,
TabVPilot = 3
};
//! Constructor
@@ -85,14 +86,20 @@ namespace BlackGui
//! Own (installed) model for given model string
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
//! Own models
BlackMisc::Simulation::CAircraftModelList getOwnModels() const;
//! Own models for simulator
const BlackMisc::Simulation::CSimulatorInfo &getOwnModelsSimulator() const;
//! Number of own models
int getOwnModelsCount() const;
//! Current tab index
TabIndex currentTabIndex() const;
//! Current model view
const BlackGui::Views::CAircraftModelView *currentModelView() const;
//! Current model view
BlackGui::Views::CAircraftModelView *currentModelView();
BlackGui::Views::CAircraftModelView *currentModelView() const;
//! Is stashed view
bool isStashedTab() const;
@@ -142,6 +149,9 @@ namespace BlackGui
//! Request latest (incremental) data from backend
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
//! Tab index has been changed
void tabIndexChanged(int index);
private slots:
//! Load the vPilot rules
void ps_loadVPilotData();
@@ -173,6 +183,9 @@ namespace BlackGui
//! Stash count has been changed
void ps_onStashCountChanged(int count, bool withFilter);
//! Model set count has been changed
void ps_onModelSetCountChanged(int count, bool withFilter);
//! Row has been selected
void ps_onModelRowSelected(const QModelIndex &index);
@@ -212,18 +225,15 @@ namespace BlackGui
//! Open simulator file
void ps_showSimulatorFile();
//! When main GUI application has been started
void ps_deferredInit();
private:
QScopedPointer<Ui::CDbMappingComponent> ui;
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog;
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
BlackMisc::CData<BlackCore::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
BlackMisc::CData<BlackGui::Components::Data::DbMappingComponent> m_lastInteractions {this}; //!< last interactions
QScopedPointer<Ui::CDbMappingComponent> ui;
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog; //!< dialog when modifying models
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
BlackMisc::CData<BlackMisc::Simulation::Data::VPilotAircraftModels> m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged};
BlackMisc::CData<BlackGui::Components::Data::DbMappingComponent> m_lastInteractions {this}; //!< last interactions
bool m_vPilot1stInit = true;
bool m_withVPilot = false;
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model

View File

@@ -66,7 +66,7 @@
<item>
<widget class="QTabWidget" name="tw_ModelsToBeMapped">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tab_StashAircraftModels">
<attribute name="title">
@@ -141,6 +141,38 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_OwnModelSet">
<attribute name="title">
<string>My model set</string>
</attribute>
<layout class="QHBoxLayout" name="hl_OwnModelSet">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CDbOwnModelSetComponent" name="comp_OwnModelSet">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_VPilot">
<attribute name="title">
<string>vPilot rules</string>
@@ -404,6 +436,12 @@
<header>blackgui/components/dbstashcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CDbOwnModelSetComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbownmodelsetcomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -14,6 +14,11 @@ namespace BlackGui
{
namespace Components
{
void CDbMappingComponentAware::setMappingComponent(CDbMappingComponent *component)
{
m_mappingComponent = component;
}
CDbMappingComponentAware::CDbMappingComponentAware(QObject *parent)
{
// if we get a mapping component we use it
@@ -23,5 +28,6 @@ namespace BlackGui
if (!m) { return; }
m_mappingComponent = m;
}
} // ns
} // ns

View File

@@ -26,20 +26,17 @@ namespace BlackGui
{
public:
//! Set the corresponding component
void setMappingComponent(CDbMappingComponent *component) { m_mappingComponent = component; }
virtual void setMappingComponent(CDbMappingComponent *component);
protected:
//! Constructor
CDbMappingComponentAware(QObject *parent);
//! Get the mapping component
const CDbMappingComponent *getMappingComponent() const { return m_mappingComponent; }
//! Get mapping component
CDbMappingComponent *getMappingComponent() { return m_mappingComponent; }
CDbMappingComponent *getMappingComponent() const { return m_mappingComponent; }
private :
CDbMappingComponent *m_mappingComponent = nullptr;
CDbMappingComponent *m_mappingComponent = nullptr; //!< reference to component
};
} // ns
} // ns

View File

@@ -0,0 +1,115 @@
/* Copyright (C) 2016
* 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 "dbownmodelsetcomponent.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackgui/models/aircrafticaolistmodel.h"
#include "dbmappingcomponent.h"
#include "dbownmodelsetdialog.h"
#include "ui_dbownmodelsetcomponent.h"
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
using namespace BlackGui::Models;
using namespace BlackGui::Views;
namespace BlackGui
{
namespace Components
{
CDbOwnModelSetComponent::CDbOwnModelSetComponent(QWidget *parent) :
QFrame(parent),
CDbMappingComponentAware(parent),
ui(new Ui::CDbOwnModelSetComponent)
{
ui->setupUi(this);
ui->tvp_OwnModelSet->setAircraftModelMode(CAircraftModelListModel::OwnSimulatorModelMapping);
ui->tvp_OwnModelSet->menuRemoveItems(CAircraftModelView::MenuDisplayAutomaticallyAndRefresh | CAircraftModelView::MenuStashing | CAircraftModelView::MenuBackend | CAircraftModelView::MenuRefresh);
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows);
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
}
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
{
// void
}
Views::CAircraftModelView *CDbOwnModelSetComponent::getView() const
{
return ui->tvp_OwnModelSet;
}
void CDbOwnModelSetComponent::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
{
this->ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
this->ui->pb_SaveAsSetForSimulator->setText("save for " + simulator.toQString());
this->ui->pb_SaveAsSetForSimulator->setEnabled(!models.isEmpty());
this->m_simulator = simulator;
}
void CDbOwnModelSetComponent::setMappingComponent(CDbMappingComponent *component)
{
CDbMappingComponentAware::setMappingComponent(component);
if (component)
{
connect(this->getMappingComponent(), &CDbMappingComponent::tabIndexChanged, this, &CDbOwnModelSetComponent::ps_tabChanged);
}
}
void CDbOwnModelSetComponent::ps_tabChanged(int index)
{
CDbMappingComponent::TabIndex ti = static_cast<CDbMappingComponent::TabIndex>(index);
if (ti == CDbMappingComponent::TabOwnModelSet)
{
// myself
this->getMappingComponent()->resizeForSelect();
}
else
{
// others
}
}
void CDbOwnModelSetComponent::ps_buttonClicked()
{
const QObject *sender = QObject::sender();
if (sender == ui->pb_CreateNewSet)
{
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<QDialog::DialogCode>(
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, CStatusMessage::SeverityError, "No model data"));
this->getMappingComponent()->showOverlayMessage(m);
}
}
else if (sender == ui->pb_LoadExistingSet)
{
this->ui->tvp_OwnModelSet->showFileLoadDialog();
}
}
} // ns
} // ns

View File

@@ -0,0 +1,69 @@
/* Copyright (C) 2016
* 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.
*/
#ifndef BLACKGUI_COMPONENTS_DBOWNMODELSETCOMPONENT_H
#define BLACKGUI_COMPONENTS_DBOWNMODELSETCOMPONENT_H
#include "blackmisc/simulation/aircraftmodellist.h"
#include "dbmappingcomponentaware.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CDbOwnModelSetComponent; }
namespace BlackGui
{
namespace Views { class CAircraftModelView; }
namespace Components
{
class CDbOwnModelSetDialog;
/*!
* Handling of the own model set
*/
class CDbOwnModelSetComponent :
public QFrame,
public CDbMappingComponentAware
{
Q_OBJECT
public:
//! Constructor
explicit CDbOwnModelSetComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CDbOwnModelSetComponent();
//! Corresponding view
Views::CAircraftModelView *getView() const;
//! Set the model set
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! \copydoc CDbMappingComponentAware::setMappingComponent
virtual void setMappingComponent(CDbMappingComponent *component) override;
private slots:
//! Tab has been changed
void ps_tabChanged(int index);
//! Button was clicked
void ps_buttonClicked();
private:
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
QScopedPointer<CDbOwnModelSetDialog> m_modelSetDialog;
BlackMisc::Simulation::CSimulatorInfo m_simulator;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbOwnModelSetComponent</class>
<widget class="QFrame" name="CDbOwnModelSetComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_DbOwnModelSetComponent">
<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="BlackGui::Views::CAircraftModelView" name="tvp_OwnModelSet">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_OwnModelSetBottom">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="hl_OwnModelSetButtons">
<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>
<spacer name="hs_Buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_CreateNewSet">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>create a new set</string>
</property>
<property name="text">
<string>new set</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_LoadExistingSet">
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>load an existing set</string>
</property>
<property name="text">
<string>load</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SaveAsSetForSimulator">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>125</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>save</string>
</property>
</widget>
</item>
</layout>
</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>

View File

@@ -0,0 +1,91 @@
/* Copyright (C) 2016
* 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 "dbownmodelsetdialog.h"
#include "ui_dbownmodelsetdialog.h"
#include "blackgui/components/dbmappingcomponent.h"
#include "blackcore/modelsetbuilder.h"
#include "blackmisc/simulation/distributorlist.h"
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
using namespace BlackCore;
namespace BlackGui
{
namespace Components
{
const CLogCategoryList &CDbOwnModelSetDialog::getLogCategories()
{
static const CLogCategoryList cats({ CLogCategory("swift.ownmodelset"), CLogCategory::guiComponent()});
return cats;
}
CDbOwnModelSetDialog::CDbOwnModelSetDialog(QWidget *parent) :
QDialog(parent),
CDbMappingComponentAware(parent),
ui(new Ui::CDbOwnModelSetDialog)
{
ui->setupUi(this);
connect(ui->pb_Cancel, &QPushButton::clicked, this, &CDbOwnModelSetDialog::ps_buttonClicked);
connect(ui->pb_Ok, &QPushButton::clicked, this, &CDbOwnModelSetDialog::ps_buttonClicked);
}
CDbOwnModelSetDialog::~CDbOwnModelSetDialog()
{
// void
}
void CDbOwnModelSetDialog::reloadData()
{
this->ui->form_OwnModelSet->reloadData();
}
int CDbOwnModelSetDialog::exec()
{
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
this->setWindowTitle("Create model set for " + this->m_simulatorInfo.toQString(true));
return QDialog::exec();
}
void CDbOwnModelSetDialog::ps_buttonClicked()
{
const QObject *sender = QObject::sender();
if (sender == ui->pb_Cancel)
{
this->reject();
}
else if (sender == ui->pb_Ok)
{
this->m_modelSet = this->buildSet();
this->accept();
}
}
CAircraftModelList CDbOwnModelSetDialog::buildSet()
{
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
const bool selectedProviders = this->ui->form_OwnModelSet->selectedDistributors();
const bool dbDataOnly = this->ui->form_OwnModelSet->dbDataOnly();
const bool dbIcaoOnly = this->ui->form_OwnModelSet->dbIcaoCodesOnly();
const CAircraftModelList models = this->getMappingComponent()->getOwnModels();
this->m_simulatorInfo = this->getMappingComponent()->getOwnModelsSimulator();
const CDistributorList distributors = selectedProviders ?
this->ui->form_OwnModelSet->getSelectedDistributors() :
CDistributorList();
const CModelSetBuilder builder(this);
CModelSetBuilder::Builder options = selectedProviders ? CModelSetBuilder::FilterDistributos : CModelSetBuilder::NoOptions;
if (dbDataOnly) { options |= CModelSetBuilder::OnlyDbData; }
if (dbIcaoOnly) { options |= CModelSetBuilder::OnlyDbIcaoCodes; }
return builder.buildModelSet(models, options, distributors);
}
} // ns
} // ns

View File

@@ -0,0 +1,74 @@
/* Copyright (C) 2016
* 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_DBOWNMODELSETDIALOG_H
#define BLACKGUI_COMPONENTS_DBOWNMODELSETDIALOG_H
#include <QDialog>
#include <QScopedPointer>
#include "blackmisc/logcategorylist.h"
#include "blackmisc/simulation/aircraftmodellist.h"
#include "blackgui/components/dbmappingcomponentaware.h"
namespace Ui { class CDbOwnModelSetDialog; }
namespace BlackGui
{
namespace Components
{
/*!
* Dialog to create new model set
*/
class CDbOwnModelSetDialog :
public QDialog,
public CDbMappingComponentAware
{
Q_OBJECT
public:
//! Categories
static const BlackMisc::CLogCategoryList &getLogCategories();
//! Constructor
explicit CDbOwnModelSetDialog(QWidget *parent = nullptr);
//! Destructor
virtual ~CDbOwnModelSetDialog();
//! Last build set
const BlackMisc::Simulation::CAircraftModelList &getModelSet() const { return m_modelSet; }
//! Simulator info
const BlackMisc::Simulation::CSimulatorInfo &getSimulatorInfo() const { return m_simulatorInfo; }
//! Reload data
void reloadData();
//! Exec and display simulator
virtual int exec() override;
private slots:
//! Button clicked
void ps_buttonClicked();
private:
QScopedPointer<Ui::CDbOwnModelSetDialog> ui;
BlackMisc::Simulation::CAircraftModelList m_modelSet;
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo;
//! Build the set
BlackMisc::Simulation::CAircraftModelList buildSet();
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CDbOwnModelSetDialog</class>
<widget class="QDialog" name="CDbOwnModelSetDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Create a model set</string>
</property>
<layout class="QVBoxLayout" name="vl_OwnModelSetDialog">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<widget class="BlackGui::Editors::COwnModelSetForm" name="form_OwnModelSet">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="wi_Buttons" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="hs_Buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_Cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Editors::COwnModelSetForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/ownmodelsetform.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -0,0 +1,67 @@
/* Copyright (C) 2016
* 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 "ownmodelsetform.h"
#include "ui_ownmodelsetform.h"
#include "blackgui/models/distributorlistmodel.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/simulation/distributorlist.h"
using namespace BlackMisc::Simulation;
using namespace BlackGui::Models;
namespace BlackGui
{
namespace Editors
{
COwnModelSetForm::COwnModelSetForm(QWidget *parent) :
QFrame(parent),
ui(new Ui::COwnModelSetForm)
{
ui->setupUi(this);
this->ui->tvp_Distributors->setDistributorMode(CDistributorListModel::Minimal);
}
COwnModelSetForm::~COwnModelSetForm()
{
// void
}
void COwnModelSetForm::reloadData()
{
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web data services");
const CDistributorList distributors(sGui->getWebDataServices()->getDistributors());
if (!distributors.isEmpty())
{
this->ui->tvp_Distributors->updateContainerMaybeAsync(distributors);
}
}
bool COwnModelSetForm::selectedDistributors() const
{
return this->ui->rb_SelectedDistributors->isChecked();
}
bool COwnModelSetForm::dbDataOnly() const
{
return this->ui->rb_DbDataOnly->isChecked();
}
bool COwnModelSetForm::dbIcaoCodesOnly() const
{
return this->ui->rb_DbIcaoCodesOnly->isChecked();
}
CDistributorList COwnModelSetForm::getSelectedDistributors() const
{
return ui->tvp_Distributors->selectedObjects();
}
} // ns
} // ns

View File

@@ -0,0 +1,60 @@
/* Copyright (C) 2016
* 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_EDITORS_OWNMODELSETFORM_H
#define BLACKGUI_EDITORS_OWNMODELSETFORM_H
#include "blackmisc/simulation/distributorlist.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class COwnModelSetForm; }
namespace BlackGui
{
namespace Editors
{
/*!
* Selection for own model set
*/
class COwnModelSetForm : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit COwnModelSetForm(QWidget *parent = nullptr);
//! Destructor
~COwnModelSetForm();
//! Reload data
void reloadData();
//! Selected providers?
bool selectedDistributors() const;
//! Get selected providers
BlackMisc::Simulation::CDistributorList getSelectedDistributors() const;
//! Only DB data
bool dbDataOnly() const;
//! DB ICAO codes
bool dbIcaoCodesOnly() const;
private:
QScopedPointer<Ui::COwnModelSetForm> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>COwnModelSetForm</class>
<widget class="QFrame" name="COwnModelSetForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_OwnModelSetForm">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
<layout class="QGridLayout" name="gq_OwnModelSetForm">
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="2">
<widget class="QRadioButton" name="rb_DbIcaoCodesOnly">
<property name="toolTip">
<string>Model has ICAO code known in DB</string>
</property>
<property name="text">
<string>DB ICAO data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_SourceSet</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_Providers">
<property name="text">
<string>Distributors:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QRadioButton" name="rb_WithIcaoData">
<property name="toolTip">
<string>Model has ICAO code</string>
</property>
<property name="text">
<string> ICAO data</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_SourceSet</string>
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_SelectSourceSet">
<property name="text">
<string>Source set:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="rb_SelectedDistributors">
<property name="text">
<string>selected</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Distributors</string>
</attribute>
</widget>
</item>
<item row="0" column="1">
<widget class="QRadioButton" name="rb_DbDataOnly">
<property name="toolTip">
<string>Own models for which DB data are available</string>
</property>
<property name="text">
<string>DB data only</string>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_SourceSet</string>
</attribute>
</widget>
</item>
<item row="1" column="2">
<widget class="QRadioButton" name="rb_DefaultDistributors">
<property name="text">
<string>default</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">bg_Distributors</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<widget class="BlackGui::Views::CDistributorView" name="tvp_Distributors">
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Views::CDistributorView</class>
<extends>QTableView</extends>
<header>blackgui/views/distributorview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="bg_Distributors"/>
<buttongroup name="bg_SourceSet"/>
</buttongroups>
</ui>