mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Feature request based on new VATSIM code of conduct, allow empty homebase
This commit is contained in:
committed by
Mat Sutcliffe
parent
4030a1a730
commit
740cb5a536
@@ -76,6 +76,11 @@ namespace BlackGui
|
|||||||
return ui->le_Icao->text().trimmed().toUpper();
|
return ui->le_Icao->text().trimmed().toUpper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CAirportSmallCompleter::isEmpty() const
|
||||||
|
{
|
||||||
|
return ui->le_Icao->text().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void CAirportSmallCompleter::setReadOnly(bool readOnly)
|
void CAirportSmallCompleter::setReadOnly(bool readOnly)
|
||||||
{
|
{
|
||||||
ui->le_Icao->setReadOnly(readOnly);
|
ui->le_Icao->setReadOnly(readOnly);
|
||||||
@@ -88,6 +93,15 @@ namespace BlackGui
|
|||||||
m_current = CAirport();
|
m_current = CAirport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAirportSmallCompleter::clearIfInvalidCode(bool strictValidation)
|
||||||
|
{
|
||||||
|
const CAirportIcaoCode icao = this->getAirportIcaoCode();
|
||||||
|
if (!icao.hasValidIcaoCode(strictValidation))
|
||||||
|
{
|
||||||
|
this->clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CAirportSmallCompleter::onIcaoChanged()
|
void CAirportSmallCompleter::onIcaoChanged()
|
||||||
{
|
{
|
||||||
if (!sGui && !sGui->hasWebDataServices()) { return; }
|
if (!sGui && !sGui->hasWebDataServices()) { return; }
|
||||||
|
|||||||
@@ -49,12 +49,18 @@ namespace BlackGui
|
|||||||
//! The raw ICAO code text
|
//! The raw ICAO code text
|
||||||
QString getIcaoText() const;
|
QString getIcaoText() const;
|
||||||
|
|
||||||
|
//! Empty field
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
//! Read only
|
//! Read only
|
||||||
void setReadOnly(bool readOnly);
|
void setReadOnly(bool readOnly);
|
||||||
|
|
||||||
//! Clear
|
//! Clear
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
//! Clear if code not valid
|
||||||
|
void clearIfInvalidCode(bool strictValidation);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Airport has been changed
|
//! Airport has been changed
|
||||||
void changedAirport(const BlackMisc::Aviation::CAirport &airport);
|
void changedAirport(const BlackMisc::Aviation::CAirport &airport);
|
||||||
|
|||||||
@@ -122,7 +122,8 @@ namespace BlackGui
|
|||||||
ui->lblp_Id->setTicked(validId);
|
ui->lblp_Id->setTicked(validId);
|
||||||
if (!validId) { msgs.push_back(CStatusMessage(this).validationError(u"Invalid id")); }
|
if (!validId) { msgs.push_back(CStatusMessage(this).validationError(u"Invalid id")); }
|
||||||
|
|
||||||
const bool validHomeAirport = user.hasValidHomeBase();
|
// check against user and if the data entry contains a valid code (or is empty)
|
||||||
|
const bool validHomeAirport = user.hasValidOrEmptyHomeBase() && (ui->comp_HomeAirport->isEmpty() || ui->comp_HomeAirport->getAirportIcaoCode().hasValidIcaoCode(false));
|
||||||
ui->lblp_HomeAirport->setTicked(validHomeAirport);
|
ui->lblp_HomeAirport->setTicked(validHomeAirport);
|
||||||
if (!validHomeAirport) { msgs.push_back(CStatusMessage(this).validationError(u"Wromg home airport")); }
|
if (!validHomeAirport) { msgs.push_back(CStatusMessage(this).validationError(u"Wromg home airport")); }
|
||||||
|
|
||||||
@@ -144,6 +145,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CPilotForm::doValidation()
|
void CPilotForm::doValidation()
|
||||||
{
|
{
|
||||||
|
// ui->comp_HomeAirport->clearIfInvalidCode(false);
|
||||||
this->validate();
|
this->validate();
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Aviation
|
namespace Aviation
|
||||||
{
|
{
|
||||||
|
|
||||||
QString CAirportIcaoCode::convertToQString(bool /** i18n **/) const
|
QString CAirportIcaoCode::convertToQString(bool /** i18n **/) const
|
||||||
{
|
{
|
||||||
return m_icaoCode;
|
return m_icaoCode;
|
||||||
|
|||||||
@@ -141,6 +141,11 @@ namespace BlackMisc
|
|||||||
return m_homebase.hasValidIcaoCode(false);
|
return m_homebase.hasValidIcaoCode(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CUser::hasValidOrEmptyHomeBase() const
|
||||||
|
{
|
||||||
|
return m_homebase.isEmpty() || this->hasValidHomeBase();
|
||||||
|
}
|
||||||
|
|
||||||
CStatusMessageList CUser::validate() const
|
CStatusMessageList CUser::validate() const
|
||||||
{
|
{
|
||||||
CStatusMessageList msgs;
|
CStatusMessageList msgs;
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ namespace BlackMisc
|
|||||||
//! Has valid home base?
|
//! Has valid home base?
|
||||||
bool hasValidHomeBase() const;
|
bool hasValidHomeBase() const;
|
||||||
|
|
||||||
|
//! Has valid or empty home base?
|
||||||
|
bool hasValidOrEmptyHomeBase() const;
|
||||||
|
|
||||||
//! Real name + homebase
|
//! Real name + homebase
|
||||||
QString getRealNameAndHomeBase(const QString &separator = QString(" ")) const;
|
QString getRealNameAndHomeBase(const QString &separator = QString(" ")) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user