mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
using hashes to perform comparisons between blackmisc value objects stored inside of QVariant
refs #81
This commit is contained in:
committed by
Mathew Sutcliffe
parent
67a5dbfe48
commit
a280d239e6
@@ -58,6 +58,28 @@ namespace BlackMisc
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
int CAltitude::compare(const QVariant &qv) const
|
||||
{
|
||||
Q_ASSERT(qv.canConvert<CAltitude>() || qv.canConvert<CLength>());
|
||||
Q_ASSERT(qv.isValid() && !qv.isNull());
|
||||
if (qv.canConvert<CAltitude>())
|
||||
{
|
||||
CAltitude other = qv.value<CAltitude>();
|
||||
if (this->isMeanSeaLevel() && other.isAboveGroundLevel()) return 1;
|
||||
if (this->isAboveGroundLevel() && other.isMeanSeaLevel()) return -1;
|
||||
return this->compare(other);
|
||||
}
|
||||
else if (qv.canConvert<CLength>())
|
||||
{
|
||||
return this->compare(qv.value<CLength>());
|
||||
}
|
||||
qFatal("Invalid comparison");
|
||||
return 0; // just for compiler
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user