mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 23:35:33 +08:00
refs #501, compareByPropertyIndex (performance for sort)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1e57ce7ecb
commit
0c94922bd6
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user