mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #587, form/component to modify multiple model properties
This commit is contained in:
43
src/blackgui/components/dbmodelmappingmodifycomponent.cpp
Normal file
43
src/blackgui/components/dbmodelmappingmodifycomponent.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* 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 "dbmodelmappingmodifycomponent.h"
|
||||
#include "ui_dbmodelmappingmodifycomponent.h"
|
||||
#include "dbmappingcomponent.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CDbModelMappingModifyComponent::CDbModelMappingModifyComponent(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
CDbMappingComponentAware(parent),
|
||||
ui(new Ui::CDbModelMappingModifyComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CDbModelMappingModifyComponent::~CDbModelMappingModifyComponent()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
CPropertyIndexVariantMap CDbModelMappingModifyComponent::getValues() const
|
||||
{
|
||||
return (ui->editor_ModelMappingModify->getValues());
|
||||
}
|
||||
|
||||
void CDbModelMappingModifyComponent::setValue(const Simulation::CAircraftModel &model)
|
||||
{
|
||||
this->ui->editor_ModelMappingModify->setValue(model);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
55
src/blackgui/components/dbmodelmappingmodifycomponent.h
Normal file
55
src/blackgui/components/dbmodelmappingmodifycomponent.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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_DBMODELMAPPINGMODIFYCOMPONENT_H
|
||||
#define BLACKGUI_COMPONENTS_DBMODELMAPPINGMODIFYCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "dbmappingcomponentaware.h"
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CDbModelMappingModifyComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
/*!
|
||||
* Modify model fields as dialog
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbModelMappingModifyComponent :
|
||||
public QDialog,
|
||||
public CDbMappingComponentAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CDbModelMappingModifyComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CDbModelMappingModifyComponent();
|
||||
|
||||
//! Get the values
|
||||
BlackMisc::CPropertyIndexVariantMap getValues() const;
|
||||
|
||||
//! Set default values
|
||||
void setValue(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDbModelMappingModifyComponent> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
#endif // guard
|
||||
107
src/blackgui/components/dbmodelmappingmodifycomponent.ui
Normal file
107
src/blackgui/components/dbmodelmappingmodifycomponent.ui
Normal file
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDbModelMappingModifyComponent</class>
|
||||
<widget class="QDialog" name="CDbModelMappingModifyComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>320</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>320</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Model modify form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BlackGui::Editors::CModelMappingModifyForm" name="editor_ModelMappingModify">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>75</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs_ModelMappingModify">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_ModelMappingModiyForm">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CModelMappingModifyForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/modelmappingmodifyform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_ModelMappingModiyForm</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CDbModelMappingModifyComponent</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_ModelMappingModiyForm</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CDbModelMappingModifyComponent</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
99
src/blackgui/editors/modelmappingmodifyform.cpp
Normal file
99
src/blackgui/editors/modelmappingmodifyform.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/* 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 "modelmappingmodifyform.h"
|
||||
#include "ui_modelmappingmodifyform.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CModelMappingModifyForm::CModelMappingModifyForm(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CModelMappingModifyForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->le_Description, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
||||
connect(ui->le_Name, &QLineEdit::returnPressed, this, &CModelMappingModifyForm::ps_returnPressed);
|
||||
connect(ui->frp_IncludeSelector, &CModelModeSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
connect(ui->frp_SimulatorSelector, &CSimulatorSelector::changed, this, &CModelMappingModifyForm::ps_changed);
|
||||
}
|
||||
|
||||
CModelMappingModifyForm::~CModelMappingModifyForm()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
CPropertyIndexVariantMap CModelMappingModifyForm::getValues() const
|
||||
{
|
||||
CPropertyIndexVariantMap vm;
|
||||
if (ui->cb_Name->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexName, ui->le_Name->text().trimmed());
|
||||
}
|
||||
|
||||
if (ui->cb_Description->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexDescription, ui->le_Description->text().trimmed());
|
||||
}
|
||||
|
||||
if (ui->cb_Simulator->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexSimulatorInfo, ui->frp_SimulatorSelector->getValue());
|
||||
}
|
||||
|
||||
if (ui->cb_Simulator->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexSimulatorInfo, ui->frp_SimulatorSelector->getValue());
|
||||
}
|
||||
|
||||
if (ui->cb_Mode->isChecked())
|
||||
{
|
||||
vm.addValue(CAircraftModel::IndexModelMode, ui->frp_IncludeSelector->getMode());
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::setValue(const CAircraftModel &model)
|
||||
{
|
||||
this->ui->le_Description->setText(model.getDescription());
|
||||
this->ui->le_Name->setText(model.getName());
|
||||
this->ui->frp_SimulatorSelector->setValue(model.getSimulatorInfo());
|
||||
this->ui->frp_IncludeSelector->setValue(model);
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::ps_returnPressed()
|
||||
{
|
||||
QCheckBox *cb = widgetToCheckbox(sender());
|
||||
if (!cb) { return; }
|
||||
cb->setChecked(true);
|
||||
}
|
||||
|
||||
void CModelMappingModifyForm::ps_changed()
|
||||
{
|
||||
QCheckBox *cb = widgetToCheckbox(sender());
|
||||
if (!cb) { return; }
|
||||
cb->setChecked(true);
|
||||
}
|
||||
|
||||
QCheckBox *CModelMappingModifyForm::widgetToCheckbox(QObject *widget) const
|
||||
{
|
||||
if (!widget) { return nullptr; }
|
||||
if (widget == ui->le_Description) { return ui->cb_Description; }
|
||||
if (widget == ui->le_Name) { return ui->cb_Name; }
|
||||
if (widget == ui->frp_IncludeSelector) { return ui->cb_Mode; }
|
||||
if (widget == ui->frp_SimulatorSelector) { return ui->cb_Simulator; }
|
||||
return nullptr;
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
64
src/blackgui/editors/modelmappingmodifyform.h
Normal file
64
src/blackgui/editors/modelmappingmodifyform.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* 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_MODELMAPPINGMODIFYFORM_H
|
||||
#define BLACKGUI_EDITORS_MODELMAPPINGMODIFYFORM_H
|
||||
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include <QCheckBox>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui { class CModelMappingModifyForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Allows to modify individual fields of the model form
|
||||
*/
|
||||
class CModelMappingModifyForm : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CModelMappingModifyForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CModelMappingModifyForm();
|
||||
|
||||
//! Get the values
|
||||
BlackMisc::CPropertyIndexVariantMap getValues() const;
|
||||
|
||||
//! Set value
|
||||
void setValue(const BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
private slots:
|
||||
//! Return pressed
|
||||
void ps_returnPressed();
|
||||
|
||||
//! Data changed
|
||||
void ps_changed();
|
||||
|
||||
private:
|
||||
//! Checkbox from its corresponding widgte
|
||||
QCheckBox *widgetToCheckbox(QObject *widget) const;
|
||||
|
||||
QScopedPointer<Ui::CModelMappingModifyForm> ui;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
146
src/blackgui/editors/modelmappingmodifyform.ui
Normal file
146
src/blackgui/editors/modelmappingmodifyform.ui
Normal file
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CModelMappingModifyForm</class>
|
||||
<widget class="QFrame" name="CModelMappingModifyForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>237</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Modify model data</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_ModelMappingModifyForm">
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="cb_Simulator">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="BlackGui::CSimulatorSelector" name="frp_SimulatorSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Description</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="cb_Name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="lbl_Name">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Name</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_Name">
|
||||
<property name="placeholderText">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_Description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="lbl_Simulator">
|
||||
<property name="text">
|
||||
<string>Simulator:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="maxLength">
|
||||
<number>256</number>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Model description</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="lbl_Mode">
|
||||
<property name="text">
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="BlackGui::CModelModeSelector" name="frp_IncludeSelector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="cb_Mode">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::CSimulatorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/simulatorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CModelModeSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/modelmodeselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user