mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 20:25:29 +08:00
refs #358, interface for mapping readers
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
|
|
||||||
#include "simulatormodelmappings.h"
|
#include "simulatormodelmappings.h"
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -24,19 +27,26 @@ namespace BlackSim
|
|||||||
return this->m_mappings.isEmpty();
|
return this->m_mappings.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlackMisc::Network::CAircraftMappingList &ISimulatorModelMappings::getMappingList() const
|
const CAircraftMappingList &ISimulatorModelMappings::getMappingList() const
|
||||||
{
|
{
|
||||||
return this->m_mappings;
|
return this->m_mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::Network::CAircraftMappingList ISimulatorModelMappings::findByIcaoWildcard(const BlackMisc::Aviation::CAircraftIcao &icao) const
|
int ISimulatorModelMappings::synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs)
|
||||||
{
|
{
|
||||||
return this->m_mappings.findByIcaoCodeWildcard(icao);
|
if (modelNames.isEmpty() || this->m_mappings.isEmpty()) { return this->m_mappings.size(); }
|
||||||
|
CAircraftMappingList newList;
|
||||||
|
foreach(CAircraftMapping mapping, this->m_mappings)
|
||||||
|
{
|
||||||
|
QString modelString = mapping.getModel().getModelString();
|
||||||
|
if (modelString.isEmpty()) { continue; }
|
||||||
|
if (modelNames.contains(modelString, cs))
|
||||||
|
{
|
||||||
|
newList.push_back(mapping);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
BlackMisc::Network::CAircraftMappingList ISimulatorModelMappings::findByIcaoExact(const BlackMisc::Aviation::CAircraftIcao &icao) const
|
this->m_mappings = newList;
|
||||||
{
|
return this->m_mappings.size();
|
||||||
return this->m_mappings.findByIcaoCodeExact(icao);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
{
|
{
|
||||||
//! Model mappings
|
//! Model mappings interface, different mapping readers (e.g. from database, from vPilot data files)
|
||||||
|
//! can implement this, but provide the same mapping list.
|
||||||
class ISimulatorModelMappings : public QObject
|
class ISimulatorModelMappings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -30,7 +31,7 @@ namespace BlackSim
|
|||||||
virtual ~ISimulatorModelMappings() {}
|
virtual ~ISimulatorModelMappings() {}
|
||||||
|
|
||||||
//! Load data
|
//! Load data
|
||||||
virtual bool load() = 0;
|
virtual bool read() = 0;
|
||||||
|
|
||||||
//! Empty
|
//! Empty
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
@@ -41,11 +42,8 @@ namespace BlackSim
|
|||||||
//! Get list
|
//! Get list
|
||||||
const BlackMisc::Network::CAircraftMappingList &getMappingList() const;
|
const BlackMisc::Network::CAircraftMappingList &getMappingList() const;
|
||||||
|
|
||||||
//! Find by ICAO code, empty fields are treated as wildcards
|
//! Synchronize with existing model names, remove unneeded models
|
||||||
BlackMisc::Network::CAircraftMappingList findByIcaoWildcard(const BlackMisc::Aviation::CAircraftIcao &icao) const;
|
int synchronizeWithExistingModels(const QStringList &modelNames, Qt::CaseSensitivity cs = Qt::CaseInsensitive);
|
||||||
|
|
||||||
//! Find by ICAO code, empty fields are treated literally
|
|
||||||
BlackMisc::Network::CAircraftMappingList findByIcaoExact(const BlackMisc::Aviation::CAircraftIcao &icao) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BlackMisc::Network::CAircraftMappingList m_mappings; //!< Mappings
|
BlackMisc::Network::CAircraftMappingList m_mappings; //!< Mappings
|
||||||
|
|||||||
Reference in New Issue
Block a user