swift
Loading...
Searching...
No Matches
simulatorinfolist.cpp
1// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#include <tuple>
7
8#include <QList>
9
10SWIFT_DEFINE_SEQUENCE_MIXINS(swift::misc::simulation, CSimulatorInfo, CSimulatorInfoList)
11
12namespace swift::misc::simulation
13{
15
17 {
18 if (this->isEmpty())
19 {
20 return {};
21 }
22 QList<int> simIndexes;
23 CSimulatorInfoList newList;
24 for (const CSimulatorInfo &simulator : *this)
25 {
26 const int i = static_cast<int>(simulator.getSimulator());
27 if (simIndexes.contains(i))
28 {
29 continue;
30 }
31 newList.push_back(simulator);
32 simIndexes.append(i);
33 }
34 return newList;
35 }
36
38 {
39 if (this->isEmpty())
40 {
41 return {};
42 }
43 CSimulatorInfoList newList;
44 for (const CSimulatorInfo &simulator : *this)
45 {
46 if (simulator.isUnspecified() || simulator.isNoSimulator())
47 {
48 continue;
49 }
50 if (simulator.isSingleSimulator())
51 {
52 newList.push_back(simulator);
53 }
54 else
55 {
56 newList.push_back(splitIntoSingleSimulators(simulator));
57 }
58 }
59 return newList;
60 }
61
63 {
65 if (sim.isP3D())
66 {
67 sims.push_back(CSimulatorInfo(CSimulatorInfo::P3D));
68 }
69 if (sim.isMSFS())
70 {
71 sims.push_back(CSimulatorInfo(CSimulatorInfo::MSFS));
72 }
73 if (sim.isMSFS2024())
74 {
75 sims.push_back(CSimulatorInfo(CSimulatorInfo::MSFS2024));
76 }
77 if (sim.isXPlane())
78 {
79 sims.push_back(CSimulatorInfo(CSimulatorInfo::XPLANE));
80 }
81 return sims;
82 }
83} // namespace swift::misc::simulation
void push_back(const T &value)
Appends an element at the end of the sequence.
Definition sequence.h:308
Simple hardcoded info about the corresponding simulator.
bool isSingleSimulator() const
Single simulator selected.
bool isNoSimulator() const
No simulator?
bool isUnspecified() const
Unspecified simulator.
Simulator getSimulator() const
Simulator.
CSimulatorInfoList()=default
Default constructor.
CSequence()=default
Default constructor.
CSimulatorInfoList withNoDuplicates() const
Find by id or alias.
CSimulatorInfoList splitIntoSingleSimulators() const
Split into single simulators, unknown simulators are ignored.
void append(QList< T > &&value)
bool contains(const AT &value) const const
#define SWIFT_DEFINE_SEQUENCE_MIXINS(Namespace, T, List)
Explicit template definition of mixins for a CSequence subclass.
Definition sequence.h:63