refs #501, compareByPropertyIndex (performance for sort)

This commit is contained in:
Klaus Basan
2015-10-26 19:13:43 +01:00
committed by Mathew Sutcliffe
parent 1e57ce7ecb
commit 0c94922bd6
55 changed files with 692 additions and 131 deletions

View File

@@ -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)
{

View File

@@ -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;