using hashes to perform comparisons between blackmisc value objects stored inside of QVariant

refs #81
This commit is contained in:
Klaus Basan
2013-12-22 20:40:30 +00:00
committed by Mathew Sutcliffe
parent 67a5dbfe48
commit a280d239e6
22 changed files with 416 additions and 0 deletions

View File

@@ -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
*/