mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +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; }
|
||||
|
||||
@@ -168,6 +168,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAircraftIcaoCode &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
*/
|
||||
|
||||
#include "aircraftparts.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
QString CAircraftParts::convertToQString(bool i18n) const
|
||||
{
|
||||
QString s;
|
||||
@@ -34,10 +36,7 @@ namespace BlackMisc
|
||||
CVariant CAircraftParts::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index))
|
||||
{
|
||||
return ITimestampBased::propertyByIndex(index);
|
||||
}
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
@@ -60,11 +59,7 @@ namespace BlackMisc
|
||||
void CAircraftParts::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAircraftParts>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index))
|
||||
{
|
||||
ITimestampBased::setPropertyByIndex(variant, index);
|
||||
return;
|
||||
}
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(variant, index); return; }
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
@@ -90,6 +85,31 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CAircraftParts::comparePropertyByIndex(const CAircraftParts &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return ITimestampBased::comparePropertyByIndex(compareValue, CPropertyIndex()); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(compareValue, index); }
|
||||
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEngines:
|
||||
return Compare::compare(this->getEnginesCount(), compareValue.getEnginesCount());
|
||||
case IndexFlapsPercentage:
|
||||
return Compare::compare(this->m_flapsPercentage, compareValue.getFlapsPercent());
|
||||
case IndexGearDown:
|
||||
return Compare::compare(this->m_gearDown, compareValue.isGearDown());
|
||||
case IndexLights:
|
||||
break;
|
||||
case IndexSpoilersOut:
|
||||
return Compare::compare(this->m_spoilersOut, compareValue.isSpoilersOut());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CAircraftParts::setAllLightsOn()
|
||||
{
|
||||
m_lights.setAllOn();
|
||||
|
||||
@@ -56,6 +56,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAircraftParts &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Get aircraft lights
|
||||
CAircraftLights getLights() const { return m_lights; }
|
||||
|
||||
@@ -92,6 +95,9 @@ namespace BlackMisc
|
||||
//! Engine with number
|
||||
CAircraftEngine getEngine(int number) const;
|
||||
|
||||
//! Number of engines
|
||||
int getEnginesCount() const { return m_engines.size(); }
|
||||
|
||||
//! Is engine with number 1..n on?
|
||||
bool isEngineOn(int number) const;
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <QThreadStorage>
|
||||
@@ -154,6 +155,32 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CAirlineIcaoCode::comparePropertyByIndex(const CAirlineIcaoCode &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 IndexAirlineDesignator:
|
||||
return this->m_designator.compare(compareValue.getDesignator());
|
||||
case IndexAirlineCountry:
|
||||
return this->m_country.comparePropertyByIndex(compareValue.getCountry(), index.copyFrontRemoved());
|
||||
case IndexAirlineName:
|
||||
return this->m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
case IndexTelephonyDesignator:
|
||||
return this->m_telephonyDesignator.compare(compareValue.getTelephonyDesignator(), Qt::CaseInsensitive);
|
||||
case IndexIsVirtualAirline:
|
||||
return Compare::compare(this->isVirtualAirline(), compareValue.isVirtualAirline());
|
||||
case IndexIsOperating:
|
||||
return Compare::compare(this->isOperating(), compareValue.isOperating());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No compare function");
|
||||
return 0;
|
||||
}
|
||||
|
||||
CStatusMessageList CAirlineIcaoCode::validate() const
|
||||
{
|
||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation() }));
|
||||
|
||||
@@ -133,6 +133,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAirlineIcaoCode &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Validate data
|
||||
BlackMisc::CStatusMessageList validate() const;
|
||||
|
||||
|
||||
@@ -100,5 +100,27 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CAirport::comparePropertyByIndex(const CAirport &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->m_icao.comparePropertyByIndex(compareValue.getIcao(), index.copyFrontRemoved()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexIcao:
|
||||
return this->m_icao.comparePropertyByIndex(compareValue.getIcao(), index.copyFrontRemoved());
|
||||
case IndexDescriptiveName:
|
||||
return this->m_descriptiveName.compare(compareValue.getDescriptiveName(), Qt::CaseInsensitive);
|
||||
case IndexBearing:
|
||||
return this->m_bearingToOwnAircraft.comparePropertyByIndex(compareValue.getBearingToOwnAircraft(), index.copyFrontRemoved());
|
||||
case IndexPosition:
|
||||
case IndexDistanceToOwnAircraft:
|
||||
return this->m_distanceToOwnAircraft.comparePropertyByIndex(compareValue.getDistanceToOwnAircraft(), index.copyFrontRemoved());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -102,6 +102,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAirport &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@ namespace BlackMisc
|
||||
return this->m_icaoCode;
|
||||
}
|
||||
|
||||
int CAirportIcaoCode::comparePropertyByIndex(const CAirportIcaoCode &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return this->m_icaoCode.compare(compareValue.getIcaoCode(), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
bool CAirportIcaoCode::equalsString(const QString &icaoCode) const
|
||||
{
|
||||
CAirportIcaoCode other(icaoCode);
|
||||
|
||||
@@ -54,6 +54,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::convertToQString()
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAirportIcaoCode &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CAirportIcaoCode)
|
||||
QString m_icaoCode;
|
||||
|
||||
@@ -168,6 +168,25 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CCallsign::comparePropertyByIndex(const CCallsign &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->m_callsign.compare(compareValue.m_callsign, Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsignString:
|
||||
return this->m_callsign.compare(compareValue.m_callsign, Qt::CaseInsensitive);
|
||||
case IndexCallsignStringAsSet:
|
||||
return this->m_callsignAsSet.compare(compareValue.m_callsignAsSet, Qt::CaseInsensitive);
|
||||
case IndexTelephonyDesignator:
|
||||
return this->m_telephonyDesignator.compare(compareValue.m_telephonyDesignator, Qt::CaseInsensitive);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CCallsign::isValidCallsign(const QString &callsign)
|
||||
{
|
||||
// We allow all number callsigns
|
||||
|
||||
@@ -117,6 +117,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CCallsign &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Valid callsign?
|
||||
static bool isValidCallsign(const QString &callsign);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -228,6 +228,30 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CLivery::comparePropertyByIndex(const CLivery &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDescription:
|
||||
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexAirlineIcaoCode:
|
||||
return this->m_airline.comparePropertyByIndex(compareValue.getAirlineIcaoCode(), index.copyFrontRemoved());
|
||||
case IndexColorFuselage:
|
||||
return this->m_colorFuselage.comparePropertyByIndex(compareValue.getColorFuselage(), index.copyFrontRemoved());
|
||||
case IndexColorTail:
|
||||
return this->m_colorTail.comparePropertyByIndex(compareValue.getColorTail(), index.copyFrontRemoved());
|
||||
case IndexCombinedCode:
|
||||
return this->getCombinedCode().compare(compareValue.getCombinedCode());
|
||||
case IndexIsMilitary:
|
||||
return Compare::compare(this->isMilitary(), compareValue.isMilitary());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No compare function");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CLivery::updateMissingParts(const CLivery &otherLivery)
|
||||
{
|
||||
if (!this->m_colorFuselage.isValid()) { this->setColorFuselage(otherLivery.getColorFuselage()); }
|
||||
|
||||
@@ -112,6 +112,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CLivery &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
42
src/blackmisc/comparefunctions.cpp
Normal file
42
src/blackmisc/comparefunctions.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "comparefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Compare
|
||||
{
|
||||
int compare(bool a, bool b)
|
||||
{
|
||||
if ((a && b) || (!a && !b)) return 0;
|
||||
if (a && !b) return 10;
|
||||
return -10;
|
||||
}
|
||||
|
||||
int compare(int a, int b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
int compare(qint64 a, qint64 b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
int compare(double a, double b)
|
||||
{
|
||||
if (a == b) return 0;
|
||||
return a < b ? -10 : 10;
|
||||
}
|
||||
|
||||
} // ns
|
||||
} // ns
|
||||
36
src/blackmisc/comparefunctions.h
Normal file
36
src/blackmisc/comparefunctions.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_COMPAREFUNCTIONS_H
|
||||
#define BLACKMISC_COMPAREFUNCTIONS_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Compare
|
||||
{
|
||||
//! Compare bool
|
||||
BLACKMISC_EXPORT int compare(bool a, bool b);
|
||||
|
||||
//! Compare int
|
||||
BLACKMISC_EXPORT int compare(int a, int b);
|
||||
|
||||
//! Compare qint64
|
||||
BLACKMISC_EXPORT int compare(qint64 a, qint64 b);
|
||||
|
||||
//! Compare qint64
|
||||
BLACKMISC_EXPORT int compare(double a, double b);
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif
|
||||
@@ -130,6 +130,23 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CCountry::comparePropertyByIndex(const CCountry &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return getIsoCode().compare(compareValue.getIsoCode(), Qt::CaseInsensitive); }
|
||||
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::comparePropertyByIndex(compareValue, index);}
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexIsoCode:
|
||||
return getIsoCode().compare(compareValue.getIsoCode(), Qt::CaseInsensitive);
|
||||
case IndexName:
|
||||
return getName().compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison possible");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CCountry CCountry::fromDatabaseJson(const QJsonObject &json, const QString &prefix)
|
||||
{
|
||||
if (!existsKey(json, prefix))
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CCountry &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! From our database JSON format
|
||||
static CCountry fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "blackmisc/datastore.h"
|
||||
#include "blackmisc/datastoreutility.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -80,6 +81,21 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int IDatastoreObjectWithIntegerKey::comparePropertyByIndex(const IDatastoreObjectWithIntegerKey &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(compareValue, index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDbIntegerKey:
|
||||
return Compare::compare(this->m_dbKey, compareValue.getDbKey());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IDatastoreObjectWithIntegerKey::canHandleIndex(const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (ITimestampBased::canHandleIndex(index)) { return true;}
|
||||
@@ -132,8 +148,24 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int IDatastoreObjectWithStringKey::comparePropertyByIndex(const IDatastoreObjectWithStringKey &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(compareValue, index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexDbStringKey:
|
||||
return this->m_dbKey.compare(compareValue.getDbKey());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool IDatastoreObjectWithStringKey::canHandleIndex(const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isEmpty()) { return false; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return true;}
|
||||
int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexDbStringKey)) && (i <= static_cast<int>(IndexDbStringKey));
|
||||
|
||||
@@ -68,6 +68,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const IDatastoreObjectWithIntegerKey &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Can given index be handled?
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
@@ -114,6 +117,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const IDatastoreObjectWithStringKey &compareValue, const BlackMisc::CPropertyIndex &index) const;
|
||||
|
||||
//! Can given index be handled
|
||||
static bool canHandleIndex(const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
|
||||
@@ -218,5 +218,30 @@ namespace BlackMisc
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int CUser::comparePropertyByIndex(const CUser &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->getRealName().compare(compareValue.getRealName(), Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexEmail:
|
||||
return this->m_email.compare(compareValue.getEmail(), Qt::CaseInsensitive);
|
||||
case IndexId:
|
||||
return this->m_id.compare(compareValue.getId(), Qt::CaseInsensitive);
|
||||
case IndexPassword:
|
||||
break;
|
||||
case IndexRealName:
|
||||
return this->m_realname.compare(compareValue.getRealName(), Qt::CaseInsensitive);
|
||||
case IndexHomebase:
|
||||
return this->m_homebase.comparePropertyByIndex(compareValue.getHomebase(), index.copyFrontRemoved());
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.comparePropertyByIndex(compareValue.getCallsign(), index.copyFrontRemoved());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "compare failed");
|
||||
return 0;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -122,6 +122,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare by index
|
||||
int comparePropertyByIndex(const CUser &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! This and another user exchange missing data, This user has priority and overrides first.
|
||||
void syncronizeData(CUser &otherUser);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "blackmisc/pq/pq.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
@@ -15,7 +16,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace PhysicalQuantities
|
||||
{
|
||||
|
||||
template <class MU, class PQ>
|
||||
MU CPhysicalQuantity<MU, PQ>::getUnit() const
|
||||
{
|
||||
@@ -394,6 +394,22 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
int CPhysicalQuantity<MU, PQ>::comparePropertyByIndex(const PQ &pq, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return compareImpl(*derived(), pq); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexValue:
|
||||
return Compare::compare(this->m_value, pq.m_value);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
int CPhysicalQuantity<MU, PQ>::compareImpl(const PQ &a, const PQ &b)
|
||||
{
|
||||
|
||||
@@ -211,6 +211,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare
|
||||
int comparePropertyByIndex(const PQ &pq, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -36,12 +36,11 @@ namespace BlackMisc
|
||||
|
||||
CPropertyIndex CPropertyIndex::copyFrontRemoved() const
|
||||
{
|
||||
Q_ASSERT(!this->isEmpty());
|
||||
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "Empty index");
|
||||
if (this->isEmpty()) { return CPropertyIndex(); }
|
||||
QList<int> l = this->indexList();
|
||||
l.removeAt(0);
|
||||
CPropertyIndex pi(l);
|
||||
return pi;
|
||||
int p = this->m_indexString.indexOf(';');
|
||||
if (p < 0) { return CPropertyIndex(); }
|
||||
return CPropertyIndex(this->m_indexString.mid(p + 1));
|
||||
}
|
||||
|
||||
bool CPropertyIndex::isNested() const
|
||||
@@ -102,7 +101,7 @@ namespace BlackMisc
|
||||
QList<int> list;
|
||||
if (this->m_indexString.isEmpty()) { return list; }
|
||||
QStringList indexes = this->m_indexString.split(';');
|
||||
foreach(QString index, indexes)
|
||||
for (const QString &index : indexes)
|
||||
{
|
||||
if (index.isEmpty()) { continue; }
|
||||
bool ok;
|
||||
@@ -126,4 +125,22 @@ namespace BlackMisc
|
||||
return this->indexList().contains(index);
|
||||
}
|
||||
|
||||
int CPropertyIndex::frontToInt() const
|
||||
{
|
||||
Q_ASSERT_X(!this->isEmpty(), Q_FUNC_INFO, "No index");
|
||||
int f = -1;
|
||||
bool ok;
|
||||
int p = this->m_indexString.indexOf(';');
|
||||
if (p < 0)
|
||||
{
|
||||
f = this->m_indexString.toInt(&ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
f = this->m_indexString.left(p).toInt(&ok);
|
||||
}
|
||||
Q_ASSERT_X(ok && f >= 0, Q_FUNC_INFO, "Invalid index");
|
||||
return f;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
/*!
|
||||
* Property index. The index can be nested, that's why it is a sequence
|
||||
* (e.g. PropertyIndexPilot, PropertyIndexRealname).
|
||||
@@ -136,13 +135,14 @@ namespace BlackMisc
|
||||
return contains(static_cast<int>(ev));
|
||||
}
|
||||
|
||||
//! First element casted to given type, usually then PropertIndex enum
|
||||
//! Front to integer
|
||||
int frontToInt() const;
|
||||
|
||||
//! First element casted to given type, usually the PropertIndex enum
|
||||
template<class CastType> CastType frontCasted() const
|
||||
{
|
||||
QList<int> l = indexList();
|
||||
Q_ASSERT(!l.isEmpty());
|
||||
int f = l.isEmpty() ? 0 : l.first();
|
||||
return static_cast<CastType>(f);
|
||||
static_assert(std::is_enum<CastType>::value || std::is_integral<CastType>::value, "CastType must be an enum or integer");
|
||||
return static_cast<CastType>(frontToInt());
|
||||
}
|
||||
|
||||
//! Compare with index given by enum
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
#include "blackmisc/rgbcolor.h"
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "comparefunctions.h"
|
||||
#include <QPainter>
|
||||
|
||||
using namespace BlackMisc;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
|
||||
CRgbColor::CRgbColor(const QString &color, bool isName)
|
||||
{
|
||||
this->setByString(color, isName);
|
||||
@@ -217,6 +219,28 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CRgbColor::comparePropertyByIndex(const CRgbColor &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->hex().compare(compareValue.hex(), Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexBlue:
|
||||
return Compare::compare(this->m_b, compareValue.m_b);
|
||||
case IndexRed:
|
||||
return Compare::compare(this->m_r, compareValue.m_r);
|
||||
case IndexGreen:
|
||||
return Compare::compare(this->m_g, compareValue.m_g);
|
||||
case IndexWebHex:
|
||||
this->hex().compare(compareValue.hex(), Qt::CaseInsensitive);
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Missing compare");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
double CRgbColor::colorRange() const
|
||||
{
|
||||
if (!this->isValid()) { return 255; }
|
||||
|
||||
@@ -106,6 +106,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CRgbColor &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CRgbColor)
|
||||
int m_r = -1;
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
#include "aircraftmodel.h"
|
||||
#include "distributor.h"
|
||||
#include "blackmisc/datastoreutility.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include <QString>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -140,6 +142,42 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CAircraftModel::comparePropertyByIndex(const CAircraftModel &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (IDatastoreObjectWithIntegerKey::canHandleIndex(index)) { return IDatastoreObjectWithIntegerKey::comparePropertyByIndex(compareValue, index);}
|
||||
if (index.isMyself()) { return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexModelString:
|
||||
return this->m_modelString.compare(compareValue.getModelString(), Qt::CaseInsensitive);
|
||||
case IndexAircraftIcaoCode:
|
||||
return this->m_aircraftIcao.comparePropertyByIndex(compareValue.getAircraftIcaoCode(), index.copyFrontRemoved());
|
||||
case IndexLivery:
|
||||
return this->m_livery.comparePropertyByIndex(compareValue.getLivery(), index.copyFrontRemoved());
|
||||
case IndexDistributor:
|
||||
return this->m_distributor.comparePropertyByIndex(compareValue.getDistributor(), index.copyFrontRemoved());
|
||||
case IndexDescription:
|
||||
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
case IndexSimulatorInfo:
|
||||
return this->m_simulator.comparePropertyByIndex(compareValue.getSimulatorInfo(), index.copyFrontRemoved());
|
||||
case IndexName:
|
||||
return this->m_modelName.compare(compareValue.getName(), Qt::CaseInsensitive);
|
||||
case IndexCallsign:
|
||||
break;
|
||||
case IndexFileName:
|
||||
return this->m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
|
||||
case IndexModelType:
|
||||
return Compare::compare(this->m_modelType, compareValue.getModelType());
|
||||
case IndexModelMode:
|
||||
return Compare::compare(this->m_modelMode, compareValue.getModelMode());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "No comparison");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CAircraftModel::setAircraftIcaoCode(const CAircraftIcaoCode &aircraftIcaoCode)
|
||||
{
|
||||
if (this->m_aircraftIcao == aircraftIcaoCode) { return false; }
|
||||
|
||||
@@ -94,6 +94,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAircraftModel &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Corresponding callsign if applicable
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_callsign; }
|
||||
|
||||
|
||||
@@ -71,6 +71,25 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CDistributor::comparePropertyByIndex(const CDistributor &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (IDatastoreObjectWithStringKey::canHandleIndex(index)) { return IDatastoreObjectWithStringKey::comparePropertyByIndex(compareValue, index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAlias1:
|
||||
return this->m_alias1.compare(compareValue.m_alias1, Qt::CaseInsensitive);
|
||||
case IndexAlias2:
|
||||
return this->m_alias2.compare(compareValue.m_alias2, Qt::CaseInsensitive);
|
||||
case IndexDescription:
|
||||
return this->m_description.compare(compareValue.getDescription(), Qt::CaseInsensitive);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString CDistributor::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
|
||||
@@ -84,6 +84,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CDistributor &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#include "simulatedaircraft.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -315,7 +317,8 @@ namespace BlackMisc
|
||||
this->m_transponder.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
break;
|
||||
case IndexAircraftIcaoCode:
|
||||
this->m_livery.setPropertyByIndex(variant, index); // intentionally not removing front, delegating
|
||||
// intentionally not removing front, delegating
|
||||
this->m_livery.setPropertyByIndex(variant, index);
|
||||
break;
|
||||
case IndexLivery:
|
||||
this->m_livery.setPropertyByIndex(variant, index.copyFrontRemoved());
|
||||
@@ -348,6 +351,46 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
int CSimulatedAircraft::comparePropertyByIndex(const CSimulatedAircraft &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return this->m_callsign.comparePropertyByIndex(compareValue.getCallsign(), index.copyFrontRemoved()); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexCallsign:
|
||||
return this->m_callsign.comparePropertyByIndex(compareValue.getCallsign(), index.copyFrontRemoved());
|
||||
case IndexPilot:
|
||||
return this->m_pilot.comparePropertyByIndex(compareValue.getPilot(), index.copyFrontRemoved());
|
||||
case IndexSituation:
|
||||
case IndexDistanceToOwnAircraft:
|
||||
return this->m_distanceToOwnAircraft.comparePropertyByIndex(compareValue.getDistanceToOwnAircraft(), index.copyFrontRemoved());
|
||||
case IndexCom1System:
|
||||
return m_com1system.getFrequencyActive().comparePropertyByIndex(compareValue.getCom1System().getFrequencyActive(), index.copyFrontRemoved());
|
||||
case IndexCom2System:
|
||||
return m_com2system.getFrequencyActive().comparePropertyByIndex(compareValue.getCom2System().getFrequencyActive(), index.copyFrontRemoved());
|
||||
case IndexTransponder:
|
||||
return Compare::compare(m_transponder.getTransponderCode(), compareValue.getTransponder().getTransponderCode());
|
||||
case IndexLivery:
|
||||
return this->m_livery.comparePropertyByIndex(compareValue.getLivery(), index.copyFrontRemoved());
|
||||
case IndexParts:
|
||||
return this->m_parts.comparePropertyByIndex(compareValue.getParts(), index.copyFrontRemoved());
|
||||
case IndexModel:
|
||||
return m_model.comparePropertyByIndex(compareValue.getModel(), index.copyFrontRemoved());
|
||||
case IndexEnabled:
|
||||
return Compare::compare(this->m_enabled, compareValue.isEnabled());
|
||||
case IndexRendered:
|
||||
return Compare::compare(this->m_rendered, compareValue.isRendered());
|
||||
case IndexPartsSynchronized:
|
||||
return Compare::compare(this->m_partsSynchronized, compareValue.isPartsSynchronized());
|
||||
case IndexFastPositionUpdates:
|
||||
return Compare::compare(this->m_fastPositionUpdates, compareValue.fastPositionUpdates());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Comapre failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CSimulatedAircraft::setModel(const CAircraftModel &model)
|
||||
{
|
||||
// sync the callsigns
|
||||
|
||||
@@ -301,6 +301,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CSimulatedAircraft &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Get model
|
||||
const BlackMisc::Simulation::CAircraftModel &getModel() const { return m_model; }
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "simulatorinfo.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/simulation/fscommon/fscommonutil.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
@@ -85,6 +86,12 @@ namespace BlackMisc
|
||||
return (this->m_simulator & otherInfo.m_simulator) > 0;
|
||||
}
|
||||
|
||||
int CSimulatorInfo::comparePropertyByIndex(const CSimulatorInfo &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return Compare::compare(this->m_simulator, compareValue.m_simulator);
|
||||
}
|
||||
|
||||
QString CSimulatorInfo::convertToQString(bool i18n) const
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
|
||||
@@ -101,6 +101,9 @@ namespace BlackMisc
|
||||
//! All simulators
|
||||
void setAllSimulators() { setSimulator(All); }
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CSimulatorInfo &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "timestampbased.h"
|
||||
#include "variant.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -138,6 +139,7 @@ namespace BlackMisc
|
||||
|
||||
bool ITimestampBased::canHandleIndex(const CPropertyIndex &index)
|
||||
{
|
||||
if (index.isEmpty()) { return false; }
|
||||
int i = index.frontCasted<int>();
|
||||
return (i >= static_cast<int>(IndexUtcTimestamp)) && (i <= static_cast<int>(IndexMSecsSinceEpoch));
|
||||
}
|
||||
@@ -168,7 +170,7 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
const QString m = QString("Cannot handle index %1").arg(index.toQString());
|
||||
Q_ASSERT_X(false, "propertyByIndex", m.toLocal8Bit().constData());
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
|
||||
return CVariant::fromValue(m);
|
||||
}
|
||||
|
||||
@@ -199,7 +201,13 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
const QString m = QString("Cannot handle index %1").arg(index.toQString());
|
||||
Q_ASSERT_X(false, "setPropertyByIndex", m.toLocal8Bit().constData());
|
||||
Q_ASSERT_X(false, Q_FUNC_INFO, m.toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
int ITimestampBased::comparePropertyByIndex(const ITimestampBased &compareValue, const CPropertyIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return Compare::compare(this->m_timestampMSecsSinceEpoch, compareValue.m_timestampMSecsSinceEpoch);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -111,6 +111,9 @@ namespace BlackMisc
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const ITimestampBased &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
qint64 m_timestampMSecsSinceEpoch; //!< timestamp value
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user