mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #501, compareByPropertyIndex (performance for sort)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1e57ce7ecb
commit
0c94922bd6
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/datastoreutility.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include <tuple>
|
||||
#include <QThreadStorage>
|
||||
#include <QRegularExpression>
|
||||
@@ -280,6 +281,36 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CAircraftIcaoCode::comparePropertyByIndex(const CAircraftIcaoCode &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive); }
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(compareValue, index);}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAircraftDesignator:
|
||||
return m_designator.compare(compareValue.getDesignator(), Qt::CaseInsensitive);
|
||||
case IndexCombinedAircraftType:
|
||||
return m_combinedType.compare(compareValue.getCombinedType(), Qt::CaseInsensitive);
|
||||
case IndexModelDescription:
|
||||
return m_modelDescription.compare(compareValue.getModelDescription(), Qt::CaseInsensitive);
|
||||
case IndexManufacturer:
|
||||
return m_manufacturer.compare(compareValue.getManufacturer(), Qt::CaseInsensitive);
|
||||
case IndexWtc:
|
||||
return m_wtc.compare(compareValue.getWtc(), Qt::CaseInsensitive);
|
||||
case IndexIsLegacy:
|
||||
return Compare::compare(m_legacy, compareValue.isLegacyAircraft());
|
||||
case IndexIsMilitary:
|
||||
return Compare::compare(m_military, compareValue.isMilitary());
|
||||
case IndexRank:
|
||||
return Compare::compare(m_rank, compareValue.getRank());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CAircraftIcaoCode::isValidDesignator(const QString &designator)
|
||||
{
|
||||
if (designator.length() < 2 || designator.length() > 5) { return false; }
|
||||
|
||||
Reference in New Issue
Block a user