mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Ref T348, updated utility functions in CSimConnectObject/CAircraftCfgEntriesList, also fixed bug that type need to be updated to probe setting when aircraft changes
Related: Ref T317 Ref T247 Ref T335
This commit is contained in:
@@ -7,11 +7,12 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "stringutils.h"
|
||||
#include "blackmisc/predicates.h"
|
||||
#include "blackmisc/range.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -26,9 +27,7 @@ namespace BlackMisc
|
||||
bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
if (title.isEmpty()) { return false; }
|
||||
return this->containsBy(
|
||||
[ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; }
|
||||
);
|
||||
return this->containsBy([ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
||||
}
|
||||
|
||||
QStringList CAircraftCfgEntriesList::detectAmbiguousTitles() const
|
||||
@@ -58,6 +57,21 @@ namespace BlackMisc
|
||||
return titles;
|
||||
}
|
||||
|
||||
QString CAircraftCfgEntriesList::getTitlesAsString(bool sorted, const QString &separator) const
|
||||
{
|
||||
return this->getTitles(sorted).join(separator);
|
||||
}
|
||||
|
||||
bool CAircraftCfgEntriesList::containsTitle(const QString &title) const
|
||||
{
|
||||
if (title.isEmpty()) { return false; }
|
||||
for (const CAircraftCfgEntries &entries : (*this))
|
||||
{
|
||||
if (stringCompare(entries.getTitle(), title, Qt::CaseInsensitive)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CAircraftModelList CAircraftCfgEntriesList::toAircraftModelList(bool ignoreDuplicatesAndEmptyModelStrings, CStatusMessageList &msgs) const
|
||||
{
|
||||
CAircraftModelList ml;
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace BlackMisc
|
||||
//! All titles (aka model names)
|
||||
QStringList getTitles(bool sorted = false) const;
|
||||
|
||||
//! All titles as string
|
||||
QString getTitlesAsString(bool sorted, const QString &separator = ", ") const;
|
||||
|
||||
//! As aircraft models
|
||||
BlackMisc::Simulation::CAircraftModelList toAircraftModelList(bool ignoreDuplicatesAndEmptyModelStrings, CStatusMessageList &msgs) const;
|
||||
|
||||
@@ -61,6 +64,9 @@ namespace BlackMisc
|
||||
//! Find by title
|
||||
CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const;
|
||||
|
||||
//! Can check if a title (model string) is known
|
||||
bool containsTitle(const QString &title) const;
|
||||
|
||||
private:
|
||||
//! Section within file
|
||||
enum FileSection
|
||||
|
||||
Reference in New Issue
Block a user