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