mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Ref T442, ATC station list split per suffix
This commit is contained in:
@@ -138,5 +138,25 @@ namespace BlackMisc
|
||||
stations.sortByAtcSuffixSortOrderAndDistance();
|
||||
return stations;
|
||||
}
|
||||
|
||||
QHash<QString, CAtcStationList> CAtcStationList::splitPerSuffix(bool sort) const
|
||||
{
|
||||
if (this->isEmpty()) { return QHash<QString, CAtcStationList>(); }
|
||||
const CAtcStationList stations = sort ? this->sortedByAtcSuffixSortOrderAndDistance() : * this;
|
||||
|
||||
QString suffix;
|
||||
QHash<QString, CAtcStationList> split;
|
||||
for (const CAtcStation &s : stations)
|
||||
{
|
||||
const QString currentSuffix = s.getCallsignSuffix();
|
||||
if (suffix != currentSuffix)
|
||||
{
|
||||
suffix = currentSuffix;
|
||||
split[currentSuffix] = CAtcStationList();
|
||||
}
|
||||
split[currentSuffix].push_back(s);
|
||||
}
|
||||
return split;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QHash>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -81,6 +82,10 @@ namespace BlackMisc
|
||||
|
||||
//! Sorted by ATC suffix sort order and distance
|
||||
CAtcStationList sortedByAtcSuffixSortOrderAndDistance() const;
|
||||
|
||||
//! Split per suffix
|
||||
//! \remark sort can be disabled if already sorted
|
||||
QHash<QString, CAtcStationList> splitPerSuffix(bool sort = true) const;
|
||||
};
|
||||
} //namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user