mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 02:06:08 +08:00
Ref T343, support for 7digit ids
This commit is contained in:
@@ -134,6 +134,28 @@ namespace BlackMisc
|
|||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CUser::get7DigitId() const
|
||||||
|
{
|
||||||
|
if (!this->hasNumericId()) { return m_id; }
|
||||||
|
if (m_id.length() > 6) { return m_id; }
|
||||||
|
|
||||||
|
static const QString zeros("0000000");
|
||||||
|
return zeros.left(7 - m_id.length()) % m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CUser::getIntegerId() const
|
||||||
|
{
|
||||||
|
if (m_id.isEmpty()) { return -1; }
|
||||||
|
if (is09OnlyString(m_id)) { return m_id.toInt(); }
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CUser::hasNumericId() const
|
||||||
|
{
|
||||||
|
if (m_id.isEmpty()) { return false; }
|
||||||
|
return is09OnlyString(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
void CUser::updateMissingParts(const CUser &otherUser)
|
void CUser::updateMissingParts(const CUser &otherUser)
|
||||||
{
|
{
|
||||||
if (this == &otherUser) { return; }
|
if (this == &otherUser) { return; }
|
||||||
@@ -153,9 +175,8 @@ namespace BlackMisc
|
|||||||
bool CUser::isValidVatsimId(const QString &id)
|
bool CUser::isValidVatsimId(const QString &id)
|
||||||
{
|
{
|
||||||
if (id.isEmpty()) { return false; }
|
if (id.isEmpty()) { return false; }
|
||||||
bool ok;
|
if (!is09OnlyString(id)) { return false; }
|
||||||
const int i = id.toInt(&ok);
|
const int i = id.toInt();
|
||||||
if (!ok) { return false; }
|
|
||||||
return i >= 100000 && i <= 9999999;
|
return i >= 100000 && i <= 9999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,10 +226,12 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
case IndexEmail: return CVariant(m_email);
|
case IndexEmail: return CVariant(m_email);
|
||||||
case IndexId: return CVariant(m_id);
|
case IndexId: return CVariant(m_id);
|
||||||
case IndexPassword: return CVariant(m_password);
|
case IndexId7Digit: return CVariant(this->get7DigitId());
|
||||||
case IndexRealName: return CVariant(m_realname);
|
case IndexIdInteger: return CVariant::fromValue(this->getIntegerId());
|
||||||
case IndexHomebase: return m_homebase.propertyByIndex(index.copyFrontRemoved());
|
case IndexPassword: return CVariant(m_password);
|
||||||
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
case IndexRealName: return CVariant(m_realname);
|
||||||
|
case IndexHomebase: return m_homebase.propertyByIndex(index.copyFrontRemoved());
|
||||||
|
case IndexCallsign: return m_callsign.propertyByIndex(index.copyFrontRemoved());
|
||||||
default: return CValueObject::propertyByIndex(index);
|
default: return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,6 +243,8 @@ namespace BlackMisc
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case IndexEmail: this->setEmail(variant.value<QString>()); break;
|
case IndexEmail: this->setEmail(variant.value<QString>()); break;
|
||||||
|
case IndexIdInteger: this->setId(QString::number(variant.toInt())); break;
|
||||||
|
case IndexId7Digit: // fallthru
|
||||||
case IndexId: this->setId(variant.value<QString>()); break;
|
case IndexId: this->setId(variant.value<QString>()); break;
|
||||||
case IndexPassword: this->setPassword(variant.value<QString>()); break;
|
case IndexPassword: this->setPassword(variant.value<QString>()); break;
|
||||||
case IndexRealName: this->setRealName(variant.value<QString>()); break;
|
case IndexRealName: this->setRealName(variant.value<QString>()); break;
|
||||||
@@ -237,6 +262,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
case IndexEmail: return m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
case IndexEmail: return m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||||
case IndexId: return m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
case IndexId: return m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||||
|
case IndexId7Digit: return this->get7DigitId().compare(compareValue.get7DigitId(), Qt::CaseInsensitive);
|
||||||
case IndexRealName: return m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
case IndexRealName: return m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||||
case IndexHomebase: return m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
case IndexHomebase: return m_homebase.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getHomeBase());
|
||||||
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
case IndexCallsign: return m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
IndexEmail = CPropertyIndex::GlobalIndexCUser,
|
IndexEmail = CPropertyIndex::GlobalIndexCUser,
|
||||||
IndexId,
|
IndexId,
|
||||||
|
IndexIdInteger,
|
||||||
|
IndexId7Digit,
|
||||||
IndexPassword,
|
IndexPassword,
|
||||||
IndexRealName,
|
IndexRealName,
|
||||||
IndexCallsign,
|
IndexCallsign,
|
||||||
@@ -120,6 +122,15 @@ namespace BlackMisc
|
|||||||
//! Get id.
|
//! Get id.
|
||||||
const QString &getId() const { return m_id; }
|
const QString &getId() const { return m_id; }
|
||||||
|
|
||||||
|
//! Numeric ids get a leading zeros if required
|
||||||
|
QString get7DigitId() const;
|
||||||
|
|
||||||
|
//! Id as integer if possible, otherwise -1
|
||||||
|
int getIntegerId() const;
|
||||||
|
|
||||||
|
//! Has a numeric id?
|
||||||
|
bool hasNumericId() const;
|
||||||
|
|
||||||
//! Set id
|
//! Set id
|
||||||
void setId(const QString &id) { m_id = decode(id); }
|
void setId(const QString &id) { m_id = decode(id); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user