mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +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
@@ -693,13 +693,16 @@ namespace BlackMisc
|
||||
return scoreMap;
|
||||
}
|
||||
|
||||
QStringList CAircraftModelList::toCompleterStrings(bool sorted) const
|
||||
QStringList CAircraftModelList::toCompleterStrings(bool sorted, const CSimulatorInfo &simulator) const
|
||||
{
|
||||
QStringList c;
|
||||
c.reserve(size());
|
||||
for (const CAircraftModel &model : *this)
|
||||
{
|
||||
c.append(model.getModelString());
|
||||
if (model.getSimulator().matchesAny(simulator))
|
||||
{
|
||||
c.append(model.getModelString());
|
||||
}
|
||||
}
|
||||
if (sorted) { c.sort(); }
|
||||
return c;
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace BlackMisc
|
||||
ScoredModels scoreFull(const CAircraftModel &remoteModel, bool preferColorLiveries, bool ignoreZeroScores = true, CStatusMessageList *log = nullptr) const;
|
||||
|
||||
//! 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
|
||||
CStatusMessageList validateForPublishing() const;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace BlackMisc
|
||||
|
||||
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'"); }
|
||||
|
||||
@@ -45,6 +45,16 @@ namespace BlackMisc
|
||||
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
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
@@ -75,6 +85,12 @@ namespace BlackMisc
|
||||
return s;
|
||||
}
|
||||
|
||||
const QString &CSimulatorPluginInfo::swiftPluginIndentifier()
|
||||
{
|
||||
static const QString s("org.swift-project.plugins.simulator.swift");
|
||||
return s;
|
||||
}
|
||||
|
||||
const QStringList &CSimulatorPluginInfo::allIdentifiers()
|
||||
{
|
||||
static const QStringList identifiers(
|
||||
@@ -82,7 +98,8 @@ namespace BlackMisc
|
||||
fsxPluginIndentifier(),
|
||||
p3dPluginIndentifier(),
|
||||
xplanePluginIndentifier(),
|
||||
fs9PluginIndentifier()
|
||||
fs9PluginIndentifier(),
|
||||
swiftPluginIndentifier()
|
||||
});
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#ifndef BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFO_H
|
||||
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
@@ -58,6 +59,12 @@ namespace BlackMisc
|
||||
//! 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
|
||||
const QString &getDescription() const { return m_description; }
|
||||
|
||||
@@ -76,6 +83,9 @@ namespace BlackMisc
|
||||
//! Plugin identifier (XPlane)
|
||||
static const QString &xplanePluginIndentifier();
|
||||
|
||||
//! Plugin identifier (swift pseudo driver)
|
||||
static const QString &swiftPluginIndentifier();
|
||||
|
||||
//! All valid identifiers
|
||||
static const QStringList &allIdentifiers();
|
||||
|
||||
|
||||
@@ -38,5 +38,14 @@ namespace BlackMisc
|
||||
{
|
||||
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
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
#define BLACKMISC_SIMULATION_SIMULATORPLUGININFOLIST_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/simulation/simulatorinfo.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include "blackmisc/sequence.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QMetaType>
|
||||
@@ -50,6 +51,9 @@ namespace BlackMisc
|
||||
|
||||
//! Find by identifier (unique)
|
||||
CSimulatorPluginInfo findByIdentifier(const QString &identifier) const;
|
||||
|
||||
//! Find by simulator
|
||||
CSimulatorPluginInfo findBySimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -234,10 +234,10 @@ namespace BlackMisc
|
||||
* the derived class uses this macro to disambiguate the inherited members.
|
||||
*/
|
||||
# define BLACKMISC_DECLARE_USING_MIXIN_STRING(DERIVED) \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toFormattedQString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::toStdString; \
|
||||
using ::BlackMisc::Mixin::String<DERIVED>::stringForStreaming;
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user