FlightGear next
FlightPlanController.hxx
Go to the documentation of this file.
1#ifndef FLIGHTPLANCONTROLLER_HXX
2#define FLIGHTPLANCONTROLLER_HXX
3
4#include <memory>
5
6#include <QAbstractListModel>
7#include <QObject>
8
10
11#include "QmlPositioned.hxx"
12#include "UnitsModel.hxx"
13
14class FPDelegate;
15class LaunchConfig;
16
17class LegsModel : public QAbstractListModel
18{
19 Q_OBJECT
20
21 Q_PROPERTY(int numLegs READ numLegs NOTIFY numLegsChanged)
22public:
24
25 int rowCount(const QModelIndex& parent) const override;
26 QVariant data(const QModelIndex& index, int role) const override;
27 QHash<int, QByteArray> roleNames() const override;
28
29
30 void waypointsChanged();
31 int numLegs() const;
32
33signals:
35
36private:
38};
39class FlightPlanController : public QObject
40{
41 Q_OBJECT
42
43 Q_PROPERTY(bool enabled MEMBER _enabled NOTIFY enabledChanged)
44 Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
45
46 Q_PROPERTY(QString callsign READ callsign WRITE setCallsign NOTIFY infoChanged)
47 Q_PROPERTY(QString remarks READ remarks WRITE setRemarks NOTIFY infoChanged)
48 Q_PROPERTY(QString aircraftType READ aircraftType WRITE setAircraftType NOTIFY infoChanged)
49
50 Q_PROPERTY(LegsModel* legs READ legs CONSTANT)
51
52 Q_PROPERTY(QString icaoRoute READ icaoRoute NOTIFY waypointsChanged)
53
54 Q_ENUMS(FlightRules)
55 Q_ENUMS(FlightType)
56
59
60 // planned departure date + time
61
63
65
68
72
73 // equipment
74public:
75 virtual ~FlightPlanController();
76
77 // alias these enums to QML
85
94
95 explicit FlightPlanController(QObject *parent,
96 LaunchConfig* config);
97
98 bool loadFromPath(QString path);
99 bool saveToPath(QString path) const;
100
103
104 QString description() const;
105
106 QmlPositioned* departure() const;
107 QmlPositioned* destination() const;
108 QmlPositioned* alternate() const;
109
111
112 FlightRules flightRules() const;
113 FlightType flightType() const;
114
115 QString callsign() const;
116 QString remarks() const;
117 QString aircraftType() const;
118
119 int estimatedDurationMinutes() const;
121
122 Q_INVOKABLE bool tryParseRoute(QString routeDesc);
123
124 Q_INVOKABLE bool tryGenerateRoute();
125 Q_INVOKABLE void clearRoute();
126
128 { return _legs; }
129
130 QString icaoRoute() const;
131
133 { return _fp; }
134
135 Q_INVOKABLE bool loadPlan();
136signals:
139
142
143public slots:
144
145 void setFlightType(FlightType ty);
147
148 void setCallsign(QString s);
149 void setRemarks(QString r);
150 void setAircraftType(QString ty);
151
152 void setDeparture(QmlPositioned* destinationAirport);
153 void setDestination(QmlPositioned* destinationAirport);
154 void setAlternate(QmlPositioned* apt);
155
157
158 void setEstimatedDurationMinutes(int mins);
159
160 void computeDuration();
161
162 void clearPlan();
163 void savePlan();
164private slots:
165 void onCollectConfig();
166 void onSave();
167 void onRestore();
168
169private:
170 friend class FPDelegate;
171
173 LegsModel* _legs = nullptr;
174 std::unique_ptr<FPDelegate> _delegate;
175 LaunchConfig* _config = nullptr;
176 bool _enabled = false;
177};
178
179#endif // FLIGHTPLANCONTROLLER_HXX
void setDeparture(QmlPositioned *destinationAirport)
void setFlightType(FlightType ty)
Q_INVOKABLE bool tryParseRoute(QString routeDesc)
Q_INVOKABLE bool tryGenerateRoute()
void setFlightRules(FlightRules r)
void setDestination(QmlPositioned *destinationAirport)
void setAlternate(QmlPositioned *apt)
bool saveToPath(QString path) const
bool loadFromPath(QString path)
FlightPlanController(QObject *parent, LaunchConfig *config)
flightgear::FlightPlanRef flightplan() const
Q_INVOKABLE void clearRoute()
void descriptionChanged(QString description)
void enabledChanged(bool enabled)
void setCruiseAltitude(QuantityValue alt)
void setEstimatedDurationMinutes(int mins)
void setCruiseSpeed(QuantityValue cruiseSpeed)
int rowCount(const QModelIndex &parent) const override
void numLegsChanged()
QHash< int, QByteArray > roleNames() const override
void setFlightPlan(flightgear::FlightPlanRef f)
QVariant data(const QModelIndex &index, int role) const override
SGSharedPtr< FlightPlan > FlightPlanRef