mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T111, added utility functions used for swift plugin (dummy driver)
* new reader functions * plugin info
This commit is contained in:
committed by
Mathew Sutcliffe
parent
29e1d54e05
commit
b1295cd457
@@ -34,6 +34,11 @@ namespace BlackCore
|
|||||||
return m_airportCache.get();
|
return m_airportCache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAirport CAirportDataReader::getAirportForIcaoDesignator(const QString &designator) const
|
||||||
|
{
|
||||||
|
return getAirports().findByIcao(CAirportIcaoCode(designator)).frontOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
int CAirportDataReader::getAirportsCount() const
|
int CAirportDataReader::getAirportsCount() const
|
||||||
{
|
{
|
||||||
return this->getAirports().size();
|
return this->getAirports().size();
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Aviation::CAirportList getAirports() const;
|
BlackMisc::Aviation::CAirportList getAirports() const;
|
||||||
|
|
||||||
|
//! Returns airport for designator (or default)
|
||||||
|
//! \threadsafe
|
||||||
|
BlackMisc::Aviation::CAirport getAirportForIcaoDesignator(const QString &designator) const;
|
||||||
|
|
||||||
//! Returns a list of all airports in the database.
|
//! Returns a list of all airports in the database.
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
int getAirportsCount() const;
|
int getAirportsCount() const;
|
||||||
|
|||||||
@@ -523,9 +523,9 @@ namespace BlackCore
|
|||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CWebDataServices::getModelCompleterStrings(bool sorted) const
|
QStringList CWebDataServices::getModelCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
|
||||||
{
|
{
|
||||||
if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted); }
|
if (m_modelDataReader) { return m_modelDataReader->getModels().toCompleterStrings(sorted, simulator); }
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -666,6 +666,12 @@ namespace BlackCore
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAirport CWebDataServices::getAirportForIcaoDesignator(const QString &icao) const
|
||||||
|
{
|
||||||
|
if (m_airportDataReader) { return m_airportDataReader->getAirportForIcaoDesignator(icao); }
|
||||||
|
return CAirport();
|
||||||
|
}
|
||||||
|
|
||||||
CCountry CWebDataServices::getCountryForIsoCode(const QString &iso) const
|
CCountry CWebDataServices::getCountryForIsoCode(const QString &iso) const
|
||||||
{
|
{
|
||||||
if (m_icaoDataReader) { return m_icaoDataReader->getCountryForIsoCode(iso); }
|
if (m_icaoDataReader) { return m_icaoDataReader->getCountryForIsoCode(iso); }
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ namespace BlackCore
|
|||||||
|
|
||||||
//! Model completer string
|
//! Model completer string
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
QStringList getModelCompleterStrings(bool sorted = true) const;
|
QStringList getModelCompleterStrings(bool sorted = true, const BlackMisc::Simulation::CSimulatorInfo &simulator = { BlackMisc::Simulation::CSimulatorInfo::All }) const;
|
||||||
|
|
||||||
//! Models for combined code and aircraft designator
|
//! Models for combined code and aircraft designator
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -313,6 +313,10 @@ namespace BlackCore
|
|||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
int getAirportsCount() const;
|
int getAirportsCount() const;
|
||||||
|
|
||||||
|
//! Get airport for ICAO designator
|
||||||
|
//! \threadsafe
|
||||||
|
BlackMisc::Aviation::CAirport getAirportForIcaoDesignator(const QString &icao) const;
|
||||||
|
|
||||||
//! Get METARs
|
//! Get METARs
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Weather::CMetarList getMetars() const;
|
BlackMisc::Weather::CMetarList getMetars() const;
|
||||||
|
|||||||
@@ -693,13 +693,16 @@ namespace BlackMisc
|
|||||||
return scoreMap;
|
return scoreMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CAircraftModelList::toCompleterStrings(bool sorted) const
|
QStringList CAircraftModelList::toCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
|
||||||
{
|
{
|
||||||
QStringList c;
|
QStringList c;
|
||||||
c.reserve(size());
|
c.reserve(size());
|
||||||
for (const CAircraftModel &model : *this)
|
for (const CAircraftModel &model : *this)
|
||||||
{
|
{
|
||||||
c.append(model.getModelString());
|
if (model.getSimulator().matchesAny(simulator))
|
||||||
|
{
|
||||||
|
c.append(model.getModelString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sorted) { c.sort(); }
|
if (sorted) { c.sort(); }
|
||||||
return c;
|
return c;
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ namespace BlackMisc
|
|||||||
ScoredModels scoreFull(const CAircraftModel &remoteModel, bool preferColorLiveries, bool ignoreZeroScores = true, CStatusMessageList *log = nullptr) const;
|
ScoredModels scoreFull(const CAircraftModel &remoteModel, bool preferColorLiveries, bool ignoreZeroScores = true, CStatusMessageList *log = nullptr) const;
|
||||||
|
|
||||||
//! Completer strings
|
//! Completer strings
|
||||||
QStringList toCompleterStrings(bool sorted = true) const;
|
QStringList toCompleterStrings(bool sorted = true, const BlackMisc::Simulation::CSimulatorInfo &simulator = { BlackMisc::Simulation::CSimulatorInfo::All }) const;
|
||||||
|
|
||||||
//! Validate for publishing
|
//! Validate for publishing
|
||||||
CStatusMessageList validateForPublishing() const;
|
CStatusMessageList validateForPublishing() const;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json)
|
void CSimulatorPluginInfo::convertFromJson(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
if (json.contains("IID")) // comes from the plugin
|
if (json.contains("IID")) // comes from the plugin
|
||||||
{
|
{
|
||||||
if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); }
|
if (! json.contains("MetaData")) { throw CJsonException("Missing 'MetaData'"); }
|
||||||
|
|
||||||
@@ -45,6 +45,16 @@ namespace BlackMisc
|
|||||||
return m_identifier.isEmpty();
|
return m_identifier.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimulatorInfo CSimulatorPluginInfo::getSimulatorInfo() const
|
||||||
|
{
|
||||||
|
return CSimulatorInfo(getSimulator());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSimulatorPluginInfo::isSwiftPlugin() const
|
||||||
|
{
|
||||||
|
return this->getIdentifier() == swiftPluginIndentifier();
|
||||||
|
}
|
||||||
|
|
||||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
@@ -75,6 +85,12 @@ namespace BlackMisc
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &CSimulatorPluginInfo::swiftPluginIndentifier()
|
||||||
|
{
|
||||||
|
static const QString s("org.swift-project.plugins.simulator.swift");
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
const QStringList &CSimulatorPluginInfo::allIdentifiers()
|
const QStringList &CSimulatorPluginInfo::allIdentifiers()
|
||||||
{
|
{
|
||||||
static const QStringList identifiers(
|
static const QStringList identifiers(
|
||||||
@@ -82,7 +98,8 @@ namespace BlackMisc
|
|||||||
fsxPluginIndentifier(),
|
fsxPluginIndentifier(),
|
||||||
p3dPluginIndentifier(),
|
p3dPluginIndentifier(),
|
||||||
xplanePluginIndentifier(),
|
xplanePluginIndentifier(),
|
||||||
fs9PluginIndentifier()
|
fs9PluginIndentifier(),
|
||||||
|
swiftPluginIndentifier()
|
||||||
});
|
});
|
||||||
return identifiers;
|
return identifiers;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#ifndef BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
#ifndef BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
#include "blackmisc/metaclass.h"
|
#include "blackmisc/metaclass.h"
|
||||||
#include "blackmisc/valueobject.h"
|
#include "blackmisc/valueobject.h"
|
||||||
@@ -58,6 +59,12 @@ namespace BlackMisc
|
|||||||
//! Simulator
|
//! Simulator
|
||||||
const QString &getSimulator() const { return m_simulator; }
|
const QString &getSimulator() const { return m_simulator; }
|
||||||
|
|
||||||
|
//! Simulator info object
|
||||||
|
BlackMisc::Simulation::CSimulatorInfo getSimulatorInfo() const;
|
||||||
|
|
||||||
|
//! Is this the pseudo swift driver?
|
||||||
|
bool isSwiftPlugin() const;
|
||||||
|
|
||||||
//! Description
|
//! Description
|
||||||
const QString &getDescription() const { return m_description; }
|
const QString &getDescription() const { return m_description; }
|
||||||
|
|
||||||
@@ -76,6 +83,9 @@ namespace BlackMisc
|
|||||||
//! Plugin identifier (XPlane)
|
//! Plugin identifier (XPlane)
|
||||||
static const QString &xplanePluginIndentifier();
|
static const QString &xplanePluginIndentifier();
|
||||||
|
|
||||||
|
//! Plugin identifier (swift pseudo driver)
|
||||||
|
static const QString &swiftPluginIndentifier();
|
||||||
|
|
||||||
//! All valid identifiers
|
//! All valid identifiers
|
||||||
static const QStringList &allIdentifiers();
|
static const QStringList &allIdentifiers();
|
||||||
|
|
||||||
|
|||||||
@@ -38,5 +38,14 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
return this->findFirstByOrDefault(&CSimulatorPluginInfo::getIdentifier, identifier);
|
return this->findFirstByOrDefault(&CSimulatorPluginInfo::getIdentifier, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimulatorPluginInfo CSimulatorPluginInfoList::findBySimulator(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
for (const CSimulatorPluginInfo &info : *this)
|
||||||
|
{
|
||||||
|
if (info.getSimulatorInfo() == simulator) { return info; }
|
||||||
|
}
|
||||||
|
return CSimulatorPluginInfo();
|
||||||
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -13,9 +13,10 @@
|
|||||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFOLIST_H
|
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFOLIST_H
|
||||||
|
|
||||||
#include "blackmisc/blackmiscexport.h"
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
|
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||||
#include "blackmisc/collection.h"
|
#include "blackmisc/collection.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
@@ -50,6 +51,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Find by identifier (unique)
|
//! Find by identifier (unique)
|
||||||
CSimulatorPluginInfo findByIdentifier(const QString &identifier) const;
|
CSimulatorPluginInfo findByIdentifier(const QString &identifier) const;
|
||||||
|
|
||||||
|
//! Find by simulator
|
||||||
|
CSimulatorPluginInfo findBySimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -234,10 +234,10 @@ namespace BlackMisc
|
|||||||
* the derived class uses this macro to disambiguate the inherited members.
|
* the derived class uses this macro to disambiguate the inherited members.
|
||||||
*/
|
*/
|
||||||
# define BLACKMISC_DECLARE_USING_MIXIN_STRING(DERIVED) \
|
# define BLACKMISC_DECLARE_USING_MIXIN_STRING(DERIVED) \
|
||||||
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
||||||
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
||||||
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
||||||
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user