refs #587, allow to select model mode (include/exclude)

This commit is contained in:
Klaus Basan
2016-01-29 21:32:46 +01:00
parent 873f5f04b9
commit d860d971eb
3 changed files with 181 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
/* 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 "modelmodeselector.h"
#include "ui_modelmodeselector.h"
using namespace BlackMisc::Simulation;
namespace BlackGui
{
CModelModeSelector::CModelModeSelector(QWidget *parent) :
QFrame(parent),
ui(new Ui::CModelModeSelector)
{
ui->setupUi(this);
connect(ui->rb_Include, &QRadioButton::released, this, &CModelModeSelector::changed);
}
CModelModeSelector::~CModelModeSelector()
{
// void
}
BlackMisc::Simulation::CAircraftModel::ModelMode CModelModeSelector::getMode() const
{
if (ui->rb_Include->isChecked())
{
return CAircraftModel::Include;
}
else
{
return CAircraftModel::Exclude;
}
}
void CModelModeSelector::setValue(CAircraftModel::ModelMode mode)
{
if (mode == CAircraftModel::Include)
{
ui->rb_Include->setChecked(true);
}
else
{
ui->rb_Exclude->setChecked(true);
}
}
void CModelModeSelector::setValue(const CAircraftModel &model)
{
this->setValue(model.getModelMode());
}
void CModelModeSelector::setReadOnly(bool readOnly)
{
this->setEnabled(!readOnly);
}
}

View File

@@ -0,0 +1,59 @@
/* 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_MODELMODESELECTOR_H
#define BLACKGUI_MODELMODESELECTOR_H
#include "blackguiexport.h"
#include "blackmisc/simulation/aircraftmodel.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CModelModeSelector; }
namespace BlackGui
{
/*!
* Select the mode
*/
class BLACKGUI_EXPORT CModelModeSelector : public QFrame
{
Q_OBJECT
public:
//! Constructor
explicit CModelModeSelector(QWidget *parent = nullptr);
//! Destructor
~CModelModeSelector();
//! Get mode
BlackMisc::Simulation::CAircraftModel::ModelMode getMode() const;
//! Set mode
void setValue(BlackMisc::Simulation::CAircraftModel::ModelMode mode);
//! Set mode
void setValue(const BlackMisc::Simulation::CAircraftModel &model);
//! Read only
void setReadOnly(bool readOnly);
signals:
//! Value changed
void changed();
private:
QScopedPointer<Ui::CModelModeSelector> ui;
};
}
#endif // guard

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CModelModeSelector</class>
<widget class="QFrame" name="CModelModeSelector">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>88</width>
<height>25</height>
</rect>
</property>
<property name="windowTitle">
<string>Model include/exclude</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="hl_ModelModeSelector">
<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="QRadioButton" name="rb_Include">
<property name="toolTip">
<string>Include model</string>
</property>
<property name="text">
<string>In</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_Exclude">
<property name="text">
<string>Ex.</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>