mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +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.
|
* contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackmisc/predicates.h"
|
|
||||||
#include "blackmisc/range.h"
|
|
||||||
#include "blackmisc/simulation/aircraftmodel.h"
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "blackmisc/statusmessagelist.h"
|
#include "blackmisc/statusmessagelist.h"
|
||||||
|
#include "stringutils.h"
|
||||||
|
#include "blackmisc/predicates.h"
|
||||||
|
#include "blackmisc/range.h"
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
@@ -26,9 +27,7 @@ namespace BlackMisc
|
|||||||
bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
bool CAircraftCfgEntriesList::containsModelWithTitle(const QString &title, Qt::CaseSensitivity caseSensitivity)
|
||||||
{
|
{
|
||||||
if (title.isEmpty()) { return false; }
|
if (title.isEmpty()) { return false; }
|
||||||
return this->containsBy(
|
return this->containsBy([ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; });
|
||||||
[ = ](const CAircraftCfgEntries & entries) { return title.compare(entries.getTitle(), caseSensitivity) == 0; }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CAircraftCfgEntriesList::detectAmbiguousTitles() const
|
QStringList CAircraftCfgEntriesList::detectAmbiguousTitles() const
|
||||||
@@ -58,6 +57,21 @@ namespace BlackMisc
|
|||||||
return titles;
|
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 CAircraftCfgEntriesList::toAircraftModelList(bool ignoreDuplicatesAndEmptyModelStrings, CStatusMessageList &msgs) const
|
||||||
{
|
{
|
||||||
CAircraftModelList ml;
|
CAircraftModelList ml;
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ namespace BlackMisc
|
|||||||
//! All titles (aka model names)
|
//! All titles (aka model names)
|
||||||
QStringList getTitles(bool sorted = false) const;
|
QStringList getTitles(bool sorted = false) const;
|
||||||
|
|
||||||
|
//! All titles as string
|
||||||
|
QString getTitlesAsString(bool sorted, const QString &separator = ", ") const;
|
||||||
|
|
||||||
//! As aircraft models
|
//! As aircraft models
|
||||||
BlackMisc::Simulation::CAircraftModelList toAircraftModelList(bool ignoreDuplicatesAndEmptyModelStrings, CStatusMessageList &msgs) const;
|
BlackMisc::Simulation::CAircraftModelList toAircraftModelList(bool ignoreDuplicatesAndEmptyModelStrings, CStatusMessageList &msgs) const;
|
||||||
|
|
||||||
@@ -61,6 +64,9 @@ namespace BlackMisc
|
|||||||
//! Find by title
|
//! Find by title
|
||||||
CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const;
|
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:
|
private:
|
||||||
//! Section within file
|
//! Section within file
|
||||||
enum FileSection
|
enum FileSection
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
m_aircraft = aircraft;
|
m_aircraft = aircraft;
|
||||||
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
m_callsignByteArray = aircraft.getCallsignAsString().toLatin1();
|
||||||
|
m_type = aircraft.isTerrainProbe() ? TerrainProbe : Aircraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimConnectObject::setAircraftModelString(const QString &modelString)
|
void CSimConnectObject::setAircraftModelString(const QString &modelString)
|
||||||
@@ -327,6 +328,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
CSimConnectObject CSimConnectObjects::getOldestObject() const
|
CSimConnectObject CSimConnectObjects::getOldestObject() const
|
||||||
{
|
{
|
||||||
|
if (this->isEmpty()) { return CSimConnectObject(); }
|
||||||
CSimConnectObject oldestSimObj = *this->begin();
|
CSimConnectObject oldestSimObj = *this->begin();
|
||||||
for (const CSimConnectObject &simObj : this->values())
|
for (const CSimConnectObject &simObj : this->values())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ namespace BlackSimPlugin
|
|||||||
//! Get callsign
|
//! Get callsign
|
||||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_aircraft.getCallsign(); }
|
const BlackMisc::Aviation::CCallsign &getCallsign() const { return m_aircraft.getCallsign(); }
|
||||||
|
|
||||||
|
//! Get callsign
|
||||||
|
const QString &getCallsignAsString() const { return m_aircraft.getCallsign().asString(); }
|
||||||
|
|
||||||
//! Callsign?
|
//! Callsign?
|
||||||
bool hasCallsign() const { return !this->getCallsign().isEmpty(); }
|
bool hasCallsign() const { return !this->getCallsign().isEmpty(); }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user