From 317b52a00bd20a26b377cde2b3a3703f1ffd0123 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 22 Mar 2017 04:03:09 +0100 Subject: [PATCH] refs #911, livery form fixed * search buttons in select mode * id can be entered --- src/blackgui/editors/liveryform.cpp | 38 ++++++++++++++++++++++++++--- src/blackgui/editors/liveryform.h | 8 +++++- src/blackgui/editors/liveryform.ui | 9 ++++--- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/blackgui/editors/liveryform.cpp b/src/blackgui/editors/liveryform.cpp index 9a0905f4a..2d2015ec9 100644 --- a/src/blackgui/editors/liveryform.cpp +++ b/src/blackgui/editors/liveryform.cpp @@ -7,7 +7,8 @@ * contained in the LICENSE file. */ -#include "blackcore/webdataservices.h" +#include "liveryform.h" +#include "ui_liveryform.h" #include "blackgui/components/colorselector.h" #include "blackgui/components/dbliveryselectorcomponent.h" #include "blackgui/dropsite.h" @@ -17,11 +18,10 @@ #include "blackgui/guiapplication.h" #include "blackgui/guiutility.h" #include "blackgui/labelandicon.h" +#include "blackcore/webdataservices.h" #include "blackmisc/aviation/liverylist.h" #include "blackmisc/compare.h" #include "blackmisc/icons.h" -#include "liveryform.h" -#include "ui_liveryform.h" #include #include @@ -41,11 +41,14 @@ namespace BlackGui ui(new Ui::CLiveryForm) { ui->setupUi(this); - ui->le_Id->setReadOnly(true); ui->le_Updated->setReadOnly(true); + ui->le_Id->setValidator(new QIntValidator(0, 999999, ui->le_Id)); ui->lai_Id->set(CIcons::appLiveries16(), "Id:"); ui->comp_LiverySelector->withLiveryDescription(false); + // Id + connect(ui->le_Id, &QLineEdit::returnPressed, this, &CLiveryForm::ps_idEntered); + // selector connect(ui->comp_LiverySelector, &CDbLiverySelectorComponent::changedLivery, this, &CLiveryForm::setValue); @@ -149,6 +152,7 @@ namespace BlackGui void CLiveryForm::setReadOnly(bool readOnly) { this->m_readOnly = readOnly; + ui->le_Id->setReadOnly(readOnly); ui->comp_LiverySelector->setReadOnly(readOnly); ui->le_Description->setReadOnly(readOnly); ui->color_Fuselage->setReadOnly(readOnly); @@ -164,8 +168,11 @@ namespace BlackGui { this->setReadOnly(true); ui->comp_LiverySelector->setReadOnly(false); + ui->le_Id->setReadOnly(false); ui->editor_AirlineIcao->setSelectOnly(); ui->drop_DropData->setVisible(true); + ui->pb_SearchColor->setVisible(true); + ui->pb_TempLivery->setVisible(true); } void CLiveryForm::clear() @@ -173,6 +180,11 @@ namespace BlackGui this->setValue(CLivery()); } + void CLiveryForm::resetValue() + { + this->setValue(m_originalLivery); + } + void CLiveryForm::ps_droppedLivery(const BlackMisc::CVariant &variantDropped) { CLivery livery; @@ -227,5 +239,23 @@ namespace BlackGui this->setValue(found); } } + + void CLiveryForm::ps_idEntered() + { + if (!sGui || !sGui->hasWebDataServices()) + { + ui->le_Id->undo(); + return; + } + + const int id = ui->le_Id->text().toInt(); + const CLivery livery = sGui->getWebDataServices()->getLiveryForDbKey(id); + if (!livery.isLoadedFromDb()) + { + ui->le_Id->undo(); + return; + } + this->setValue(livery); + } } // ns } // ns diff --git a/src/blackgui/editors/liveryform.h b/src/blackgui/editors/liveryform.h index 035499be8..bde11da66 100644 --- a/src/blackgui/editors/liveryform.h +++ b/src/blackgui/editors/liveryform.h @@ -42,7 +42,7 @@ namespace BlackGui explicit CLiveryForm(QWidget *parent = nullptr); //! Destructor - ~CLiveryForm(); + virtual ~CLiveryForm(); //! Value BlackMisc::Aviation::CLivery getValue() const; @@ -69,6 +69,9 @@ namespace BlackGui //! Clear data void clear(); + //! Reset value to current value + void resetValue(); + public slots: //! Value bool setValue(const BlackMisc::Aviation::CLivery &livery); @@ -86,6 +89,9 @@ namespace BlackGui //! Search for color void ps_searchForColor(); + //! Id entered + void ps_idEntered(); + private: QScopedPointer ui; BlackMisc::Aviation::CLivery m_originalLivery; //!< object allowing to override values diff --git a/src/blackgui/editors/liveryform.ui b/src/blackgui/editors/liveryform.ui index 940e74165..4d05acc38 100644 --- a/src/blackgui/editors/liveryform.ui +++ b/src/blackgui/editors/liveryform.ui @@ -63,9 +63,6 @@ 16777215 - - true - Id @@ -118,6 +115,9 @@ + + <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> + temp. @@ -217,6 +217,9 @@ + + find a color livery + search color