mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #911, paste support in forms
* added paste icon * base class utility functions * implemented paste for livery, airline and aircraft ICAO
This commit is contained in:
committed by
Mathew Sutcliffe
parent
5e69be6208
commit
fc3a36512e
@@ -45,7 +45,7 @@ namespace BlackGui
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setFocusProxy(ui->le_Id);
|
||||
ui->lai_id->set(CIcons::appAircraftIcao16(), "Id:");
|
||||
ui->lai_Id->set(CIcons::appAircraftIcao16(), "Id:");
|
||||
ui->le_Updated->setReadOnly(true);
|
||||
ui->le_Id->setValidator(new QIntValidator(0, 999999, ui->le_Id));
|
||||
ui->aircraft_Selector->displayWithIcaoDescription(false);
|
||||
@@ -54,8 +54,9 @@ namespace BlackGui
|
||||
// Id
|
||||
connect(ui->le_Id, &QLineEdit::returnPressed, this, &CAircraftIcaoForm::ps_idEntered);
|
||||
|
||||
// drag and drop
|
||||
// drag and drop, pasted
|
||||
connect(ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAircraftIcaoForm::ps_droppedCode);
|
||||
connect(ui->tb_Paste, &QToolButton::clicked, this, &CAircraftIcaoForm::ps_pasted);
|
||||
ui->drop_DropData->setInfoText("<drop aircraft ICAO code>");
|
||||
ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CAircraftIcaoCode>(), qMetaTypeId<CAircraftIcaoCodeList>()});
|
||||
}
|
||||
@@ -89,6 +90,23 @@ namespace BlackGui
|
||||
return true;
|
||||
}
|
||||
|
||||
void CAircraftIcaoForm::jsonPasted(const QString &json)
|
||||
{
|
||||
try
|
||||
{
|
||||
CAircraftIcaoCodeList icaos;
|
||||
icaos.convertFromJson(Json::jsonObjectFromString(json));
|
||||
if (!icaos.isEmpty())
|
||||
{
|
||||
this->setValue(icaos.front());
|
||||
}
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
Q_UNUSED(ex);
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftIcaoCode CAircraftIcaoForm::getValue() const
|
||||
{
|
||||
CAircraftIcaoCode icao(ui->aircraft_Selector->getAircraftIcao());
|
||||
@@ -159,6 +177,7 @@ namespace BlackGui
|
||||
ui->le_Family->setReadOnly(readOnly);
|
||||
ui->le_Iata->setReadOnly(readOnly);
|
||||
ui->le_Id->setReadOnly(readOnly);
|
||||
ui->tb_Paste->setVisible(!readOnly);
|
||||
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Legacy, readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
|
||||
@@ -173,6 +192,7 @@ namespace BlackGui
|
||||
void CAircraftIcaoForm::setSelectOnly()
|
||||
{
|
||||
this->setReadOnly(true);
|
||||
ui->tb_Paste->setVisible(true);
|
||||
ui->aircraft_Selector->setReadOnly(false);
|
||||
ui->le_Id->setReadOnly(false);
|
||||
ui->drop_DropData->setVisible(true);
|
||||
|
||||
@@ -69,6 +69,10 @@ namespace BlackGui
|
||||
//! Set value
|
||||
bool setValue(const BlackMisc::Aviation::CAircraftIcaoCode &icao);
|
||||
|
||||
protected:
|
||||
//! \copydoc CForm::jsonPasted
|
||||
virtual void jsonPasted(const QString &json) override;
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
@@ -41,90 +41,6 @@
|
||||
<string>Aircraft ICAO</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_AircraftIcao" columnstretch="0,1,0">
|
||||
<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="focusPolicy">
|
||||
<enum>Qt::StrongFocus</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="0" column="2" rowspan="9">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="sizePolicy">
|
||||
@@ -147,10 +63,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="BlackGui::Components::CAircraftCombinedTypeSelector" name="combined_TypeSelector">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
<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>
|
||||
@@ -242,130 +167,6 @@
|
||||
</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="0">
|
||||
<widget class="QLabel" name="lbl_IataFamily">
|
||||
<property name="text">
|
||||
<string>IATA/family:</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="3" column="1">
|
||||
<widget class="QLineEdit" name="le_Manufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. Boeing, Airbus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_ModelDescription">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_ModelDescription</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_MiscFlags">
|
||||
<property name="text">
|
||||
<string>Misc.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_CombinedCode">
|
||||
<property name="toolTip">
|
||||
<string>Type / Engine / Engine count</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comb. type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="placeholderText">
|
||||
<string>Aircraft model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Last updated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Updated</cstring>
|
||||
</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="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Manufacturer">
|
||||
<property name="text">
|
||||
<string>Manufacturer:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Manufacturer</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="wi_IataFamily" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_IataFamily">
|
||||
@@ -407,6 +208,247 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<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="focusPolicy">
|
||||
<enum>Qt::StrongFocus</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="5" column="1">
|
||||
<widget class="BlackGui::Components::CAircraftCombinedTypeSelector" name="combined_TypeSelector">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QWidget" name="wi_IdPaste" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_IdPaste">
|
||||
<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="QToolButton" name="tb_Paste">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_IdPaste">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_IataFamily">
|
||||
<property name="text">
|
||||
<string>IATA/family:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_ModelDescription">
|
||||
<property name="text">
|
||||
<string>Model:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_ModelDescription</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="le_Manufacturer">
|
||||
<property name="placeholderText">
|
||||
<string>e.g. Boeing, Airbus</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="le_ModelDescription">
|
||||
<property name="placeholderText">
|
||||
<string>Aircraft model</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Last updated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_MiscFlags">
|
||||
<property name="text">
|
||||
<string>Misc.:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_CombinedCode">
|
||||
<property name="toolTip">
|
||||
<string>Type / Engine / Engine count</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Comb. type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Manufacturer">
|
||||
<property name="text">
|
||||
<string>Manufacturer:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Manufacturer</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Updated</cstring>
|
||||
</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="8" column="0" colspan="2">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -444,7 +486,6 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>le_Id</tabstop>
|
||||
<tabstop>aircraft_Selector</tabstop>
|
||||
<tabstop>cb_Rank</tabstop>
|
||||
<tabstop>le_Iata</tabstop>
|
||||
@@ -458,6 +499,8 @@
|
||||
<tabstop>cb_Military</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace BlackGui
|
||||
// Id
|
||||
connect(ui->le_Id, &QLineEdit::returnPressed, this, &CAirlineIcaoForm::ps_idEntered);
|
||||
|
||||
// drag and drop
|
||||
// drag and drop, paste
|
||||
connect(ui->tb_Paste, &QToolButton::clicked, this, &CAirlineIcaoForm::ps_pasted);
|
||||
connect(ui->drop_DropData, &CDropSite::droppedValueObject, this, &CAirlineIcaoForm::ps_droppedCode);
|
||||
ui->drop_DropData->setInfoText("<drop airline ICAO code>");
|
||||
ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CAirlineIcaoCode>(), qMetaTypeId<CAirlineIcaoCodeList>()});
|
||||
@@ -75,6 +76,9 @@ namespace BlackGui
|
||||
ui->country_Selector->setCountry(icao.getCountry());
|
||||
ui->lbl_AirlineIcon->setPixmap(icao.toPixmap());
|
||||
|
||||
// sometimes artefacts when icon is displayed
|
||||
this->repaint();
|
||||
|
||||
if (this->m_originalCode.hasCompleteData())
|
||||
{
|
||||
emit airlineChanged(this->m_originalCode);
|
||||
@@ -125,6 +129,7 @@ namespace BlackGui
|
||||
ui->le_TelephonyDesignator->setReadOnly(readOnly);
|
||||
ui->country_Selector->setReadOnly(readOnly);
|
||||
ui->drop_DropData->setVisible(!readOnly);
|
||||
ui->tb_Paste->setVisible(!readOnly);
|
||||
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Va, readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
|
||||
@@ -137,6 +142,7 @@ namespace BlackGui
|
||||
ui->selector_AirlineDesignator->setReadOnly(false);
|
||||
ui->selector_AirlineName->setReadOnly(false);
|
||||
ui->drop_DropData->setVisible(true);
|
||||
ui->tb_Paste->setVisible(true);
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::clear()
|
||||
@@ -149,6 +155,23 @@ namespace BlackGui
|
||||
this->setValue(m_originalCode);
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::jsonPasted(const QString &json)
|
||||
{
|
||||
try
|
||||
{
|
||||
CAirlineIcaoCodeList icaos;
|
||||
icaos.convertFromJson(Json::jsonObjectFromString(json));
|
||||
if (!icaos.isEmpty())
|
||||
{
|
||||
this->setValue(icaos.front());
|
||||
}
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
Q_UNUSED(ex);
|
||||
}
|
||||
}
|
||||
|
||||
void CAirlineIcaoForm::ps_droppedCode(const BlackMisc::CVariant &variantDropped)
|
||||
{
|
||||
CAirlineIcaoCode icao;
|
||||
|
||||
@@ -73,6 +73,10 @@ namespace BlackGui
|
||||
//! Airline has been changed
|
||||
void airlineChanged(const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcao);
|
||||
|
||||
protected:
|
||||
//! \copydoc CForm::jsonPasted
|
||||
virtual void jsonPasted(const QString &json) override;
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>233</width>
|
||||
<height>205</height>
|
||||
<width>243</width>
|
||||
<height>206</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -107,6 +107,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_Paste">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_AirlineIcon">
|
||||
<property name="text">
|
||||
@@ -205,7 +216,7 @@
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated</string>
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>le_Updated</cstring>
|
||||
@@ -310,6 +321,8 @@
|
||||
<tabstop>country_Selector</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -62,6 +62,11 @@ namespace BlackGui
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDistributorForm::jsonPasted(const QString &json)
|
||||
{
|
||||
Q_UNUSED(json);
|
||||
}
|
||||
|
||||
CDistributor CDistributorForm::getValue() const
|
||||
{
|
||||
CDistributor distributor(ui->distributor_Selector->getDistributor());
|
||||
@@ -126,9 +131,9 @@ namespace BlackGui
|
||||
}
|
||||
else if (variantDropped.canConvert<CDistributorList>())
|
||||
{
|
||||
CDistributorList icaoList(variantDropped.value<CDistributorList>());
|
||||
if (icaoList.isEmpty()) { return; }
|
||||
distributor = icaoList.front();
|
||||
const CDistributorList icaoList(variantDropped.value<CDistributorList>());
|
||||
if (icaoList.isEmpty()) { return; }
|
||||
distributor = icaoList.front();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -136,6 +141,5 @@ namespace BlackGui
|
||||
}
|
||||
this->setValue(distributor);
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackGui
|
||||
explicit CDistributorForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CDistributorForm();
|
||||
virtual ~CDistributorForm();
|
||||
|
||||
//! Get value
|
||||
BlackMisc::Simulation::CDistributor getValue() const;
|
||||
@@ -66,6 +66,10 @@ namespace BlackGui
|
||||
//! Set value
|
||||
bool setValue(const BlackMisc::Simulation::CDistributor &distributor = BlackMisc::Simulation::CDistributor());
|
||||
|
||||
protected:
|
||||
//! \copydoc CForm::jsonPasted
|
||||
virtual void jsonPasted(const QString &json) override;
|
||||
|
||||
private slots:
|
||||
//! Variant has been dropped
|
||||
void ps_droppedCode(const BlackMisc::CVariant &variantDropped);
|
||||
@@ -74,7 +78,6 @@ namespace BlackGui
|
||||
QScopedPointer<Ui::CDistributorForm> ui;
|
||||
bool m_readOnly = false;
|
||||
};
|
||||
|
||||
} // ns
|
||||
} //ns
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
<string>Last updated</string>
|
||||
<string>Last updated:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -8,6 +8,9 @@
|
||||
*/
|
||||
|
||||
#include "blackgui/editors/form.h"
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QShortcut>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -17,7 +20,7 @@ namespace BlackGui
|
||||
namespace Editors
|
||||
{
|
||||
CForm::CForm(QWidget *parent) : COverlayMessagesFrame(parent)
|
||||
{ }
|
||||
{ }
|
||||
|
||||
CForm::~CForm() { }
|
||||
|
||||
@@ -37,9 +40,22 @@ namespace BlackGui
|
||||
return this->m_swiftDbUser.get();
|
||||
}
|
||||
|
||||
void CForm::jsonPasted(const QString &json)
|
||||
{
|
||||
Q_UNUSED(json);
|
||||
}
|
||||
|
||||
void CForm::ps_userChanged()
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
void CForm::ps_pasted()
|
||||
{
|
||||
if (!QApplication::clipboard()) { return; }
|
||||
const QString data = QApplication::clipboard()->text();
|
||||
if (!Json::looksLikeSwiftJson(data)) { return; }
|
||||
this->jsonPasted(data);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace BlackGui
|
||||
explicit CForm(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CForm();
|
||||
virtual ~CForm();
|
||||
|
||||
//! Set editable
|
||||
virtual void setReadOnly(bool readOnly) = 0;
|
||||
@@ -56,12 +56,19 @@ namespace BlackGui
|
||||
BlackMisc::Network::CAuthenticatedUser getSwiftDbUser() const;
|
||||
|
||||
protected:
|
||||
//! JSON string has been pasted
|
||||
//! \remark The JSON string has been pre-checked
|
||||
virtual void jsonPasted(const QString &json);
|
||||
|
||||
bool m_readOnly = false; //!< read only
|
||||
BlackMisc::CDataReadOnly<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser {this, &CForm::ps_userChanged}; //!< authenticated user
|
||||
|
||||
protected slots:
|
||||
//! User has been changed
|
||||
virtual void ps_userChanged();
|
||||
|
||||
//! Pasted from clipboard
|
||||
void ps_pasted();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -52,7 +52,8 @@ namespace BlackGui
|
||||
// selector
|
||||
connect(ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue);
|
||||
|
||||
// drag and drop
|
||||
// drag and drop, paste
|
||||
connect(ui->tb_Paste, &QToolButton::clicked, this, &CLiveryForm::ps_pasted);
|
||||
connect(ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery);
|
||||
ui->drop_DropData->setInfoText("<drop livery>");
|
||||
ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CLivery>(), qMetaTypeId<CLiveryList>()});
|
||||
@@ -112,6 +113,23 @@ namespace BlackGui
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLiveryForm::jsonPasted(const QString &json)
|
||||
{
|
||||
try
|
||||
{
|
||||
CLiveryList liveries;
|
||||
liveries.convertFromJson(Json::jsonObjectFromString(json));
|
||||
if (!liveries.isEmpty())
|
||||
{
|
||||
this->setValue(liveries.front());
|
||||
}
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
Q_UNUSED(ex);
|
||||
}
|
||||
}
|
||||
|
||||
CStatusMessageList CLiveryForm::validate(bool withNestedForms) const
|
||||
{
|
||||
CLivery livery(getValue());
|
||||
@@ -161,6 +179,7 @@ namespace BlackGui
|
||||
ui->pb_SearchColor->setVisible(!readOnly);
|
||||
ui->pb_TempLivery->setVisible(!readOnly);
|
||||
ui->drop_DropData->setVisible(!readOnly);
|
||||
ui->tb_Paste->setVisible(!readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
|
||||
}
|
||||
|
||||
@@ -173,6 +192,7 @@ namespace BlackGui
|
||||
ui->drop_DropData->setVisible(true);
|
||||
ui->pb_SearchColor->setVisible(true);
|
||||
ui->pb_TempLivery->setVisible(true);
|
||||
ui->tb_Paste->setVisible(true);
|
||||
}
|
||||
|
||||
void CLiveryForm::clear()
|
||||
|
||||
@@ -76,6 +76,10 @@ namespace BlackGui
|
||||
//! Value
|
||||
bool setValue(const BlackMisc::Aviation::CLivery &livery);
|
||||
|
||||
protected:
|
||||
//! \copydoc CForm::jsonPasted
|
||||
virtual void jsonPasted(const QString &json) override;
|
||||
|
||||
private slots:
|
||||
//! Livery dropped
|
||||
void ps_droppedLivery(const BlackMisc::CVariant &variantDropped);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<property name="title">
|
||||
<string>Livery</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gl_Livery" columnstretch="0,1,1,1,0">
|
||||
<layout class="QGridLayout" name="gl_Livery" columnstretch="0,1,1,1,0,0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbl_Timestamp">
|
||||
<property name="text">
|
||||
@@ -45,6 +45,13 @@
|
||||
</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="0">
|
||||
<widget class="QLabel" name="lbl_Description">
|
||||
<property name="text">
|
||||
@@ -55,6 +62,13 @@
|
||||
</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="0" column="1">
|
||||
<widget class="QLineEdit" name="le_Id">
|
||||
<property name="maximumSize">
|
||||
@@ -68,52 +82,7 @@
|
||||
</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="3" column="0">
|
||||
<widget class="QLabel" name="lbl_FuselageColor">
|
||||
<property name="text">
|
||||
<string>Fuselage/Tail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>Livery description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="4">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QCheckBox" name="cb_Military">
|
||||
<property name="toolTip">
|
||||
<string>Military livery</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mil.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pb_TempLivery">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>set a 'no color' livery, allowing to create a<br/>temp. DB entry which will later be specified.</p></body></html></string>
|
||||
@@ -123,7 +92,64 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4" rowspan="7">
|
||||
<item row="2" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="le_Description">
|
||||
<property name="placeholderText">
|
||||
<string>Livery description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="5">
|
||||
<widget class="BlackGui::CDropSite" name="drop_DropData">
|
||||
<property name="text">
|
||||
<string>Drop data here</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="QCheckBox" name="cb_Military">
|
||||
<property name="toolTip">
|
||||
<string>Military livery</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mil.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="4">
|
||||
<widget class="QLineEdit" name="le_Updated">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pb_SearchColor">
|
||||
<property name="toolTip">
|
||||
<string>find a color livery</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>search color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="5">
|
||||
<widget class="BlackGui::Editors::CAirlineIcaoForm" name="editor_AirlineIcao">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>225</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id"/>
|
||||
</item>
|
||||
<item row="0" column="5" rowspan="7">
|
||||
<widget class="BlackGui::Editors::CValidationIndicator" name="val_Indicator">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -139,23 +165,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BlackGui::CLabelAndIcon" name="lai_Id"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="4">
|
||||
<widget class="BlackGui::Editors::CAirlineIcaoForm" name="editor_AirlineIcao">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>225</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<item row="3" column="1" colspan="4">
|
||||
<widget class="QWidget" name="wi_Colors" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_Colors">
|
||||
<property name="spacing">
|
||||
@@ -215,23 +225,24 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_SearchColor">
|
||||
<property name="toolTip">
|
||||
<string>find a color livery</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>search color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<item row="1" column="1" colspan="3">
|
||||
<widget class="BlackGui::Components::CDbLiverySelectorComponent" name="comp_LiverySelector">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="tb_Paste">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../blackmisc/blackmisc.qrc">
|
||||
<normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</normaloff>:/diagona/icons/diagona/icons/clipboard-paste.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -285,6 +296,8 @@
|
||||
<tabstop>color_Tail</tabstop>
|
||||
<tabstop>le_Updated</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../blackmisc/blackmisc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user