FlightGear next
CarriersLocationModel.hxx
Go to the documentation of this file.
1#ifndef CARRIERSMODEL_H
2#define CARRIERSMODEL_H
3
4#include <vector>
5
6#include <simgear/math/sg_geodesy.hxx>
7#include <simgear/props/props.hxx>
8
9#include <QAbstractListModel>
10#include <QPixmap>
11
12class CarriersLocationModel : public QAbstractListModel
13{
14 Q_OBJECT
15
16public:
17 explicit CarriersLocationModel(QObject *parent = nullptr);
18
19 // Basic functionality:
20 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
21
22 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
23
24 QHash<int, QByteArray> roleNames() const override;
25
26 // copied from NavaidSearchModel
27 enum Roles {
28 GeodRole = Qt::UserRole + 1,
29 GuidRole = Qt::UserRole + 2,
30 IdentRole = Qt::UserRole + 3,
31 NameRole = Qt::UserRole + 4,
32 IconRole = Qt::UserRole + 5,
33 TypeRole = Qt::UserRole + 6,
34 NavFrequencyRole = Qt::UserRole + 7,
35 DescriptionRole = Qt::UserRole + 8
36 };
37
38 int indexOf(const QString name) const;
39
40 SGGeod geodForIndex(int index) const;
41 QString pennantForIndex(int index) const;
42
43 QStringList parkingsForIndex(int index) const;
44private:
45 mutable QPixmap m_carrierPixmap;
46
47 struct Carrier
48 {
49 QString mScenario; // scenario ID for loading
50 QString mCallsign; // pennant-number
51 QString mName;
52 QString mDescription;
53 SGGeod mInitialLocation;
54 // icon?
55 QString mTACAN;
56 QStringList mParkings;
57 };
58
59 using CarrierVec = std::vector<Carrier>;
60 CarrierVec mCarriers;
61
62 void processCarrier(const std::string& scenario, SGPropertyNode_ptr carrierNode);
63};
64
65#endif // CARRIERSMODEL_H
QString pennantForIndex(int index) const
SGGeod geodForIndex(int index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
CarriersLocationModel(QObject *parent=nullptr)
int indexOf(const QString name) const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QHash< int, QByteArray > roleNames() const override
QStringList parkingsForIndex(int index) const
const char * name