swift
flightplancomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_COMPONENTS_FLIGHTPLANCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_FLIGHTPLANCOMPONENT_H
8 
9 #include <QFileDialog>
10 #include <QListWidget>
11 #include <QMenu>
12 #include <QNetworkReply>
13 #include <QObject>
14 #include <QScopedPointer>
15 #include <QStringList>
16 #include <QTabWidget>
17 #include <QtGlobal>
18 
20 #include "gui/swiftguiexport.h"
21 #include "misc/aviation/comnavequipment.h"
23 #include "misc/aviation/ssrequipment.h"
24 #include "misc/datacache.h"
25 #include "misc/directories.h"
26 #include "misc/identifier.h"
27 #include "misc/logcategories.h"
29 #include "misc/network/user.h"
30 #include "misc/settingscache.h"
33 #include "misc/statusmessagelist.h"
34 
35 namespace Ui
36 {
37  class CFlightPlanComponent;
38 }
39 namespace swift::gui::components
40 {
41  namespace FlightPlanSettings
42  {
44  struct TRemarksHistory : public swift::misc::TSettingTrait<QStringList>
45  {
47  static const char *key() { return "flightplan/remarkshistory"; }
48 
50  static const QString &humanReadable()
51  {
52  static const QString name("FP remarks history");
53  return name;
54  }
55  };
56 
59  {
61  static const char *key() { return "flightplan/remarkshistoryadd"; }
62 
64  static const QString &humanReadable()
65  {
66  static const QString name("FP remarks history (add)");
67  return name;
68  }
69  };
70  } // namespace FlightPlanSettings
71 
72  class CStringListDialog;
73  class CAltitudeDialog;
74  class CSimBriefDownloadDialog;
75 
78  {
79  Q_OBJECT
80 
81  public:
83  explicit CFlightPlanComponent(QWidget *parent = nullptr);
84 
87 
89  void loginDataSet();
90 
92  void fillWithFlightPlanData(const swift::misc::aviation::CFlightPlan &flightPlan);
93 
95  const swift::misc::aviation::CFlightPlan &getSentFlightPlan() const { return m_sentFlightPlan; }
96 
98  static const QStringList &getLogCategories();
99 
100  private:
101  static constexpr std::chrono::milliseconds OverlayTimeout { 5000 };
103  CAltitudeDialog *m_altitudeDialog = nullptr;
104  CStringListDialog *m_fpRemarksDialog = nullptr;
105  CSimBriefDownloadDialog *m_simBriefDialog = nullptr;
106  QMenu *m_navComEquipmentMenu = nullptr;
107  QMenu *m_ssrEquipmentMenu = nullptr;
108  swift::misc::aviation::CFlightPlan m_sentFlightPlan;
110  swift::misc::aviation::CComNavEquipment m_navComEquipment;
111  swift::misc::aviation::CSsrEquipment m_ssrEquipment;
112  swift::misc::CIdentifier m_identifier { "FlightPlanComponent", this };
114  this
115  };
118  this
119  };
121  this
122  };
124  this
125  };
126 
127  struct WakeTurbulenceEntry
128  {
129  QString m_name;
131  };
132 
133  const QList<WakeTurbulenceEntry> m_wakeTurbulenceCategories = {
138  };
139 
141  swift::misc::CStatusMessageList validateAndInitializeFlightPlan(swift::misc::aviation::CFlightPlan &fligtPlan);
142 
144  static const QString &defaultIcao()
145  {
146  static const QString d("ICAO");
147  return d;
148  }
149 
151  static const QString &defaultTime()
152  {
153  static const QString t("00:00");
154  return t;
155  }
156 
158  const swift::misc::CIdentifier &flightPlanIdentifier() const { return m_identifier; }
159 
161  void prefillWithOwnAircraftData();
162 
164  void prefillWithAircraftData(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool force = false);
165 
167  void prefillWithUserData(const swift::misc::network::CUser &user);
168 
170  void initCompleters();
171 
173  QString getDefaultFilename(bool load);
174 
176  void currentTextChangedToBuildRemarks(const QString &text)
177  {
178  this->buildRemarksString();
179  Q_UNUSED(text)
180  }
181 
183  void syncVoiceComboBoxes(const QString &text);
184 
186  void sendFlightPlan();
187 
189  void resetFlightPlan();
190 
192  void loadFromDisk();
193 
195  void loadTemplateFromDisk();
196 
198  void saveToDisk();
199 
201  bool saveFPToDisk(const QString &fileName);
202 
204  void saveTemplateToDisk();
205 
207  void clearTemplate();
208 
210  QString getTemplateName() const;
211 
213  void setSelcalInOwnAircraft();
214 
216  void loadFlightPlanFromNetwork();
217 
219  void buildRemarksString();
220 
222  void copyRemarksConfirmed() { this->copyRemarks(true); }
223 
225  void copyRemarks(bool confirm = true);
226 
228  void currentTabGenerator();
229 
231  void swiftWebDataRead();
232 
234  void aircraftTypeChanged();
235 
237  void syncWithSimulator();
238 
240  swift::misc::aviation::CAircraftIcaoCode getAircraftIcaoCode() const;
241 
243  void showEquipmentCodesTab();
244 
246  bool isVfr() const;
247 
250 
252  bool overrideRemarks();
253 
255  void updateDirectorySettings(const QString &fileOrDirectory);
256 
258  void altitudeDialog();
259 
261  void remarksHistory();
262 
264  void updateRemarksHistories();
265 
267  void setRemarksUIValues(const QString &remarks);
268 
270  void loadFromSimBrief();
271 
273  void handleSimBriefResponse(QNetworkReply *nwReplyPtr);
274 
276  void setupNavComContextMenu();
277 
279  void setupSsrContextMenu();
280 
282  void updateNavComEquipmentFromSelection();
283 
285  void updateSsrEquipmentFromSelection();
286 
288  void updateNavComEquipmentUi();
289 
291  void updateSsrEquipmentUi();
292 
294  void updateWakeTurbulenceCategorySelector(const swift::misc::aviation::CWakeTurbulenceCategory &wtc);
295 
297  swift::misc::aviation::CWakeTurbulenceCategory getSelectedWakeTurbulenceCategory() const;
298 
300  static QListWidget *getMenuEquipmentList(QMenu *menu);
301 
304  static void updateListSelection(QMenu *menu, const QStringList &enabledOptions);
305 
307  static bool consolidateRemarks(QStringList &remarks, const QString &newRemarks);
308  };
309 } // namespace swift::gui::components
310 #endif // SWIFT_GUI_COMPONENTS_FLIGHTPLANCOMPONENT_H
Using this class provides a QTabWidget with the overlay functionality already integrated.
const swift::misc::aviation::CFlightPlan & getSentFlightPlan() const
Get sent flight plan.
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Status messages, e.g. from Core -> GUI.
Value object for ICAO classification.
Value object for a flight plan.
Definition: flightplan.h:148
FlightRules
Flight rules (VFR or IFR)
Definition: flightplan.h:155
ICAO flightplan field 10b.
Definition: ssrequipment.h:16
Value object encapsulating information of a user.
Definition: user.h:28
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Comprehensive information of an aircraft.
High level reusable GUI components.
Definition: aboutdialog.cpp:14
static const char * key()
Key string of the value. Reimplemented in derived class.
static const QString & humanReadable()
Optional human readable name.
static const char * key()
Key string of the value. Reimplemented in derived class.
static const QString & humanReadable()
Optional human readable name.
Base class for traits to be used as template argument to swift::misc::CSetting.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.