diff --git a/src/blackgui/components/dbmodelmappingmodifycomponent.cpp b/src/blackgui/components/dbmodelmappingmodifycomponent.cpp new file mode 100644 index 000000000..af4eba53c --- /dev/null +++ b/src/blackgui/components/dbmodelmappingmodifycomponent.cpp @@ -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 diff --git a/src/blackgui/components/dbmodelmappingmodifycomponent.h b/src/blackgui/components/dbmodelmappingmodifycomponent.h new file mode 100644 index 000000000..9b041c1a6 --- /dev/null +++ b/src/blackgui/components/dbmodelmappingmodifycomponent.h @@ -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 +#include + +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; + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/dbmodelmappingmodifycomponent.ui b/src/blackgui/components/dbmodelmappingmodifycomponent.ui new file mode 100644 index 000000000..8dc44ea1b --- /dev/null +++ b/src/blackgui/components/dbmodelmappingmodifycomponent.ui @@ -0,0 +1,107 @@ + + + CDbModelMappingModifyComponent + + + + 0 + 0 + 320 + 200 + + + + + 320 + 200 + + + + Model modify form + + + + + + + 0 + 75 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + BlackGui::Editors::CModelMappingModifyForm + QFrame +
blackgui/editors/modelmappingmodifyform.h
+ 1 +
+
+ + + + bb_ModelMappingModiyForm + accepted() + CDbModelMappingModifyComponent + accept() + + + 248 + 254 + + + 157 + 274 + + + + + bb_ModelMappingModiyForm + rejected() + CDbModelMappingModifyComponent + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/blackgui/editors/modelmappingmodifyform.cpp b/src/blackgui/editors/modelmappingmodifyform.cpp new file mode 100644 index 000000000..0c1a4f3a3 --- /dev/null +++ b/src/blackgui/editors/modelmappingmodifyform.cpp @@ -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 diff --git a/src/blackgui/editors/modelmappingmodifyform.h b/src/blackgui/editors/modelmappingmodifyform.h new file mode 100644 index 000000000..ac540cdc9 --- /dev/null +++ b/src/blackgui/editors/modelmappingmodifyform.h @@ -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 +#include +#include +#include + +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; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/editors/modelmappingmodifyform.ui b/src/blackgui/editors/modelmappingmodifyform.ui new file mode 100644 index 000000000..a09e2a737 --- /dev/null +++ b/src/blackgui/editors/modelmappingmodifyform.ui @@ -0,0 +1,146 @@ + + + CModelMappingModifyForm + + + + 0 + 0 + 237 + 110 + + + + Modify model data + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Description: + + + le_Description + + + + + + + + + + + + + + Name: + + + le_Name + + + + + + + Name + + + true + + + + + + + + + + + + + + Simulator: + + + + + + + 256 + + + Model description + + + true + + + + + + + Mode: + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + + + BlackGui::CSimulatorSelector + QFrame +
blackgui/simulatorselector.h
+ 1 +
+ + BlackGui::CModelModeSelector + QFrame +
blackgui/modelmodeselector.h
+ 1 +
+
+ + +