mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #452 editors
the editors allow to enter data for the different value objects
This commit is contained in:
committed by
Mathew Sutcliffe
parent
93e6e1d38e
commit
513eb07a13
158
src/blackgui/editors/aircrafticaoform.cpp
Normal file
158
src/blackgui/editors/aircrafticaoform.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "blackgui/guiutility.h"
|
||||
#include "blackmisc/aviation/aircrafticaocodelist.h"
|
||||
#include "aircrafticaoform.h"
|
||||
#include "ui_aircrafticaoform.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CAircraftIcaoForm::CAircraftIcaoForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
ui(new Ui::CAircraftIcaoForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->lai_id->set(CIcons::appAircraftIcao16(), "Id:");
|
||||
this->ui->le_Updated->setReadOnly(true);
|
||||
this->ui->le_Id->setReadOnly(true);
|
||||
this->ui->aircraft_Selector->withIcaoDescription(false);
|
||||
connect(this->ui->aircraft_Selector, &CDbAircraftIcaoSelectorComponent::changedAircraftIcao, this, &CAircraftIcaoForm::setValue);
|
||||
|
||||
// drag and drop
|
||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAircraftIcaoForm::ps_droppedCode);
|
||||
this->ui->drop_DropData->setInfoText("<drop aircraft ICAO code>");
|
||||
this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CAircraftIcaoCode>(), qMetaTypeId<CAircraftIcaoCodeList>()});
|
||||
}
|
||||
|
||||
CAircraftIcaoForm::~CAircraftIcaoForm()
|
||||
{ }
|
||||
|
||||
void CAircraftIcaoForm::setValue(const BlackMisc::Aviation::CAircraftIcaoCode &icao)
|
||||
{
|
||||
this->m_aircraft = icao;
|
||||
this->ui->le_Id->setText(icao.getDbKeyAsString());
|
||||
this->ui->aircraft_Selector->setAircraftIcao(icao);
|
||||
this->ui->le_Manufacturer->setText(icao.getManufacturer());
|
||||
this->ui->le_ModelDescription->setText(icao.getModelDescription());
|
||||
|
||||
this->ui->cb_Legacy->setChecked(icao.isLegacyAircraft());
|
||||
this->ui->cb_Military->setChecked(icao.isMilitary());
|
||||
this->ui->cb_RealWorld->setChecked(icao.isRealWorld());
|
||||
this->ui->combined_TypeSelector->setCombinedType(icao.getCombinedType());
|
||||
|
||||
QString rank(icao.getRankString());
|
||||
QString wtc(icao.getWtc());
|
||||
CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Rank, rank, "unspecified");
|
||||
CGuiUtility::setComboBoxValueByStartingString(this->ui->cb_Wtc, wtc, "unspecified");
|
||||
|
||||
this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms());
|
||||
}
|
||||
|
||||
const CAircraftIcaoCode &CAircraftIcaoForm::getValue() const
|
||||
{
|
||||
CAircraftIcaoCode icao(this->ui->aircraft_Selector->getAircraftIcao());
|
||||
if (icao.hasCompleteData())
|
||||
{
|
||||
m_aircraft = icao;
|
||||
}
|
||||
QString manufacturer(this->ui->le_Manufacturer->text().trimmed().toUpper());
|
||||
QString modelDescription(this->ui->le_ModelDescription->text());
|
||||
QString wtc(ui->cb_Wtc->currentText().left(1));
|
||||
QString combined(ui->combined_TypeSelector->getCombinedType());
|
||||
bool ok;
|
||||
int rank = this->ui->cb_Rank->currentText().toInt(&ok);
|
||||
if (!ok) { rank = 10; }
|
||||
bool legacy = this->ui->cb_Legacy->isChecked();
|
||||
bool military = this->ui->cb_Military->isChecked();
|
||||
bool realWorld = this->ui->cb_RealWorld->isChecked();
|
||||
m_aircraft.setManufacturer(manufacturer);
|
||||
m_aircraft.setModelDescription(modelDescription);
|
||||
m_aircraft.setWtc(wtc);
|
||||
m_aircraft.setCodeFlags(military, legacy, realWorld);
|
||||
m_aircraft.setRank(rank);
|
||||
m_aircraft.setCombinedType(combined);
|
||||
return m_aircraft;
|
||||
}
|
||||
|
||||
CStatusMessageList CAircraftIcaoForm::validate() const
|
||||
{
|
||||
CAircraftIcaoCode code(getValue());
|
||||
CStatusMessageList msgs(code.validate());
|
||||
this->ui->val_Indicator->setState(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::allowDrop(bool allowDrop)
|
||||
{
|
||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
||||
}
|
||||
|
||||
bool CAircraftIcaoForm::isDropAllowed() const
|
||||
{
|
||||
return ui->drop_DropData->isDropAllowed();
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->m_readOnly = readOnly;
|
||||
this->ui->aircraft_Selector->setReadOnly(readOnly);
|
||||
this->ui->le_Manufacturer->setReadOnly(readOnly);
|
||||
this->ui->le_ModelDescription->setReadOnly(readOnly);
|
||||
|
||||
this->ui->cb_Legacy->setCheckable(!readOnly);
|
||||
this->ui->cb_Military->setCheckable(!readOnly);
|
||||
this->ui->cb_RealWorld->setCheckable(!readOnly);
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::clear()
|
||||
{
|
||||
setValue(CAircraftIcaoCode());
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::setMappingMode()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
this->ui->aircraft_Selector->setReadOnly(false);
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
||||
this->ui->aircraft_Selector->setProvider(webDataReaderProvider);
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
||||
{
|
||||
CAircraftIcaoCode icao;
|
||||
if (variantDropped.canConvert<CAircraftIcaoCode>())
|
||||
{
|
||||
icao = variantDropped.value<CAircraftIcaoCode>();
|
||||
}
|
||||
else if (variantDropped.canConvert<CAircraftIcaoCodeList>())
|
||||
{
|
||||
CAircraftIcaoCodeList icaoList(variantDropped.value<CAircraftIcaoCodeList>());
|
||||
if (icaoList.isEmpty()) { return; }
|
||||
icao = icaoList.front();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->setValue(icao);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
83
src/blackgui/editors/aircrafticaoform.h
Normal file
83
src/blackgui/editors/aircrafticaoform.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_AIRCRAFTICAOFORM_H
|
||||
#define BLACKGUI_EDITORS_AIRCRAFTICAOFORM_H
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
#include "blackmisc/aviation/aircrafticaocode.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAircraftIcaoForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Aircraft ICAO form
|
||||
*/
|
||||
class CAircraftIcaoForm :
|
||||
public CForm,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAircraftIcaoForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAircraftIcaoForm();
|
||||
|
||||
//! Get value
|
||||
const BlackMisc::Aviation::CAircraftIcaoCode &getValue() const;
|
||||
|
||||
//! Validate, empty list means OK
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
//! Allow to drop
|
||||
void allowDrop(bool allowDrop);
|
||||
|
||||
//! Is drop allowed?
|
||||
bool isDropAllowed() const;
|
||||
|
||||
//! \copydoc CEditor::setReadOnly
|
||||
virtual void setReadOnly(bool readOnly) override;
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
//! Mapping mode
|
||||
void setMappingMode();
|
||||
|
||||
//! \copydoc CWebDataReaderAware::setProvider
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override;
|
||||
|
||||
public slots:
|
||||
//! Set value
|
||||
void setValue(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAircraftIcaoForm> ui;
|
||||
mutable BlackMisc::Aviation::CAircraftIcaoCode m_aircraft;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
386
src/blackgui/editors/aircrafticaoform.ui
Normal file
386
src/blackgui/editors/aircrafticaoform.ui
Normal file
@@ -0,0 +1,386 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAircraftIcaoForm</class>
|
||||
<widget class="QFrame" name="CAircraftIcaoForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>388</width>
|
||||
<height>223</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>220</height>
|
||||
</size>
|
||||
</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_AirccraftIcaoForm">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="QGroupBox" name="gb_AircraftIcao">
|
||||
<property name="title">
|
||||
<string>Aircraft ICAO</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="wi_DesignatorRank" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_DesignatorRank">
|
||||
<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::Components::CDbAircraftIcaoSelectorComponent" name="aircraft_Selector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_Rank">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>7</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>9</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unspecified</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="BlackGui::CAircraftCombinedTypeSelector" name="combined_TypeSelector"/>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QWidget" name="wi_Checkboxes" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_CheckBoxes">
|
||||
<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="QComboBox" name="cb_Wtc">
|
||||
<property name="toolTip">
|
||||
<string>Wake turbulence category</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>L</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>M</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>H</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Unspecified</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Wtc">
|
||||
<property name="text">
|
||||
<string>WTC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_RealWorld">
|
||||
<property name="text">
|
||||
<string>Real</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Legacy">
|
||||
<property name="text">
|
||||
<string>Legacy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Military">
|
||||
<property name="toolTip">
|
||||
<string>Military</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mil.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_id">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Manufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. Boeing, Airbus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_ModelDescription">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="placeholderText">
|
||||
<string>Aircraft model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_CombinedCode">
|
||||
<property name="toolTip">
|
||||
<string>Type / Engine / Engine count</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Combined type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_MiscFlags">
|
||||
<property name="text">
|
||||
<string>Misc.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_IcaoDesignator">
|
||||
<property name="text">
|
||||
<string>Design./Rank:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Manufacturer">
|
||||
<property name="text">
|
||||
<string>Manufacturer:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="8">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</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::CDropSite</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>blackgui/dropsite.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLabelAndIcon</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/labelandicon.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CValidationIndicator</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/validationindicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CAircraftCombinedTypeSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/aircraftcombinedtypeselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbAircraftIcaoSelectorComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbaircrafticaoselectorcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>le_Id</tabstop>
|
||||
<tabstop>cb_Rank</tabstop>
|
||||
<tabstop>le_Manufacturer</tabstop>
|
||||
<tabstop>le_ModelDescription</tabstop>
|
||||
<tabstop>cb_Wtc</tabstop>
|
||||
<tabstop>cb_RealWorld</tabstop>
|
||||
<tabstop>cb_Legacy</tabstop>
|
||||
<tabstop>cb_Military</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
127
src/blackgui/editors/airlineicaoform.cpp
Normal file
127
src/blackgui/editors/airlineicaoform.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "blackmisc/aviation/airlineicaocodelist.h"
|
||||
#include "blackmisc/country.h"
|
||||
#include "airlineicaoform.h"
|
||||
#include "ui_airlineicaoform.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CAirlineIcaoForm::CAirlineIcaoForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
BlackMisc::Network::CWebDataServicesAware(nullptr),
|
||||
ui(new Ui::CAirlineIcaoForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->le_Updated->setReadOnly(true);
|
||||
this->ui->le_Id->setReadOnly(true);
|
||||
this->ui->lai_Id->set(CIcons::appAirlineIcao16(), "Id:");
|
||||
|
||||
this->ui->airline_Selector->withIcaoDescription(false);
|
||||
connect(this->ui->airline_Selector, &CDbAirlineIcaoSelectorComponent::changedAirlineIcao, this, &CAirlineIcaoForm::setValue);
|
||||
|
||||
// drag and drop
|
||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAirlineIcaoForm::ps_droppedCode);
|
||||
this->ui->drop_DropData->setInfoText("<drop airline ICAO code>");
|
||||
this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CAirlineIcaoCode>(), qMetaTypeId<CAirlineIcaoCodeList>()});
|
||||
}
|
||||
|
||||
CAirlineIcaoForm::~CAirlineIcaoForm()
|
||||
{ }
|
||||
|
||||
void CAirlineIcaoForm::setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao)
|
||||
{
|
||||
this->m_airline = icao;
|
||||
this->ui->airline_Selector->setAirlineIcao(icao);
|
||||
this->ui->le_Id->setText(icao.getDbKeyAsString());
|
||||
this->ui->le_TelephonyDesignator->setText(icao.getTelephonyDesignator());
|
||||
this->ui->le_Name->setText(icao.getName());
|
||||
this->ui->le_Updated->setText(icao.getFormattedUtcTimestampYmdhms());
|
||||
this->ui->cb_Va->setChecked(icao.isVirtualAirline());
|
||||
this->ui->country_Selector->setCountry(icao.getCountry());
|
||||
this->ui->lbl_AirlineIcon->setPixmap(icao.toPixmap());
|
||||
}
|
||||
|
||||
const CAirlineIcaoCode &CAirlineIcaoForm::getValue() const
|
||||
{
|
||||
m_airline.setVirtualAirline(this->ui->cb_Va->isChecked());
|
||||
m_airline.setCountry(this->ui->country_Selector->getCountry());
|
||||
m_airline.setName(this->ui->le_Name->text());
|
||||
m_airline.setTelephonyDesignator(this->ui->le_TelephonyDesignator->text());
|
||||
return m_airline;
|
||||
}
|
||||
|
||||
CStatusMessageList CAirlineIcaoForm::validate() const
|
||||
{
|
||||
CAirlineIcaoCode code(getValue());
|
||||
CStatusMessageList msgs(code.validate());
|
||||
this->ui->val_Indicator->setState(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::allowDrop(bool allowDrop)
|
||||
{
|
||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
||||
}
|
||||
|
||||
bool CAirlineIcaoForm::isDropAllowed() const
|
||||
{
|
||||
return this->ui->drop_DropData->isDropAllowed();
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->ui->airline_Selector->setReadOnly(readOnly);
|
||||
this->ui->le_TelephonyDesignator->setReadOnly(readOnly);
|
||||
this->ui->le_Name->setReadOnly(readOnly);
|
||||
this->ui->country_Selector->setReadOnly(readOnly);
|
||||
this->ui->cb_Va->setEnabled(!readOnly);
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::clear()
|
||||
{
|
||||
setValue(CAirlineIcaoCode());
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
||||
this->ui->country_Selector->setProvider(webDataReaderProvider);
|
||||
this->ui->airline_Selector->setProvider(webDataReaderProvider);
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
||||
{
|
||||
CAirlineIcaoCode icao;
|
||||
if (variantDropped.canConvert<CAirlineIcaoCode>())
|
||||
{
|
||||
icao = variantDropped.value<CAirlineIcaoCode>();
|
||||
}
|
||||
else if (variantDropped.canConvert<CAirlineIcaoCodeList>())
|
||||
{
|
||||
CAirlineIcaoCodeList icaoList(variantDropped.value<CAirlineIcaoCodeList>());
|
||||
if (icaoList.isEmpty()) { return; }
|
||||
icao = icaoList.front();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->setValue(icao);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
79
src/blackgui/editors/airlineicaoform.h
Normal file
79
src/blackgui/editors/airlineicaoform.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_AIRLINEICAOFORM_H
|
||||
#define BLACKGUI_EDITORS_AIRLINEICAOFORM_H
|
||||
|
||||
#include "blackmisc/aviation/airlineicaocode.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackgui/editors/form.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CAirlineIcaoForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Airline ICAO code form
|
||||
*/
|
||||
class CAirlineIcaoForm :
|
||||
public CForm,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CAirlineIcaoForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CAirlineIcaoForm();
|
||||
|
||||
//! Set value
|
||||
void setValue(const BlackMisc::Aviation::CAirlineIcaoCode &icao = BlackMisc::Aviation::CAirlineIcaoCode());
|
||||
|
||||
//! Get value
|
||||
const BlackMisc::Aviation::CAirlineIcaoCode &getValue() const;
|
||||
|
||||
//! Validate, empty list means OK
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
//! Allow to drop
|
||||
void allowDrop(bool allowDrop);
|
||||
|
||||
//! Is drop allowed?
|
||||
bool isDropAllowed() const;
|
||||
|
||||
//! \copydoc CEditor::setReadOnly
|
||||
virtual void setReadOnly(bool readOnly) override;
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
//! \copydoc CWebDataReaderAware::setProvider
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override;
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CAirlineIcaoForm> ui;
|
||||
mutable BlackMisc::Aviation::CAirlineIcaoCode m_airline; // object allowing to override values
|
||||
};
|
||||
|
||||
} // ns
|
||||
} //ns
|
||||
|
||||
#endif // guard
|
||||
303
src/blackgui/editors/airlineicaoform.ui
Normal file
303
src/blackgui/editors/airlineicaoform.ui
Normal file
@@ -0,0 +1,303 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAirlineIcaoForm</class>
|
||||
<widget class="QFrame" name="CAirlineIcaoForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>255</width>
|
||||
<height>196</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>190</height>
|
||||
</size>
|
||||
</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_AirlineIcaoCode">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="QGroupBox" name="gb_AirlineIcao">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Airline ICAO</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="1">
|
||||
<widget class="QWidget" name="wi_Timestamps" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_Timestamps">
|
||||
<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="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="BlackGui::Components::CDbCountrySelectorComponent" name="country_Selector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="wi_IdAndIcon" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_IdAndIcon">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<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="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_AirlineIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<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="QWidget" name="wi_DesignatorVa" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_DesignatorRank">
|
||||
<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::Components::CDbAirlineIcaoSelectorComponent" name="airline_Selector">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Va">
|
||||
<property name="text">
|
||||
<string>VA?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Wtc">
|
||||
<property name="text">
|
||||
<string>Country:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_IcaoDesignator">
|
||||
<property name="text">
|
||||
<string>Designator/VA?:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Name">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_Name">
|
||||
<property name="placeholderText">
|
||||
<string>Airline's name (e.g. Lufthansa)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_TelephonyDesignator">
|
||||
<property name="placeholderText">
|
||||
<string>How airline is called via radio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_TelephonyDesignator">
|
||||
<property name="text">
|
||||
<string>Telephony:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="7">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</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::Components::CDbCountrySelectorComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbcountryselectorcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CDropSite</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>blackgui/dropsite.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLabelAndIcon</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/labelandicon.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbAirlineIcaoSelectorComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbairlineicaoselectorcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CValidationIndicator</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/validationindicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>le_Id</tabstop>
|
||||
<tabstop>cb_Va</tabstop>
|
||||
<tabstop>le_TelephonyDesignator</tabstop>
|
||||
<tabstop>le_Name</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
133
src/blackgui/editors/distributorform.cpp
Normal file
133
src/blackgui/editors/distributorform.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/country.h"
|
||||
#include "distributorform.h"
|
||||
#include "ui_distributorform.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CDistributorForm::CDistributorForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
BlackMisc::Network::CWebDataServicesAware(nullptr),
|
||||
ui(new Ui::CDistributorForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->le_Updated->setReadOnly(true);
|
||||
this->ui->distributor_Selector->withDistributorDescription(false);
|
||||
ui->lai_Id->set(CIcons::appDistributors16(), "Id:");
|
||||
|
||||
// drag and drop
|
||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CDistributorForm::ps_droppedCode);
|
||||
connect(this->ui->distributor_Selector, &CDbDistributorSelectorComponent::changedDistributor, this, &CDistributorForm::setValue);
|
||||
this->ui->drop_DropData->setInfoText("<drop distributor>");
|
||||
this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CDistributor>(), qMetaTypeId<CDistributorList>()});
|
||||
}
|
||||
|
||||
CDistributorForm::~CDistributorForm()
|
||||
{ }
|
||||
|
||||
void CDistributorForm::setValue(const BlackMisc::Simulation::CDistributor &distributor)
|
||||
{
|
||||
this->m_distributor = distributor;
|
||||
this->ui->distributor_Selector->setDistributor(distributor);
|
||||
this->ui->le_Description->setText(distributor.getDescription());
|
||||
this->ui->le_Alias1->setText(distributor.getAlias1());
|
||||
this->ui->le_Alias2->setText(distributor.getAlias2());
|
||||
this->ui->le_Updated->setText(distributor.getFormattedUtcTimestampYmdhms());
|
||||
}
|
||||
|
||||
const CDistributor &CDistributorForm::getValue() const
|
||||
{
|
||||
CDistributor d(ui->distributor_Selector->getDistributor());
|
||||
if (d.hasCompleteData()) { this->m_distributor = d;}
|
||||
|
||||
m_distributor.setAlias1(this->ui->le_Alias1->text());
|
||||
m_distributor.setAlias2(this->ui->le_Alias2->text());
|
||||
m_distributor.setDescription(this->ui->le_Description->text());
|
||||
return m_distributor;
|
||||
}
|
||||
|
||||
CStatusMessageList CDistributorForm::validate() const
|
||||
{
|
||||
CDistributor distributor(getValue());
|
||||
CStatusMessageList msgs;
|
||||
if (!distributor.getDbKey().isEmpty())
|
||||
{
|
||||
// optional distributor
|
||||
msgs = distributor.validate();
|
||||
}
|
||||
this->ui->val_Indicator->setState(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CDistributorForm::allowDrop(bool allowDrop)
|
||||
{
|
||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
||||
}
|
||||
|
||||
bool CDistributorForm::isDropAllowed() const
|
||||
{
|
||||
return this->ui->drop_DropData->isDropAllowed();
|
||||
}
|
||||
|
||||
void CDistributorForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->ui->le_Alias1->setReadOnly(readOnly);
|
||||
this->ui->le_Alias2->setReadOnly(readOnly);
|
||||
this->ui->le_Description->setReadOnly(readOnly);
|
||||
this->ui->distributor_Selector->setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
void CDistributorForm::clear()
|
||||
{
|
||||
setValue(CDistributor());
|
||||
this->ui->distributor_Selector->setReadOnly(false);
|
||||
}
|
||||
|
||||
void CDistributorForm::setMappingMode()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
}
|
||||
|
||||
void CDistributorForm::setProvider(Network::IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
CWebDataServicesAware::setProvider(webDataReaderProvider);
|
||||
this->ui->distributor_Selector->setProvider(webDataReaderProvider);
|
||||
}
|
||||
|
||||
void CDistributorForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
||||
{
|
||||
CDistributor distributor;
|
||||
if (variantDropped.canConvert<CDistributor>())
|
||||
{
|
||||
distributor = variantDropped.value<CDistributor>();
|
||||
}
|
||||
else if (variantDropped.canConvert<CDistributorList>())
|
||||
{
|
||||
CDistributorList icaoList(variantDropped.value<CDistributorList>());
|
||||
if (icaoList.isEmpty()) { return; }
|
||||
distributor = icaoList.front();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
this->setValue(distributor);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
84
src/blackgui/editors/distributorform.h
Normal file
84
src/blackgui/editors/distributorform.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_DISTRIBUTORFORM_H
|
||||
#define BLACKGUI_EDITORS_DISTRIBUTORFORM_H
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
#include "blackmisc/simulation/distributor.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CDistributorForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Distributor form
|
||||
*/
|
||||
class CDistributorForm :
|
||||
public CForm,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CDistributorForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CDistributorForm();
|
||||
|
||||
//! Get value
|
||||
const BlackMisc::Simulation::CDistributor &getValue() const;
|
||||
|
||||
//! Validate, empty list means OK
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
//! Allow to drop
|
||||
void allowDrop(bool allowDrop);
|
||||
|
||||
//! Is drop allowed?
|
||||
bool isDropAllowed() const;
|
||||
|
||||
//! \copydoc CEditor::setReadOnly
|
||||
void setReadOnly(bool readOnly);
|
||||
|
||||
//! Clear
|
||||
void clear();
|
||||
|
||||
//! Mapping mode
|
||||
void setMappingMode();
|
||||
|
||||
//! \copydoc CWebDataReaderAware::setProvider
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider);
|
||||
|
||||
public slots:
|
||||
//! Set value
|
||||
void setValue(const BlackMisc::Simulation::CDistributor &distributor = BlackMisc::Simulation::CDistributor());
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CDistributorForm> ui;
|
||||
mutable BlackMisc::Simulation::CDistributor m_distributor; // object allowing to override values
|
||||
bool m_readOnly = false;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} //ns
|
||||
|
||||
#endif // guard
|
||||
205
src/blackgui/editors/distributorform.ui
Normal file
205
src/blackgui/editors/distributorform.ui
Normal file
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CDistributorForm</class>
|
||||
<widget class="QFrame" name="CDistributorForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>240</width>
|
||||
<height>178</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>175</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Distributor editor</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_DistributorEditor">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<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="QGroupBox" name="gb_Distributor">
|
||||
<property name="title">
|
||||
<string>Distributor</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="BlackGui::Components::CDbDistributorSelectorComponent" name="distributor_Selector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="wi_Timestamps" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_Timestamps">
|
||||
<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="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Alias2">
|
||||
<property name="text">
|
||||
<string>Alias 2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Alias1">
|
||||
<property name="placeholderText">
|
||||
<string>An alias</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Alias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_Alias2">
|
||||
<property name="placeholderText">
|
||||
<string>Another alias</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>Describe distributor</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="6">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</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::CDropSite</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>blackgui/dropsite.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLabelAndIcon</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/labelandicon.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CValidationIndicator</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/validationindicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CDbDistributorSelectorComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/dbdistributorselectorcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
23
src/blackgui/editors/form.cpp
Normal file
23
src/blackgui/editors/form.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "form.h"
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CForm::CForm(QWidget *parent) :
|
||||
QFrame(parent)
|
||||
{ }
|
||||
|
||||
CForm::~CForm() { }
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
48
src/blackgui/editors/form.h
Normal file
48
src/blackgui/editors/form.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_FORM_H
|
||||
#define BLACKGUI_EDITORS_FORM_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Form base class
|
||||
*/
|
||||
class CForm : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CForm();
|
||||
|
||||
//! Set editable
|
||||
virtual void setReadOnly(bool readOnly) = 0;
|
||||
|
||||
//! Is read only?
|
||||
bool isReadOnly() const { return m_readOnly; }
|
||||
|
||||
protected:
|
||||
bool m_readOnly = false; //!< read only
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
123
src/blackgui/editors/liveryform.cpp
Normal file
123
src/blackgui/editors/liveryform.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "blackmisc/aviation/liverylist.h"
|
||||
#include "liveryform.h"
|
||||
#include "ui_liveryform.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CLiveryForm::CLiveryForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
ui(new Ui::CLiveryForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->ui->le_Id->setReadOnly(true);
|
||||
this->ui->le_Updated->setReadOnly(true);
|
||||
this->ui->lai_Id->set(CIcons::appLiveries16(), "Id:");
|
||||
|
||||
// drag and drop
|
||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery);
|
||||
this->ui->drop_DropData->setInfoText("<drop livery>");
|
||||
this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CLivery>(), qMetaTypeId<CLiveryList>()});
|
||||
}
|
||||
|
||||
CLiveryForm::~CLiveryForm() { }
|
||||
|
||||
void CLiveryForm::setProvider(BlackMisc::Network::IWebDataServicesProvider *provider)
|
||||
{
|
||||
CWebDataServicesAware::setProvider(provider);
|
||||
this->ui->editor_AirlineIcao->setProvider(provider);
|
||||
}
|
||||
|
||||
const CLivery &CLiveryForm::getValue() const
|
||||
{
|
||||
CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue());
|
||||
this->m_livery.setCombinedCode(this->ui->le_Code->text());
|
||||
this->m_livery.setAirlineIcaoCode(airline);
|
||||
this->m_livery.setDescription(this->ui->le_Description->text());
|
||||
return m_livery;
|
||||
}
|
||||
|
||||
void CLiveryForm::setValue(const CLivery &livery)
|
||||
{
|
||||
this->m_livery = livery;
|
||||
this->ui->le_Id->setText(livery.getDbKeyAsString());
|
||||
this->ui->le_Code->setText(livery.getCombinedCode());
|
||||
this->ui->le_Description->setText(livery.getDescription());
|
||||
this->ui->le_Updated->setText(livery.getFormattedUtcTimestampYmdhms());
|
||||
this->ui->color_Fuselage->setColor(livery.getColorFuselage());
|
||||
this->ui->color_Tail->setColor(livery.getColorTail());
|
||||
|
||||
this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
|
||||
}
|
||||
|
||||
CStatusMessageList CLiveryForm::validate(bool withNestedForms) const
|
||||
{
|
||||
CLivery livery(getValue());
|
||||
CStatusMessageList msgs(livery.validate());
|
||||
if (withNestedForms && (livery.hasValidDbKey() || !livery.getAirlineIcaoCodeDesignator().isEmpty()))
|
||||
{
|
||||
msgs.push_back(this->ui->editor_AirlineIcao->validate());
|
||||
}
|
||||
this->ui->val_Indicator->setState(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CLiveryForm::allowDrop(bool allowDrop)
|
||||
{
|
||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
||||
}
|
||||
|
||||
bool CLiveryForm::isDropAllowed() const
|
||||
{
|
||||
return this->ui->drop_DropData->isDropAllowed();
|
||||
}
|
||||
|
||||
void CLiveryForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->m_readOnly = readOnly;
|
||||
this->ui->le_Code->setReadOnly(readOnly);
|
||||
this->ui->le_Description->setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
void CLiveryForm::setMappingMode()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
}
|
||||
|
||||
void CLiveryForm::clear()
|
||||
{
|
||||
this->setValue(CLivery());
|
||||
}
|
||||
|
||||
void CLiveryForm::ps_droppedLivery(const BlackMisc::CVariant &variantDropped)
|
||||
{
|
||||
CLivery livery;
|
||||
if (variantDropped.canConvert<CLivery>())
|
||||
{
|
||||
livery = variantDropped.value<CLivery>();
|
||||
}
|
||||
else if (variantDropped.canConvert<CLiveryList>())
|
||||
{
|
||||
CLiveryList liveryList(variantDropped.value<CLiveryList>());
|
||||
if (liveryList.isEmpty()) { return; }
|
||||
livery = liveryList.front();
|
||||
}
|
||||
else { return; }
|
||||
this->setValue(livery);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
81
src/blackgui/editors/liveryform.h
Normal file
81
src/blackgui/editors/liveryform.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_LIVERYFORM_H
|
||||
#define BLACKGUI_EDITORS_LIVERYFORM_H
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
#include "blackmisc/aviation/livery.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
|
||||
namespace Ui { class CLiveryForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Livery form class
|
||||
*/
|
||||
class CLiveryForm :
|
||||
public CForm,
|
||||
public BlackMisc::Network::CWebDataServicesAware
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CLiveryForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CLiveryForm();
|
||||
|
||||
//! \copydoc CWebDataReaderAware::setProvider
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *provider) override;
|
||||
|
||||
//! Value
|
||||
const BlackMisc::Aviation::CLivery &getValue() const;
|
||||
|
||||
//! Value
|
||||
void setValue(const BlackMisc::Aviation::CLivery &livery);
|
||||
|
||||
//! Validate, empty list means OK
|
||||
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
|
||||
|
||||
//! Allow to drop
|
||||
void allowDrop(bool allowDrop);
|
||||
|
||||
//! Is drop allowed?
|
||||
bool isDropAllowed() const;
|
||||
|
||||
//! \copydoc CEditor::setReadOnly
|
||||
virtual void setReadOnly(bool readOnly) override;
|
||||
|
||||
//! Mapping mode
|
||||
void setMappingMode();
|
||||
|
||||
//! Clear data
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
//! Livery dropped
|
||||
void ps_droppedLivery(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CLiveryForm> ui;
|
||||
mutable BlackMisc::Aviation::CLivery m_livery; //!< object whose values will be overridden
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
247
src/blackgui/editors/liveryform.ui
Normal file
247
src/blackgui/editors/liveryform.ui
Normal file
@@ -0,0 +1,247 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CLiveryForm</class>
|
||||
<widget class="QFrame" name="CLiveryForm">
|
||||
<property name="windowTitle">
|
||||
<string>Livery editor</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_LiveryForm">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="QGroupBox" name="gb_Livery">
|
||||
<property name="title">
|
||||
<string>Livery</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Livery">
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
|
||||
<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="QWidget" name="wi_DesignatorVa" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_DesignatorRank">
|
||||
<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="QLineEdit" name="le_Code">
|
||||
<property name="placeholderText">
|
||||
<string>Livery code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QWidget" name="wi_Colors" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_Colors">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<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 alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::CColorSelector" name="color_Fuselage">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="BlackGui::CColorSelector" name="color_Tail">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="BlackGui::Editors::CAirlineIcaoForm" name="editor_AirlineIcao">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Code">
|
||||
<property name="text">
|
||||
<string>Code:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_FuselageColor">
|
||||
<property name="text">
|
||||
<string>Fuselage/Tail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>Livery description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="7">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</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::CColorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/colorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CDropSite</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>blackgui/dropsite.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLabelAndIcon</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/labelandicon.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CValidationIndicator</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/validationindicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CAirlineIcaoForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/airlineicaoform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>le_Id</tabstop>
|
||||
<tabstop>le_Code</tabstop>
|
||||
<tabstop>le_Description</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
68
src/blackgui/editors/modelmappingform.cpp
Normal file
68
src/blackgui/editors/modelmappingform.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "modelmappingform.h"
|
||||
#include "ui_modelmappingform.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CModelMappingForm::CModelMappingForm(QWidget *parent) :
|
||||
CForm(parent),
|
||||
ui(new Ui::CModelMappingForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->le_LastUpdated->setReadOnly(true);
|
||||
ui->le_Id->setReadOnly(true);
|
||||
ui->lai_Id->set(CIcons::appMappings16(), "Id:");
|
||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CModelMappingForm::requestSave);
|
||||
}
|
||||
|
||||
CModelMappingForm::~CModelMappingForm()
|
||||
{ }
|
||||
|
||||
const BlackMisc::Simulation::CAircraftModel &CModelMappingForm::getValue() const
|
||||
{
|
||||
m_model.setSimulatorInfo(this->ui->selector_Simulator->getValue());
|
||||
m_model.setDescription(this->ui->le_Description->text());
|
||||
m_model.setModelString(this->ui->le_ModelKey->text());
|
||||
m_model.setName(this->ui->le_Name->text());
|
||||
return m_model;
|
||||
}
|
||||
|
||||
CStatusMessageList CModelMappingForm::validate(bool withNestedForms) const
|
||||
{
|
||||
CAircraftModel model(getValue());
|
||||
CStatusMessageList msgs(model.validate(withNestedForms));
|
||||
this->ui->val_Indicator->setState(msgs);
|
||||
return msgs;
|
||||
}
|
||||
|
||||
void CModelMappingForm::setReadOnly(bool readOnly)
|
||||
{
|
||||
this->ui->le_Description->setReadOnly(readOnly);
|
||||
this->ui->le_ModelKey->setReadOnly(readOnly);
|
||||
this->ui->le_Name->setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
void CModelMappingForm::setValue(BlackMisc::Simulation::CAircraftModel &model)
|
||||
{
|
||||
ui->le_ModelKey->setText(model.getModelString());
|
||||
ui->le_LastUpdated->setText(model.getFormattedUtcTimestampYmdhms());
|
||||
ui->le_Id->setText(model.getDbKeyAsString());
|
||||
ui->le_Description->setText(model.getDescription());
|
||||
ui->le_Name->setText(model.getName());
|
||||
ui->selector_Simulator->setValue(model.getSimulatorInfo());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
67
src/blackgui/editors/modelmappingform.h
Normal file
67
src/blackgui/editors/modelmappingform.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_MODELMAPPINGFORM_H
|
||||
#define BLACKGUI_EDITORS_MODELMAPPINGFORM_H
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CModelMappingForm; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Model mapping form
|
||||
*/
|
||||
class CModelMappingForm : public CForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CModelMappingForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CModelMappingForm();
|
||||
|
||||
//! Value
|
||||
const BlackMisc::Simulation::CAircraftModel &getValue() const;
|
||||
|
||||
//! Validate
|
||||
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
|
||||
|
||||
//! \copydoc CEditor::setReadOnly
|
||||
virtual void setReadOnly(bool readOnly) override;
|
||||
|
||||
public slots:
|
||||
//! Set model
|
||||
void setValue(BlackMisc::Simulation::CAircraftModel &model);
|
||||
|
||||
signals:
|
||||
//! Request validation
|
||||
void requestValidation();
|
||||
|
||||
//! Save
|
||||
void requestSave();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CModelMappingForm> ui;
|
||||
mutable BlackMisc::Simulation::CAircraftModel m_model; //!< cached last value
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
186
src/blackgui/editors/modelmappingform.ui
Normal file
186
src/blackgui/editors/modelmappingform.ui
Normal file
@@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CModelMappingForm</class>
|
||||
<widget class="QFrame" name="CModelMappingForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>592</width>
|
||||
<height>87</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Model editor</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_ModelMappingForm">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="QGroupBox" name="gb_ModelMappingForm">
|
||||
<property name="title">
|
||||
<string>Simulator model</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_ModelMappingForm">
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" colspan="2">
|
||||
<widget class="BlackGui::CSimulatorSelector" name="selector_Simulator">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="ph_Stash">
|
||||
<property name="text">
|
||||
<string>Stash</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
<string>Description:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="6">
|
||||
<widget class="QPushButton" name="pb_Save">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>Model description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QLabel" name="lbl_Updated">
|
||||
<property name="text">
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="lbl_ModelKey">
|
||||
<property name="text">
|
||||
<string>Model key:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="5">
|
||||
<widget class="QLineEdit" name="le_LastUpdated"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Id</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLineEdit" name="le_ModelKey">
|
||||
<property name="placeholderText">
|
||||
<string>Model key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_Name">
|
||||
<property name="placeholderText">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_Name">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7" rowspan="2">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</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::CSimulatorSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/simulatorselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLabelAndIcon</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/labelandicon.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CValidationIndicator</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/validationindicator.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
118
src/blackgui/editors/validationindicator.cpp
Normal file
118
src/blackgui/editors/validationindicator.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 "validationindicator.h"
|
||||
#include "ui_validationindicator.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include <QPainter>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
CValidationIndicator::CValidationIndicator(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CValidationIndicator)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->clear();
|
||||
this->setFrameStyle(QFrame::StyledPanel);
|
||||
this->setFrameShadow(QFrame::Raised);
|
||||
this->setAutoFillBackground(true);
|
||||
this->m_originalStyleSheet = this->styleSheet();
|
||||
connect(&this->m_resetTimer, &QTimer::timeout, this, &CValidationIndicator::clear);
|
||||
this->m_resetTimer.setObjectName(this->objectName().append(":").append("resetTimer"));
|
||||
this->m_resetTimer.start(ResetInterval);
|
||||
}
|
||||
|
||||
CValidationIndicator::~CValidationIndicator()
|
||||
{ }
|
||||
|
||||
void CValidationIndicator::passed()
|
||||
{
|
||||
this->show();
|
||||
setBackgroundColor("green");
|
||||
ui->lbl_Icon->setPixmap(CIcons::tick16());
|
||||
}
|
||||
|
||||
void CValidationIndicator::failed()
|
||||
{
|
||||
this->show();
|
||||
setBackgroundColor("red");
|
||||
ui->lbl_Icon->setPixmap(CStatusMessage::convertToIcon(CStatusMessage::SeverityError));
|
||||
}
|
||||
|
||||
void CValidationIndicator::warnings()
|
||||
{
|
||||
this->show();
|
||||
setBackgroundColor("yellow");
|
||||
ui->lbl_Icon->setPixmap(CStatusMessage::convertToIcon(CStatusMessage::SeverityWarning));
|
||||
}
|
||||
|
||||
void CValidationIndicator::clear()
|
||||
{
|
||||
setBackgroundColor("");
|
||||
ui->lbl_Icon->clear();
|
||||
this->hide();
|
||||
}
|
||||
|
||||
void CValidationIndicator::setState(bool ok)
|
||||
{
|
||||
if (ok)
|
||||
{
|
||||
passed();
|
||||
}
|
||||
else
|
||||
{
|
||||
failed();
|
||||
}
|
||||
}
|
||||
|
||||
void CValidationIndicator::setState(const BlackMisc::CStatusMessageList &msgs)
|
||||
{
|
||||
if (msgs.hasErrorMessages())
|
||||
{
|
||||
this->failed();
|
||||
}
|
||||
else if (msgs.hasWarningMessages())
|
||||
{
|
||||
this->warnings();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->passed();
|
||||
}
|
||||
}
|
||||
|
||||
void CValidationIndicator::paintEvent(QPaintEvent *paintEvent)
|
||||
{
|
||||
CStyleSheetUtility::useStyleSheetInDerivedWidget(this);
|
||||
Q_UNUSED(paintEvent);
|
||||
}
|
||||
|
||||
void CValidationIndicator::setBackgroundColor(const QString colorName)
|
||||
{
|
||||
if (colorName.isEmpty())
|
||||
{
|
||||
this->setStyleSheet(this->m_originalStyleSheet);
|
||||
}
|
||||
else
|
||||
{
|
||||
// I have to clean up any potential background image derived from style sheet
|
||||
const QString s("background-color: %1; background-image: url(:/own/icons/own/transparent1px.png);");
|
||||
this->setStyleSheet(s.arg(colorName));
|
||||
m_resetTimer.start(ResetInterval); // restart
|
||||
}
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
77
src/blackgui/editors/validationindicator.h
Normal file
77
src/blackgui/editors/validationindicator.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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_EDITOR_VALIDATIONINDICATOR_H
|
||||
#define BLACKGUI_EDITOR_VALIDATIONINDICATOR_H
|
||||
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
namespace Ui { class CValidationIndicator; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Editors
|
||||
{
|
||||
/*!
|
||||
* Indication state of validation
|
||||
*/
|
||||
class CValidationIndicator : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CValidationIndicator(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CValidationIndicator();
|
||||
|
||||
//! Validation passed
|
||||
void passed();
|
||||
|
||||
//! Passed with warnings
|
||||
void warnings();
|
||||
|
||||
//! Validation failed
|
||||
void failed();
|
||||
|
||||
//! Ok or failed validation?
|
||||
void setState(bool ok);
|
||||
|
||||
//! Messages from status messages
|
||||
void setState(const BlackMisc::CStatusMessageList &msgs);
|
||||
|
||||
public slots:
|
||||
//! Cleared state
|
||||
void clear();
|
||||
|
||||
protected:
|
||||
//! \copydoc QFrame::paintEvent
|
||||
virtual void paintEvent(QPaintEvent *paintEvent) override;
|
||||
|
||||
private:
|
||||
const int ResetInterval = 5000;
|
||||
QScopedPointer<Ui::CValidationIndicator> ui;
|
||||
|
||||
//! Set background color
|
||||
void setBackgroundColor(const QString colorName);
|
||||
|
||||
QTimer m_resetTimer { this}; //!< reset to neutral
|
||||
QString m_originalStyleSheet; //!< stored, to be able to reset
|
||||
};
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
66
src/blackgui/editors/validationindicator.ui
Normal file
66
src/blackgui/editors/validationindicator.ui
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CValidationIndicator</class>
|
||||
<widget class="QFrame" name="CValidationIndicator">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>18</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Validation Indicator</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_ValidationIndicator">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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="QLabel" name="lbl_Icon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../blackmisc/blackmisc.qrc">:/diagona/icons/diagona/icons/tick.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user