mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
refs #734, allow to set temp.livery
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4e381a048f
commit
f1cd73a268
@@ -41,44 +41,47 @@ namespace BlackGui
|
|||||||
ui(new Ui::CLiveryForm)
|
ui(new Ui::CLiveryForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->ui->le_Id->setReadOnly(true);
|
ui->le_Id->setReadOnly(true);
|
||||||
this->ui->le_Updated->setReadOnly(true);
|
ui->le_Updated->setReadOnly(true);
|
||||||
this->ui->lai_Id->set(CIcons::appLiveries16(), "Id:");
|
ui->lai_Id->set(CIcons::appLiveries16(), "Id:");
|
||||||
this->ui->comp_LiverySelector->withLiveryDescription(false);
|
ui->comp_LiverySelector->withLiveryDescription(false);
|
||||||
|
|
||||||
// selector
|
// selector
|
||||||
connect(this->ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue);
|
connect(ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue);
|
||||||
|
|
||||||
// drag and drop
|
// drag and drop
|
||||||
connect(this->ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery);
|
connect(ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery);
|
||||||
this->ui->drop_DropData->setInfoText("<drop livery>");
|
ui->drop_DropData->setInfoText("<drop livery>");
|
||||||
this->ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CLivery>(), qMetaTypeId<CLiveryList>()});
|
ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CLivery>(), qMetaTypeId<CLiveryList>()});
|
||||||
|
|
||||||
// embedded form
|
// embedded form
|
||||||
connect(this->ui->editor_AirlineIcao, &CAirlineIcaoForm::airlineChanged, this, &CLiveryForm::ps_airlineChanged);
|
connect(ui->editor_AirlineIcao, &CAirlineIcaoForm::airlineChanged, this, &CLiveryForm::ps_airlineChanged);
|
||||||
|
|
||||||
|
// Set as temp.livery
|
||||||
|
connect(ui->pb_TempLivery, &QPushButton::pressed, this, &CLiveryForm::ps_setTemporaryLivery);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLiveryForm::~CLiveryForm() { }
|
CLiveryForm::~CLiveryForm() { }
|
||||||
|
|
||||||
CLivery CLiveryForm::getValue() const
|
CLivery CLiveryForm::getValue() const
|
||||||
{
|
{
|
||||||
CLivery livery(this->ui->comp_LiverySelector->getLivery());
|
CLivery livery(ui->comp_LiverySelector->getLivery());
|
||||||
if (livery.hasCompleteData() && livery.hasValidDbKey())
|
if (livery.hasCompleteData() && livery.hasValidDbKey())
|
||||||
{
|
{
|
||||||
// already complete data from selector
|
// already complete data from selector
|
||||||
return livery;
|
return livery;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue());
|
CAirlineIcaoCode airline(ui->editor_AirlineIcao->getValue());
|
||||||
livery.setAirlineIcaoCode(airline);
|
livery.setAirlineIcaoCode(airline);
|
||||||
livery.setDescription(this->ui->le_Description->text());
|
livery.setDescription(ui->le_Description->text());
|
||||||
livery.setMilitary(this->ui->cb_Military->isChecked());
|
livery.setMilitary(ui->cb_Military->isChecked());
|
||||||
return livery;
|
return livery;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAirlineIcaoCode CLiveryForm::getValueAirlineIcao() const
|
CAirlineIcaoCode CLiveryForm::getValueAirlineIcao() const
|
||||||
{
|
{
|
||||||
return this->ui->editor_AirlineIcao->getValue();
|
return ui->editor_AirlineIcao->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLiveryForm::setValue(const CLivery &livery)
|
bool CLiveryForm::setValue(const CLivery &livery)
|
||||||
@@ -86,21 +89,21 @@ namespace BlackGui
|
|||||||
if (this->m_originalLivery == livery) { return false; }
|
if (this->m_originalLivery == livery) { return false; }
|
||||||
|
|
||||||
this->m_originalLivery = livery;
|
this->m_originalLivery = livery;
|
||||||
this->ui->comp_LiverySelector->setLivery(livery);
|
ui->comp_LiverySelector->setLivery(livery);
|
||||||
this->ui->le_Id->setText(livery.getDbKeyAsString());
|
ui->le_Id->setText(livery.getDbKeyAsString());
|
||||||
this->ui->le_Description->setText(livery.getDescription());
|
ui->le_Description->setText(livery.getDescription());
|
||||||
this->ui->le_Updated->setText(livery.getFormattedUtcTimestampYmdhms());
|
ui->le_Updated->setText(livery.getFormattedUtcTimestampYmdhms());
|
||||||
this->ui->color_Fuselage->setColor(livery.getColorFuselage());
|
ui->color_Fuselage->setColor(livery.getColorFuselage());
|
||||||
this->ui->color_Tail->setColor(livery.getColorTail());
|
ui->color_Tail->setColor(livery.getColorTail());
|
||||||
this->ui->cb_Military->setChecked(livery.isMilitary());
|
ui->cb_Military->setChecked(livery.isMilitary());
|
||||||
|
|
||||||
if (livery.isColorLivery())
|
if (livery.isColorLivery())
|
||||||
{
|
{
|
||||||
this->ui->editor_AirlineIcao->clear();
|
ui->editor_AirlineIcao->clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
|
ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -113,7 +116,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (!livery.isColorLivery())
|
if (!livery.isColorLivery())
|
||||||
{
|
{
|
||||||
msgs.push_back(this->ui->editor_AirlineIcao->validate());
|
msgs.push_back(ui->editor_AirlineIcao->validate());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this->isReadOnly())
|
if (this->isReadOnly())
|
||||||
@@ -121,41 +124,41 @@ namespace BlackGui
|
|||||||
// in readonly I cannot change the data anyway, so skip warnings
|
// in readonly I cannot change the data anyway, so skip warnings
|
||||||
msgs.removeWarningsAndBelow();
|
msgs.removeWarningsAndBelow();
|
||||||
}
|
}
|
||||||
this->ui->val_Indicator->setState(msgs);
|
ui->val_Indicator->setState(msgs);
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList CLiveryForm::validateAirlineIcao() const
|
CStatusMessageList CLiveryForm::validateAirlineIcao() const
|
||||||
{
|
{
|
||||||
return this->ui->editor_AirlineIcao->validate();
|
return ui->editor_AirlineIcao->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLiveryForm::allowDrop(bool allowDrop)
|
void CLiveryForm::allowDrop(bool allowDrop)
|
||||||
{
|
{
|
||||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
ui->drop_DropData->allowDrop(allowDrop);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CLiveryForm::isDropAllowed() const
|
bool CLiveryForm::isDropAllowed() const
|
||||||
{
|
{
|
||||||
return this->ui->drop_DropData->isDropAllowed();
|
return ui->drop_DropData->isDropAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLiveryForm::setReadOnly(bool readOnly)
|
void CLiveryForm::setReadOnly(bool readOnly)
|
||||||
{
|
{
|
||||||
this->m_readOnly = readOnly;
|
this->m_readOnly = readOnly;
|
||||||
this->ui->comp_LiverySelector->setReadOnly(readOnly);
|
ui->comp_LiverySelector->setReadOnly(readOnly);
|
||||||
this->ui->le_Description->setReadOnly(readOnly);
|
ui->le_Description->setReadOnly(readOnly);
|
||||||
this->ui->color_Fuselage->setReadOnly(readOnly);
|
ui->color_Fuselage->setReadOnly(readOnly);
|
||||||
this->ui->color_Tail->setReadOnly(readOnly);
|
ui->color_Tail->setReadOnly(readOnly);
|
||||||
this->ui->editor_AirlineIcao->setReadOnly(readOnly);
|
ui->editor_AirlineIcao->setReadOnly(readOnly);
|
||||||
CGuiUtility::checkBoxReadOnly(this->ui->cb_Military, readOnly);
|
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLiveryForm::setSelectOnly()
|
void CLiveryForm::setSelectOnly()
|
||||||
{
|
{
|
||||||
this->setReadOnly(true);
|
this->setReadOnly(true);
|
||||||
this->ui->comp_LiverySelector->setReadOnly(false);
|
ui->comp_LiverySelector->setReadOnly(false);
|
||||||
this->ui->editor_AirlineIcao->setSelectOnly();
|
ui->editor_AirlineIcao->setSelectOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLiveryForm::clear()
|
void CLiveryForm::clear()
|
||||||
@@ -191,5 +194,15 @@ namespace BlackGui
|
|||||||
this->setValue(stdLivery);
|
this->setValue(stdLivery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CLiveryForm::ps_setTemporaryLivery()
|
||||||
|
{
|
||||||
|
if (!sGui || !sGui->hasWebDataServices()) { return; }
|
||||||
|
const CLivery l = sGui->getWebDataServices()->getLiveryForCombinedCode(CLivery::tempLiveryCode());
|
||||||
|
if (l.isLoadedFromDb())
|
||||||
|
{
|
||||||
|
this->setValue(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ namespace BlackGui
|
|||||||
//! Airline of embedded form has changed
|
//! Airline of embedded form has changed
|
||||||
void ps_airlineChanged(const BlackMisc::Aviation::CAirlineIcaoCode &code);
|
void ps_airlineChanged(const BlackMisc::Aviation::CAirlineIcaoCode &code);
|
||||||
|
|
||||||
|
//! Set data for a temp.livery
|
||||||
|
void ps_setTemporaryLivery();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CLiveryForm> ui;
|
QScopedPointer<Ui::CLiveryForm> ui;
|
||||||
BlackMisc::Aviation::CLivery m_originalLivery; //!< object allowing to override values
|
BlackMisc::Aviation::CLivery m_originalLivery; //!< object allowing to override values
|
||||||
|
|||||||
@@ -209,6 +209,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QPushButton" name="pb_TempLivery">
|
||||||
|
<property name="text">
|
||||||
|
<string>temp.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -236,6 +236,12 @@ namespace BlackMisc
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CLivery::tempLiveryCode()
|
||||||
|
{
|
||||||
|
static const QString temp("_CC_NOCOLOR");
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
CVariant CLivery::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
CVariant CLivery::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||||
{
|
{
|
||||||
if (index.isMyself()) { return CVariant::from(*this); }
|
if (index.isMyself()) { return CVariant::from(*this); }
|
||||||
|
|||||||
@@ -173,13 +173,16 @@ namespace BlackMisc
|
|||||||
//! Color livery marker
|
//! Color livery marker
|
||||||
static const QString &colorLiveryMarker();
|
static const QString &colorLiveryMarker();
|
||||||
|
|
||||||
|
//! The code for a temporary livery
|
||||||
|
static const QString &tempLiveryCode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CAirlineIcaoCode m_airline; //!< corresponding airline, if any
|
CAirlineIcaoCode m_airline; //!< corresponding airline, if any
|
||||||
QString m_combinedCode; //!< livery code and pseudo airline ICAO code
|
QString m_combinedCode; //!< livery code and pseudo airline ICAO code
|
||||||
QString m_description; //!< describes the livery
|
QString m_description; //!< describes the livery
|
||||||
BlackMisc::CRgbColor m_colorFuselage; //! color of fuselage
|
BlackMisc::CRgbColor m_colorFuselage; //!< color of fuselage
|
||||||
BlackMisc::CRgbColor m_colorTail; //! color of tail
|
BlackMisc::CRgbColor m_colorTail; //!< color of tail
|
||||||
bool m_military = false; //! Military livery?
|
bool m_military = false; //!< military livery?
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CLivery,
|
CLivery,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
|
||||||
CLiveryList::CLiveryList() { }
|
CLiveryList::CLiveryList() { }
|
||||||
|
|
||||||
CLiveryList::CLiveryList(const CSequence<CLivery> &other) :
|
CLiveryList::CLiveryList(const CSequence<CLivery> &other) :
|
||||||
|
|||||||
Reference in New Issue
Block a user