refs #768, model form as combined form of livery/distributor and aircraft ICAO

This commit is contained in:
Klaus Basan
2016-10-17 03:16:09 +02:00
parent 50546f325a
commit a3be42f0c3
5 changed files with 421 additions and 154 deletions

View File

@@ -94,7 +94,7 @@ namespace BlackGui
ui->comp_StashAircraft->view()->setCustomMenu(new CModelStashToolsMenu(this, false));
// connects
connect(ui->editor_Model, &CModelMappingForm::requestStash, this, &CDbMappingComponent::ps_stashCurrentModel);
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::ps_stashCurrentModel);
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::modelDataChanged, this, &CDbMappingComponent::ps_onOwnModelsChanged);
@@ -121,9 +121,7 @@ namespace BlackGui
this->ps_onOwnModelsChanged(ui->comp_OwnAircraftModels->view()->rowCount(), ui->comp_OwnAircraftModels->view()->hasFilter());
// how to display forms
ui->editor_AircraftIcao->setSelectOnly();
ui->editor_Distributor->setSelectOnly();
ui->editor_Livery->setSelectOnly();
ui->editor_AircraftModel->setSelectOnly();
ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
@@ -271,7 +269,7 @@ namespace BlackGui
void CDbMappingComponent::updateEditorsWhenApplicable()
{
const CAircraftModel currentEditorModel(ui->editor_Model->getValue());
const CAircraftModel currentEditorModel(ui->editor_ModelMapping->getValue());
if (!currentEditorModel.hasModelString()) { return; } // no related model
const QString modelString(currentEditorModel.getModelString());
const CAircraftModel currentStashedModel(ui->comp_StashAircraft->getStashedModel(modelString));
@@ -283,19 +281,19 @@ namespace BlackGui
const CLivery stashedLivery(currentStashedModel.getLivery());
if (stashedLivery.hasValidDbKey())
{
if (ui->editor_Livery->setValue(stashedLivery)) { updated = true; }
if (ui->editor_AircraftModel->setLivery(stashedLivery)) { updated = true; }
}
const CDistributor stashedDistributor(currentStashedModel.getDistributor());
if (stashedDistributor.hasValidDbKey())
{
if (ui->editor_Distributor->setValue(stashedDistributor)) { updated = true; }
if (ui->editor_AircraftModel->setDistributor(stashedDistributor)) { updated = true; }
}
const CAircraftIcaoCode stashedIcaoCode(currentStashedModel.getAircraftIcaoCode());
if (stashedIcaoCode.hasValidDbKey())
{
if (ui->editor_AircraftIcao->setValue(stashedIcaoCode)) { updated = true; }
if (ui->editor_AircraftModel->setAircraftIcao(stashedIcaoCode)) { updated = true; }
}
if (updated)
@@ -346,12 +344,10 @@ namespace BlackGui
CStatusMessageList CDbMappingComponent::validateCurrentModel(bool withNestedForms) const
{
CStatusMessageList msgs(ui->editor_Model->validate(!withNestedForms));
CStatusMessageList msgs(ui->editor_ModelMapping->validate(!withNestedForms));
if (withNestedForms)
{
msgs.push_back(ui->editor_AircraftIcao->validate());
msgs.push_back(ui->editor_Livery->validate(withNestedForms));
msgs.push_back(ui->editor_Distributor->validate());
msgs.push_back(ui->editor_AircraftModel->validate(withNestedForms));
}
return msgs;
}
@@ -416,42 +412,42 @@ namespace BlackGui
void CDbMappingComponent::ps_applyFormLiveryData()
{
if (ui->comp_StashAircraft->view()->selectedRowCount() < 1) { return; }
const CStatusMessageList msgs = ui->editor_Livery->validate(true);
const CStatusMessageList msgs = ui->editor_AircraftModel->validateLivery(true);
if (msgs.hasErrorMessages())
{
this->showOverlayMessages(msgs);
}
else
{
ui->comp_StashAircraft->applyToSelected(ui->editor_Livery->getValue());
ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getLivery());
}
}
void CDbMappingComponent::ps_applyFormAircraftIcaoData()
{
if (ui->comp_StashAircraft->view()->selectedRowCount() < 1) { return; }
const CStatusMessageList msgs = ui->editor_AircraftIcao->validate(true);
const CStatusMessageList msgs = ui->editor_AircraftModel->validateAircraftIcao(true);
if (msgs.hasErrorMessages())
{
this->showOverlayMessages(msgs);
}
else
{
ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftIcao->getValue());
ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getAircraftIcao());
}
}
void CDbMappingComponent::ps_applyFormDistributorData()
{
if (ui->comp_StashAircraft->view()->selectedRowCount() < 1) { return; }
const CStatusMessageList msgs = ui->editor_Distributor->validate(true);
const CStatusMessageList msgs = ui->editor_AircraftModel->validateDistributor(true);
if (msgs.hasErrorMessages())
{
this->showOverlayMessages(msgs);
}
else
{
ui->comp_StashAircraft->applyToSelected(ui->editor_Distributor->getValue());
ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getDistributor());
}
}
@@ -590,13 +586,13 @@ namespace BlackGui
case CDbMappingComponent::TabOwnModelSet:
{
ui->frp_Editors->setVisible(true);
ui->editor_Model->setVisible(true);
ui->editor_ModelMapping->setVisible(true);
this->resizeForSelect();
}
break;
case CDbMappingComponent::TabModelMatcher:
{
ui->editor_Model->setVisible(false);
ui->editor_ModelMapping->setVisible(false);
ui->frp_Editors->setVisible(false);
this->resizeForSelect();
}
@@ -609,7 +605,7 @@ namespace BlackGui
default:
{
ui->frp_Editors->setVisible(true);
ui->editor_Model->setVisible(true);
ui->editor_ModelMapping->setVisible(true);
}
break;
}
@@ -754,32 +750,32 @@ namespace BlackGui
const CDistributor distributor(dbModel ? model.getDistributor() : sGui->getWebDataServices()->smartDistributorSelector(model.getDistributor()));
// set model part
ui->editor_Model->setValue(model);
ui->editor_ModelMapping->setValue(model);
// if found, then set in editor
if (livery.hasValidDbKey())
{
ui->editor_Livery->setValue(livery);
ui->editor_AircraftModel->setLivery(livery);
}
else
{
ui->editor_Livery->clear();
ui->editor_AircraftModel->clearLivery();
}
if (aircraftIcao.hasValidDbKey())
{
ui->editor_AircraftIcao->setValue(aircraftIcao);
ui->editor_AircraftModel->setAircraftIcao(aircraftIcao);
}
else
{
ui->editor_AircraftIcao->clear();
ui->editor_AircraftModel->clearAircraftIcao();
}
if (distributor.hasValidDbKey())
{
ui->editor_Distributor->setValue(distributor);
ui->editor_AircraftModel->setDistributor(distributor);
}
else
{
ui->editor_Distributor->clear();
ui->editor_AircraftModel->clearDistributor();
}
// request filtering
@@ -793,10 +789,10 @@ namespace BlackGui
CAircraftModel CDbMappingComponent::getEditorAircraftModel() const
{
CAircraftModel model(ui->editor_Model->getValue());
model.setDistributor(ui->editor_Distributor->getValue());
model.setAircraftIcaoCode(ui->editor_AircraftIcao->getValue());
model.setLivery(ui->editor_Livery->getValue());
CAircraftModel model(ui->editor_ModelMapping->getValue());
model.setDistributor(ui->editor_AircraftModel->getDistributor());
model.setAircraftIcaoCode(ui->editor_AircraftModel->getAircraftIcao());
model.setLivery(ui->editor_AircraftModel->getLivery());
return model;
}

View File

@@ -246,7 +246,7 @@
</widget>
</item>
<item>
<widget class="BlackGui::Editors::CModelMappingForm" name="editor_Model">
<widget class="BlackGui::Editors::CModelMappingForm" name="editor_ModelMapping">
<property name="minimumSize">
<size>
<width>0</width>
@@ -297,118 +297,27 @@
<height>450</height>
</size>
</property>
<layout class="QHBoxLayout" name="hl_EditorsScrollArea">
<property name="spacing">
<number>4</number>
</property>
<layout class="QVBoxLayout" name="vl_EditorSctollArea">
<property name="leftMargin">
<number>2</number>
<number>0</number>
</property>
<property name="topMargin">
<number>2</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_EditorsLeft">
<layout class="QVBoxLayout" name="vl_EditorsLeft">
<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::Editors::CDistributorForm" name="editor_Distributor">
<property name="minimumSize">
<size>
<width>100</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Editors::CAircraftIcaoForm" name="editor_AircraftIcao">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_LeftEmpty">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_EditorsRight">
<layout class="QVBoxLayout" name="vl_EditorRight">
<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::Editors::CLiveryForm" name="editor_Livery">
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_RightEmpty">
<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>
</layout>
<widget class="BlackGui::Editors::CAircraftModelForm" name="editor_AircraftModel">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
@@ -422,29 +331,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Editors::CAircraftModelForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/aircraftmodelform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Views::CAircraftModelView</class>
<extends>QTableView</extends>
<header>blackgui/views/aircraftmodelview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CAircraftIcaoForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/aircrafticaoform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CLiveryForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/liveryform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CDistributorForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/distributorform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CModelMappingForm</class>
<extends>QFrame</extends>

View File

@@ -0,0 +1,120 @@
/* 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 "aircraftmodelform.h"
#include "ui_aircraftmodelform.h"
using namespace BlackMisc;
namespace BlackGui
{
namespace Editors
{
CAircraftModelForm::CAircraftModelForm(QWidget *parent) :
CForm(parent),
ui(new Ui::CAircraftModelForm)
{
ui->setupUi(this);
this->setFocusProxy(ui->editor_AircraftIcao);
}
CAircraftModelForm::~CAircraftModelForm()
{ }
void CAircraftModelForm::setReadOnly(bool readOnly)
{
ui->editor_AircraftIcao->setReadOnly(readOnly);
ui->editor_Distributor->setReadOnly(readOnly);
ui->editor_Livery->setReadOnly(readOnly);
}
CStatusMessageList CAircraftModelForm::validate(bool withNestedForms) const
{
CStatusMessageList msgs;
msgs.push_back(ui->editor_AircraftIcao->validate(withNestedForms));
msgs.push_back(ui->editor_Distributor->validate(withNestedForms));
msgs.push_back(ui->editor_Livery->validate(withNestedForms));
return msgs;
}
CStatusMessageList CAircraftModelForm::validateLivery(bool withNestedForms) const
{
return ui->editor_Livery->validate(withNestedForms);
}
CStatusMessageList CAircraftModelForm::validateAircraftIcao(bool withNestedForms) const
{
return ui->editor_AircraftIcao->validate(withNestedForms);
}
CStatusMessageList CAircraftModelForm::validateDistributor(bool withNestedForms) const
{
return ui->editor_Distributor->validate(withNestedForms);
}
Aviation::CLivery CAircraftModelForm::getLivery() const
{
return ui->editor_Livery->getValue();
}
Aviation::CAircraftIcaoCode CAircraftModelForm::getAircraftIcao() const
{
return ui->editor_AircraftIcao->getValue();
}
Simulation::CDistributor CAircraftModelForm::getDistributor() const
{
return ui->editor_Distributor->getValue();
}
void CAircraftModelForm::allowDrop(bool allowDrop)
{
ui->editor_AircraftIcao->allowDrop(allowDrop);
ui->editor_Distributor->allowDrop(allowDrop);
ui->editor_Livery->allowDrop(allowDrop);
}
bool CAircraftModelForm::setLivery(const BlackMisc::Aviation::CLivery &livery)
{
return ui->editor_Livery->setValue(livery);
}
bool CAircraftModelForm::setAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao)
{
return ui->editor_AircraftIcao->setValue(icao);
}
bool CAircraftModelForm::setDistributor(const BlackMisc::Simulation::CDistributor &distributor)
{
return ui->editor_Distributor->setValue(distributor);
}
void CAircraftModelForm::clear()
{
this->clearLivery();
this->clearAircraftIcao();
this->clearDistributor();
}
void CAircraftModelForm::clearLivery()
{
ui->editor_Livery->clear();
}
void CAircraftModelForm::clearAircraftIcao()
{
ui->editor_AircraftIcao->clear();
}
void CAircraftModelForm::clearDistributor()
{
ui->editor_Distributor->clear();
}
} // ns
} // ns

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.
*/
//! \file
#ifndef BLACKGUI_EDITORS_AIRCRAFTMODELFORM_H
#define BLACKGUI_EDITORS_AIRCRAFTMODELFORM_H
#include "form.h"
#include <QFrame>
namespace Ui { class CAircraftModelForm; }
namespace BlackGui
{
namespace Editors
{
/**
* Combined form of Livery, ICAOs, distributor
*/
class CAircraftModelForm : public CForm
{
Q_OBJECT
public:
//! Constructor
explicit CAircraftModelForm(QWidget *parent = nullptr);
//! Destructor
~CAircraftModelForm();
//! Allow to drop data
void allowDrop(bool allowDrop);
//! Set as read only
virtual void setReadOnly(bool readOnly) override;
//! \copydoc BlackGui::Editors::CForm::validate
virtual BlackMisc::CStatusMessageList validate(bool withNestedForms = true) const override;
//! \copydoc BlackGui::Editors::CForm::validate
virtual BlackMisc::CStatusMessageList validateLivery(bool withNestedForms = true) const;
//! \copydoc BlackGui::Editors::CForm::validate
virtual BlackMisc::CStatusMessageList validateAircraftIcao(bool withNestedForms = true) const;
//! \copydoc BlackGui::Editors::CForm::validate
virtual BlackMisc::CStatusMessageList validateDistributor(bool withNestedForms = true) const;
//! Livery
BlackMisc::Aviation::CLivery getLivery() const;
//! Aircraft ICAO
BlackMisc::Aviation::CAircraftIcaoCode getAircraftIcao() const;
//! Distributor
BlackMisc::Simulation::CDistributor getDistributor() const;
//! Livery
bool setLivery(const BlackMisc::Aviation::CLivery &livery);
//! Aircraft
bool setAircraftIcao(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
//! Distributor
bool setDistributor(const BlackMisc::Simulation::CDistributor &distributor);
//! Clear entire form
void clear();
//! \copydoc BlackGui::Editors::CLiveryForm::clear
void clearLivery();
//! \copydoc BlackGui::Editors::CAircraftIcaoForm::clear
void clearAircraftIcao();
//! \copydoc BlackGui::Editors::CDistributorForm::clear
void clearDistributor();
private:
QScopedPointer<Ui::CAircraftModelForm> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAircraftModelForm</class>
<widget class="QFrame" name="CAircraftModelForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QHBoxLayout" name="vl_AircraftModelForm">
<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="QFrame" name="fr_AircraftModelLeft">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" name="vl_AircraftModelFormLeft">
<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::Editors::CDistributorForm" name="editor_Distributor">
<property name="minimumSize">
<size>
<width>100</width>
<height>150</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="BlackGui::Editors::CAircraftIcaoForm" name="editor_AircraftIcao">
<property name="minimumSize">
<size>
<width>0</width>
<height>150</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_LeftEmpty">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_AircraftModelRight">
<layout class="QVBoxLayout" name="vl_AircraftModelFormRight">
<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::Editors::CLiveryForm" name="editor_Livery">
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_RightEmpty">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Editors::CAircraftIcaoForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/aircrafticaoform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CLiveryForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/liveryform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CDistributorForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/distributorform.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>