refs #526, forms

* fixed read only
* in read only mode no warnings (then we just do mapping and warnings do not help)
This commit is contained in:
Klaus Basan
2016-01-02 20:52:26 +01:00
parent 0a6ed4e874
commit 5aa1f3bc94
8 changed files with 43 additions and 16 deletions

View File

@@ -10,6 +10,7 @@
#include "blackgui/guiutility.h"
#include "blackmisc/aviation/aircrafticaocodelist.h"
#include "aircrafticaoform.h"
#include "blackmisc/datastore.h"
#include "ui_aircrafticaoform.h"
using namespace BlackMisc;
@@ -63,6 +64,22 @@ namespace BlackGui
CAircraftIcaoCode CAircraftIcaoForm::getValue() const
{
CAircraftIcaoCode icao(this->ui->aircraft_Selector->getAircraftIcao());
if (!icao.hasValidDbKey())
{
// not based on DB yet, do we have a DB key
int k = this->getDbKeyFromGui();
if (k >= 0)
{
// we got an id, we get the DB object for it
CAircraftIcaoCode fromDb(this->getAircraftIcaoCodeForDbKey(k));
if (fromDb.getDesignator() == icao.getDesignator())
{
// we replace by DB object
icao = fromDb;
}
}
}
QString manufacturer(this->ui->le_Manufacturer->text().trimmed().toUpper());
QString modelDescription(this->ui->le_ModelDescription->text());
QString wtc(ui->cb_Wtc->currentText().left(1));
@@ -149,5 +166,10 @@ namespace BlackGui
this->setValue(icao);
}
int CAircraftIcaoForm::getDbKeyFromGui() const
{
QString key(this->ui->le_Id->text().trimmed());
return IDatastoreObjectWithIntegerKey::stringToDbKey(key);
}
} // ns
} // ns

View File

@@ -74,8 +74,10 @@ namespace BlackGui
private:
QScopedPointer<Ui::CAircraftIcaoForm> ui;
};
//! Key from GUI
int getDbKeyFromGui() const;
};
} // ns
} // ns

View File

@@ -70,6 +70,12 @@ namespace BlackGui
{
CAirlineIcaoCode code(getValue());
CStatusMessageList msgs(code.validate());
if (this->isReadOnly())
{
// in readonly I cannot change the data anyway, so skip warnings
msgs.removeWarningsAndBelow();
}
this->ui->val_Indicator->setState(msgs);
return msgs;
}

View File

@@ -67,6 +67,11 @@ namespace BlackGui
// optional distributor
msgs = distributor.validate();
}
if (this->isReadOnly())
{
// in readonly I cannot change the data anyway, so skip warnings
msgs.removeWarningsAndBelow();
}
this->ui->val_Indicator->setState(msgs);
return msgs;
}

View File

@@ -72,6 +72,11 @@ namespace BlackGui
{
msgs.push_back(this->ui->editor_AirlineIcao->validate());
}
if (this->isReadOnly())
{
// in readonly I cannot change the data anyway, so skip warnings
msgs.removeWarningsAndBelow();
}
this->ui->val_Indicator->setState(msgs);
return msgs;
}
@@ -91,6 +96,8 @@ namespace BlackGui
this->m_readOnly = readOnly;
this->ui->le_Code->setReadOnly(readOnly);
this->ui->le_Description->setReadOnly(readOnly);
this->ui->color_Fuselage->setReadOnly(readOnly);
this->ui->color_Tail->setReadOnly(readOnly);
}
void CLiveryForm::setMappingMode()

View File

@@ -25,7 +25,6 @@ namespace BlackGui
ui->le_LastUpdated->setReadOnly(true);
ui->le_Id->setReadOnly(true);
ui->lai_Id->set(CIcons::appMappings16(), "Id:");
connect(ui->pb_Publish, &QPushButton::clicked, this, &CModelMappingForm::requestPublish);
connect(ui->pb_Stash, &QPushButton::clicked, this, &CModelMappingForm::requestStash);
}

View File

@@ -53,15 +53,9 @@ namespace BlackGui
//! Request validation
void requestValidation();
//! Request to publish (DB)
void requestPublish();
//! Request stashing for model
void requestStash();
private slots:
//!
private:
QScopedPointer<Ui::CModelMappingForm> ui;
BlackMisc::Simulation::CAircraftModel m_originalModel;

View File

@@ -78,13 +78,6 @@
</property>
</widget>
</item>
<item row="1" column="6">
<widget class="QPushButton" name="pb_Publish">
<property name="text">
<string>Publish</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_Description">
<property name="placeholderText">
@@ -199,7 +192,6 @@
<tabstop>le_Name</tabstop>
<tabstop>le_Description</tabstop>
<tabstop>pb_Stash</tabstop>
<tabstop>pb_Publish</tabstop>
<tabstop>le_LastUpdated</tabstop>
</tabstops>
<resources/>