mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Allow to split callsign based list + samples
This commit is contained in:
@@ -99,6 +99,40 @@ namespace BlackMisc
|
||||
return r;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
QMap<CCallsign, CONTAINER> ICallsignObjectList<OBJ, CONTAINER>::splitPerCallsign() const
|
||||
{
|
||||
CONTAINER copyContainer(getContainer());
|
||||
copyContainer.sortByCallsign();
|
||||
QMap<CCallsign, CONTAINER> result;
|
||||
CCallsign cs;
|
||||
for (const OBJ &csObj : copyContainer)
|
||||
{
|
||||
if (csObj.getCallsign().isEmpty())
|
||||
{
|
||||
Q_ASSERT(false); // there should be no empty callsigns
|
||||
continue;
|
||||
}
|
||||
if (cs != csObj.getCallsign())
|
||||
{
|
||||
cs = csObj.getCallsign();
|
||||
CONTAINER perCallsign({ csObj });
|
||||
result.insert(cs, perCallsign);
|
||||
}
|
||||
else
|
||||
{
|
||||
result[cs].push_back(csObj);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
void ICallsignObjectList<OBJ, CONTAINER>::sortByCallsign()
|
||||
{
|
||||
getContainer().sortBy(&OBJ::getCallsign);
|
||||
}
|
||||
|
||||
template <class OBJ, class CONTAINER>
|
||||
int ICallsignObjectList<OBJ, CONTAINER>::incrementalUpdateOrAdd(const OBJ &objectBeforeChanges, const CPropertyIndexVariantMap &changedValues)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,12 @@ namespace BlackMisc
|
||||
//! All suffixes with their respective count
|
||||
QMap<QString, int> getSuffixes() const;
|
||||
|
||||
//! Split into 0..n containers as per callsign
|
||||
QMap<BlackMisc::Aviation::CCallsign, CONTAINER> splitPerCallsign() const;
|
||||
|
||||
//! Sort by callsign
|
||||
void sortByCallsign();
|
||||
|
||||
//! Incremental update or add object
|
||||
int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const BlackMisc::CPropertyIndexVariantMap &changedValues);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user