refs #734, allow to set temp.livery

This commit is contained in:
Klaus Basan
2016-08-22 21:48:15 +02:00
committed by Mathew Sutcliffe
parent 4e381a048f
commit f1cd73a268
6 changed files with 71 additions and 40 deletions

View File

@@ -41,44 +41,47 @@ namespace BlackGui
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:");
this->ui->comp_LiverySelector->withLiveryDescription(false);
ui->le_Id->setReadOnly(true);
ui->le_Updated->setReadOnly(true);
ui->lai_Id->set(CIcons::appLiveries16(), "Id:");
ui->comp_LiverySelector->withLiveryDescription(false);
// selector
connect(this->ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue);
connect(ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue);
// 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>()});
connect(ui->drop_DropData, &CDropSite::droppedValueObject, this, &CLiveryForm::ps_droppedLivery);
ui->drop_DropData->setInfoText("<drop livery>");
ui->drop_DropData->setAcceptedMetaTypeIds({ qMetaTypeId<CLivery>(), qMetaTypeId<CLiveryList>()});
// 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() { }
CLivery CLiveryForm::getValue() const
{
CLivery livery(this->ui->comp_LiverySelector->getLivery());
CLivery livery(ui->comp_LiverySelector->getLivery());
if (livery.hasCompleteData() && livery.hasValidDbKey())
{
// already complete data from selector
return livery;
}
CAirlineIcaoCode airline(this->ui->editor_AirlineIcao->getValue());
CAirlineIcaoCode airline(ui->editor_AirlineIcao->getValue());
livery.setAirlineIcaoCode(airline);
livery.setDescription(this->ui->le_Description->text());
livery.setMilitary(this->ui->cb_Military->isChecked());
livery.setDescription(ui->le_Description->text());
livery.setMilitary(ui->cb_Military->isChecked());
return livery;
}
CAirlineIcaoCode CLiveryForm::getValueAirlineIcao() const
{
return this->ui->editor_AirlineIcao->getValue();
return ui->editor_AirlineIcao->getValue();
}
bool CLiveryForm::setValue(const CLivery &livery)
@@ -86,21 +89,21 @@ namespace BlackGui
if (this->m_originalLivery == livery) { return false; }
this->m_originalLivery = livery;
this->ui->comp_LiverySelector->setLivery(livery);
this->ui->le_Id->setText(livery.getDbKeyAsString());
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->cb_Military->setChecked(livery.isMilitary());
ui->comp_LiverySelector->setLivery(livery);
ui->le_Id->setText(livery.getDbKeyAsString());
ui->le_Description->setText(livery.getDescription());
ui->le_Updated->setText(livery.getFormattedUtcTimestampYmdhms());
ui->color_Fuselage->setColor(livery.getColorFuselage());
ui->color_Tail->setColor(livery.getColorTail());
ui->cb_Military->setChecked(livery.isMilitary());
if (livery.isColorLivery())
{
this->ui->editor_AirlineIcao->clear();
ui->editor_AirlineIcao->clear();
}
else
{
this->ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
ui->editor_AirlineIcao->setValue(livery.getAirlineIcaoCode());
}
return true;
}
@@ -113,7 +116,7 @@ namespace BlackGui
{
if (!livery.isColorLivery())
{
msgs.push_back(this->ui->editor_AirlineIcao->validate());
msgs.push_back(ui->editor_AirlineIcao->validate());
}
}
if (this->isReadOnly())
@@ -121,41 +124,41 @@ namespace BlackGui
// in readonly I cannot change the data anyway, so skip warnings
msgs.removeWarningsAndBelow();
}
this->ui->val_Indicator->setState(msgs);
ui->val_Indicator->setState(msgs);
return msgs;
}
CStatusMessageList CLiveryForm::validateAirlineIcao() const
{
return this->ui->editor_AirlineIcao->validate();
return ui->editor_AirlineIcao->validate();
}
void CLiveryForm::allowDrop(bool allowDrop)
{
this->ui->drop_DropData->allowDrop(allowDrop);
ui->drop_DropData->allowDrop(allowDrop);
}
bool CLiveryForm::isDropAllowed() const
{
return this->ui->drop_DropData->isDropAllowed();
return ui->drop_DropData->isDropAllowed();
}
void CLiveryForm::setReadOnly(bool readOnly)
{
this->m_readOnly = readOnly;
this->ui->comp_LiverySelector->setReadOnly(readOnly);
this->ui->le_Description->setReadOnly(readOnly);
this->ui->color_Fuselage->setReadOnly(readOnly);
this->ui->color_Tail->setReadOnly(readOnly);
this->ui->editor_AirlineIcao->setReadOnly(readOnly);
CGuiUtility::checkBoxReadOnly(this->ui->cb_Military, readOnly);
ui->comp_LiverySelector->setReadOnly(readOnly);
ui->le_Description->setReadOnly(readOnly);
ui->color_Fuselage->setReadOnly(readOnly);
ui->color_Tail->setReadOnly(readOnly);
ui->editor_AirlineIcao->setReadOnly(readOnly);
CGuiUtility::checkBoxReadOnly(ui->cb_Military, readOnly);
}
void CLiveryForm::setSelectOnly()
{
this->setReadOnly(true);
this->ui->comp_LiverySelector->setReadOnly(false);
this->ui->editor_AirlineIcao->setSelectOnly();
ui->comp_LiverySelector->setReadOnly(false);
ui->editor_AirlineIcao->setSelectOnly();
}
void CLiveryForm::clear()
@@ -191,5 +194,15 @@ namespace BlackGui
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

View File

@@ -80,6 +80,9 @@ namespace BlackGui
//! Airline of embedded form has changed
void ps_airlineChanged(const BlackMisc::Aviation::CAirlineIcaoCode &code);
//! Set data for a temp.livery
void ps_setTemporaryLivery();
private:
QScopedPointer<Ui::CLiveryForm> ui;
BlackMisc::Aviation::CLivery m_originalLivery; //!< object allowing to override values

View File

@@ -209,6 +209,13 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_TempLivery">
<property name="text">
<string>temp.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@@ -236,6 +236,12 @@ namespace BlackMisc
return s;
}
const QString &CLivery::tempLiveryCode()
{
static const QString temp("_CC_NOCOLOR");
return temp;
}
CVariant CLivery::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
{
if (index.isMyself()) { return CVariant::from(*this); }

View File

@@ -173,13 +173,16 @@ namespace BlackMisc
//! Color livery marker
static const QString &colorLiveryMarker();
//! The code for a temporary livery
static const QString &tempLiveryCode();
private:
CAirlineIcaoCode m_airline; //!< corresponding airline, if any
QString m_combinedCode; //!< livery code and pseudo airline ICAO code
QString m_description; //!< describes the livery
BlackMisc::CRgbColor m_colorFuselage; //! color of fuselage
BlackMisc::CRgbColor m_colorTail; //! color of tail
bool m_military = false; //! Military livery?
BlackMisc::CRgbColor m_colorFuselage; //!< color of fuselage
BlackMisc::CRgbColor m_colorTail; //!< color of tail
bool m_military = false; //!< military livery?
BLACK_METACLASS(
CLivery,

View File

@@ -23,7 +23,6 @@ namespace BlackMisc
{
namespace Aviation
{
CLiveryList::CLiveryList() { }
CLiveryList::CLiveryList(const CSequence<CLivery> &other) :