mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 09:45:44 +08:00
refs #619, simulator info list + fix in distributor list
This commit is contained in:
@@ -50,7 +50,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (distributor.matchesKeyOrAlias(keyOrAlias)) { return true; }
|
if (distributor.matchesKeyOrAlias(keyOrAlias)) { return true; }
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList CDistributorList::getDbKeysAndAliases() const
|
QStringList CDistributorList::getDbKeysAndAliases() const
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace BlackMisc
|
|||||||
CSimulatedAircraft::registerMetadata();
|
CSimulatedAircraft::registerMetadata();
|
||||||
CSimulatedAircraftList::registerMetadata();
|
CSimulatedAircraftList::registerMetadata();
|
||||||
CSimulatorInfo::registerMetadata();
|
CSimulatorInfo::registerMetadata();
|
||||||
|
CSimulatorInfoList::registerMetadata();
|
||||||
CSimulatorPluginInfo::registerMetadata();
|
CSimulatorPluginInfo::registerMetadata();
|
||||||
CSimulatorPluginInfoList::registerMetadata();
|
CSimulatorPluginInfoList::registerMetadata();
|
||||||
CSimulatorSetup::registerMetadata();
|
CSimulatorSetup::registerMetadata();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "blackmisc/simulation/airspaceaircraftsnapshot.h"
|
#include "blackmisc/simulation/airspaceaircraftsnapshot.h"
|
||||||
#include "blackmisc/simulation/distributorlist.h"
|
#include "blackmisc/simulation/distributorlist.h"
|
||||||
#include "blackmisc/simulation/simulatorsetup.h"
|
#include "blackmisc/simulation/simulatorsetup.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfolist.h"
|
||||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||||
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
#include "blackmisc/simulation/fscommon/aircraftcfgentrieslist.h"
|
||||||
#include "blackmisc/simulation/fscommon/vpilotmodelruleset.h"
|
#include "blackmisc/simulation/fscommon/vpilotmodelruleset.h"
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ namespace BlackMisc
|
|||||||
class BLACKMISC_EXPORT CSimulatorInfo : public BlackMisc::CValueObject<CSimulatorInfo>
|
class BLACKMISC_EXPORT CSimulatorInfo : public BlackMisc::CValueObject<CSimulatorInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Simulator
|
//! Simulator
|
||||||
enum SimulatorFlag
|
enum SimulatorFlag
|
||||||
{
|
{
|
||||||
|
|||||||
68
src/blackmisc/simulation/simulatorinfolist.cpp
Normal file
68
src/blackmisc/simulation/simulatorinfolist.cpp
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/simulatorinfolist.h"
|
||||||
|
#include "blackmisc/predicates.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
CSimulatorInfoList::CSimulatorInfoList() { }
|
||||||
|
|
||||||
|
CSimulatorInfoList::CSimulatorInfoList(const CSequence<CSimulatorInfo> &other) :
|
||||||
|
CSequence<CSimulatorInfo>(other)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CSimulatorInfoList CSimulatorInfoList::withNoDuplicates() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CSimulatorInfoList(); }
|
||||||
|
QList<int> simIndexes;
|
||||||
|
CSimulatorInfoList newList;
|
||||||
|
for (const CSimulatorInfo &simulator : *this)
|
||||||
|
{
|
||||||
|
const int i = static_cast<int>(simulator.getSimulator());
|
||||||
|
if (simIndexes.contains(i)) { continue; }
|
||||||
|
newList.push_back(simulator);
|
||||||
|
simIndexes.append(i);
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimulatorInfoList CSimulatorInfoList::splitIntoSingleSimulators() const
|
||||||
|
{
|
||||||
|
if (this->isEmpty()) { return CSimulatorInfoList(); }
|
||||||
|
CSimulatorInfoList newList;
|
||||||
|
for (const CSimulatorInfo &simulator : *this)
|
||||||
|
{
|
||||||
|
if (simulator.isUnspecified() || simulator.isNoSimulator()) { continue; }
|
||||||
|
if (simulator.isSingleSimulator())
|
||||||
|
{
|
||||||
|
newList.push_back(simulator);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newList.push_back(splitIntoSingleSimulators(simulator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimulatorInfoList CSimulatorInfoList::splitIntoSingleSimulators(const CSimulatorInfo &sim)
|
||||||
|
{
|
||||||
|
CSimulatorInfoList sims;
|
||||||
|
if (sim.fs9()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FS9)); }
|
||||||
|
if (sim.fsx()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::FSX)); }
|
||||||
|
if (sim.p3d()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::P3D)); }
|
||||||
|
if (sim.xplane()) { sims.push_back(CSimulatorInfo(CSimulatorInfo::XPLANE)); }
|
||||||
|
return sims;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
56
src/blackmisc/simulation/simulatorinfolist.h
Normal file
56
src/blackmisc/simulation/simulatorinfolist.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SIMULATION_SIMULATORINFOLIST_H
|
||||||
|
#define BLACKMISC_SIMULATION_SIMULATORINFOLIST_H
|
||||||
|
|
||||||
|
#include "blackmisc/blackmiscexport.h"
|
||||||
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
|
#include "blackmisc/collection.h"
|
||||||
|
#include "blackmisc/sequence.h"
|
||||||
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
//! Value object encapsulating a list of distributors.
|
||||||
|
class BLACKMISC_EXPORT CSimulatorInfoList :
|
||||||
|
public BlackMisc::CSequence<CSimulatorInfo>,
|
||||||
|
public BlackMisc::Mixin::MetaType<CSimulatorInfoList>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CSimulatorInfoList)
|
||||||
|
|
||||||
|
//! Default constructor.
|
||||||
|
CSimulatorInfoList();
|
||||||
|
|
||||||
|
//! Construct from a base class object.
|
||||||
|
CSimulatorInfoList(const CSequence<CSimulatorInfo> &other);
|
||||||
|
|
||||||
|
//! Find by id or alias
|
||||||
|
CSimulatorInfoList withNoDuplicates() const;
|
||||||
|
|
||||||
|
//! Split into single simulators, unknown simulators are ignored
|
||||||
|
CSimulatorInfoList splitIntoSingleSimulators() const;
|
||||||
|
|
||||||
|
//! Split into single simulators, unknown simulators are ignored
|
||||||
|
static CSimulatorInfoList splitIntoSingleSimulators(const CSimulatorInfo &sim);
|
||||||
|
};
|
||||||
|
} //namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Simulation::CSimulatorInfoList)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CCollection<BlackMisc::Simulation::CSimulatorInfo>)
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Simulation::CSimulatorInfo>)
|
||||||
|
|
||||||
|
#endif //guard
|
||||||
Reference in New Issue
Block a user