Ref T472, further utility functions for category handling

This commit is contained in:
Klaus Basan
2019-03-09 02:05:07 +01:00
committed by Mat Sutcliffe
parent c899bfbea7
commit 54adb40329
8 changed files with 95 additions and 4 deletions

View File

@@ -57,6 +57,13 @@ namespace BlackMisc
return levels;
}
QString CAircraftCategoryList::getLevelsString(const QString &separator) const
{
const QSet<QString> levels = this->getLevelStrings();
if (levels.isEmpty()) {return {}; }
return levels.toList().join(separator);
}
QList<int> CAircraftCategoryList::getFirstLevels() const
{
QSet<int> levels;

View File

@@ -55,6 +55,9 @@ namespace BlackMisc
//! Get all level strings
QSet<QString> getLevelStrings() const;
//! Get all level strings
QString getLevelsString(const QString &separator = ", ") const;
//! All levels sorted
QList<int> getFirstLevels() const;

View File

@@ -216,7 +216,7 @@ namespace BlackMisc
this->removeIf(&CAircraftIcaoCode::isDbDuplicate, true);
}
QStringList CAircraftIcaoCodeList::toCompleterStrings(bool withIataCodes, bool withFamily, bool sort) const
QStringList CAircraftIcaoCodeList::toCompleterStrings(bool withIataCodes, bool withFamily, bool withCategory, bool sort) const
{
QStringList c;
CAircraftIcaoCodeList icaos(*this);
@@ -225,7 +225,7 @@ namespace BlackMisc
// 3 steps to get a proper sort order of the string list
for (const CAircraftIcaoCode &icao : as_const(icaos))
{
c.append(icao.getCombinedIcaoStringWithKey());
c.append(withCategory ? icao.getCombinedIcaoCategoryStringWithKey() : icao.getCombinedIcaoStringWithKey());
}
if (withFamily)

View File

@@ -119,7 +119,7 @@ namespace BlackMisc
void removeDuplicates();
//! For selection completion
QStringList toCompleterStrings(bool withIataCodes = false, bool withFamily = false, bool sort = true) const;
QStringList toCompleterStrings(bool withIataCodes = false, bool withFamily = false, bool withCategory = true, bool sort = true) const;
//! All ICAO codes, no duplicates
QSet<QString> allDesignators(bool noUnspecified = true) const;