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 <QNetworkReply>
12 #include <QObject>
13 #include <QScopedPointer>
14 #include <QStringList>
15 #include <QTabWidget>
16 #include <QtGlobal>
17 
19 #include "gui/swiftguiexport.h"
20 #include "misc/aviation/comnavequipment.h"
22 #include "misc/aviation/ssrequipment.h"
23 #include "misc/datacache.h"
24 #include "misc/directories.h"
25 #include "misc/identifier.h"
26 #include "misc/logcategories.h"
28 #include "misc/network/user.h"
29 #include "misc/settingscache.h"
32 #include "misc/statusmessagelist.h"
33 
34 namespace Ui
35 {
36  class CFlightPlanComponent;
37 }
38 namespace swift::gui::components
39 {
40  namespace FlightPlanSettings
41  {
43  struct TRemarksHistory : public swift::misc::TSettingTrait<QStringList>
44  {
46  static const char *key() { return "flightplan/remarkshistory"; }
47 
49  static const QString &humanReadable()
50  {
51  static const QString name("FP remarks history");
52  return name;
53  }
54  };
55 
58  {
60  static const char *key() { return "flightplan/remarkshistoryadd"; }
61 
63  static const QString &humanReadable()
64  {
65  static const QString name("FP remarks history (add)");
66  return name;
67  }
68  };
69  } // namespace FlightPlanSettings
70 
71  class CStringListDialog;
72  class CAltitudeDialog;
73  class CSimBriefDownloadDialog;
74 
77  {
78  Q_OBJECT
79 
80  public:
82  explicit CFlightPlanComponent(QWidget *parent = nullptr);
83 
85  virtual ~CFlightPlanComponent() override;
86 
88  void loginDataSet();
89 
91  void fillWithFlightPlanData(const swift::misc::aviation::CFlightPlan &flightPlan);
92 
94  const swift::misc::aviation::CFlightPlan &getSentFlightPlan() const { return m_sentFlightPlan; }
95 
97  static const QStringList &getLogCategories();
98 
99  private:
100  static constexpr std::chrono::milliseconds OverlayTimeout { 5000 };
101  QScopedPointer<Ui::CFlightPlanComponent> ui;
102  CAltitudeDialog *m_altitudeDialog = nullptr;
103  CStringListDialog *m_fpRemarksDialog = nullptr;
104  CSimBriefDownloadDialog *m_simBriefDialog = nullptr;
105  QMenu *m_navComEquipmentMenu = nullptr;
106  QMenu *m_ssrEquipmentMenu = nullptr;
107  swift::misc::aviation::CFlightPlan m_sentFlightPlan;
109  swift::misc::aviation::CComNavEquipment m_navComEquipment;
110  swift::misc::aviation::CSsrEquipment m_ssrEquipment;
111  swift::misc::CIdentifier m_identifier { "FlightPlanComponent", this };
113  this
114  };
117  this
118  };
120  this
121  };
123  this
124  };
125 
126  struct WakeTurbulenceEntry
127  {
128  QString m_name;
130  };
131 
132  const QList<WakeTurbulenceEntry> m_wakeTurbulenceCategories = {
137  };
138 
140  swift::misc::CStatusMessageList validateAndInitializeFlightPlan(swift::misc::aviation::CFlightPlan &fligtPlan);
141 
143  static const QString &defaultIcao()
144  {
145  static const QString d("ICAO");
146  return d;
147  }
148 
150  static const QString &defaultTime()
151  {
152  static const QString t("00:00");
153  return t;
154  }
155 
157  const swift::misc::CIdentifier &flightPlanIdentifier() const { return m_identifier; }
158 
160  void prefillWithOwnAircraftData();
161 
163  void prefillWithAircraftData(const swift::misc::simulation::CSimulatedAircraft &aircraft, bool force = false);
164 
166  void prefillWithUserData(const swift::misc::network::CUser &user);
167 
169  void initCompleters();
170 
172  QString getDefaultFilename(bool load);
173 
175  void currentTextChangedToBuildRemarks(const QString &text)
176  {
177  this->buildRemarksString();
178  Q_UNUSED(text)
179  }
180 
182  void syncVoiceComboBoxes(const QString &text);
183 
185  void sendFlightPlan();
186 
188  void resetFlightPlan();
189 
191  void loadFromDisk();
192 
194  void loadTemplateFromDisk();
195 
197  void saveToDisk();
198 
200  bool saveFPToDisk(const QString &fileName);
201 
203  void saveTemplateToDisk();
204 
206  void clearTemplate();
207 
209  QString getTemplateName() const;
210 
212  void setSelcalInOwnAircraft();
213 
215  void loadFlightPlanFromNetwork();
216 
218  void buildRemarksString();
219 
221  void copyRemarksConfirmed() { this->copyRemarks(true); }
222 
224  void copyRemarks(bool confirm = true);
225 
227  void currentTabGenerator();
228 
230  void swiftWebDataRead();
231 
233  void aircraftTypeChanged();
234 
236  void syncWithSimulator();
237 
239  swift::misc::aviation::CAircraftIcaoCode getAircraftIcaoCode() const;
240 
242  void showEquipmentCodesTab();
243 
245  bool isVfr() const;
246 
249 
251  bool overrideRemarks();
252 
254  void updateDirectorySettings(const QString &fileOrDirectory);
255 
257  void altitudeDialog();
258 
260  void remarksHistory();
261 
263  void updateRemarksHistories();
264 
266  void setRemarksUIValues(const QString &remarks);
267 
269  void loadFromSimBrief();
270 
272  void handleSimBriefResponse(QNetworkReply *nwReplyPtr);
273 
275  void setupNavComContextMenu();
276 
278  void setupSsrContextMenu();
279 
281  void updateNavComEquipmentFromSelection();
282 
284  void updateSsrEquipmentFromSelection();
285 
287  void updateNavComEquipmentUi();
288 
290  void updateSsrEquipmentUi();
291 
293  void updateWakeTurbulenceCategorySelector(const swift::misc::aviation::CWakeTurbulenceCategory &wtc);
294 
296  swift::misc::aviation::CWakeTurbulenceCategory getSelectedWakeTurbulenceCategory() const;
297 
299  static QListWidget *getMenuEquipmentList(QMenu *menu);
300 
303  static void updateListSelection(QMenu *menu, const QStringList &enabledOptions);
304 
306  static bool consolidateRemarks(QStringList &remarks, const QString &newRemarks);
307  };
308 } // namespace swift::gui::components
309 #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:13
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.