swift
mappingcomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 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_MAPPINGCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_MAPPINGCOMPONENT_H
8 
9 #include <QFrame>
10 #include <QObject>
11 #include <QScopedPointer>
12 #include <QString>
13 #include <QTimer>
14 #include <Qt>
15 
19 #include "gui/swiftguiexport.h"
20 #include "misc/identifiable.h"
21 #include "misc/identifier.h"
23 #include "misc/propertyindex.h"
26 #include "misc/tokenbucket.h"
27 #include "misc/variant.h"
28 
29 class QModelIndex;
30 
31 namespace Ui
32 {
33  class CMappingComponent;
34 }
35 namespace swift::misc
36 {
37  namespace aviation
38  {
39  class CCallsign;
40  }
41  namespace simulation
42  {
43  class CSimulatedAircraft;
44  }
45 } // namespace swift::misc
46 namespace swift::gui
47 {
48  namespace views
49  {
50  class CCheckBoxDelegate;
51  }
52  namespace components
53  {
56  public COverlayMessagesFrame,
59  {
60  Q_OBJECT
61 
62  public:
65  enum TabWidget
66  {
67  TabRenderedAircraft = 0,
68  TabAircraftModels,
69  TabInterpolatorSetup,
70  TabStatistics,
71  TabMatchingLog,
72  TabPartsLog
73  };
74 
76  static const QStringList &getLogCategories();
77 
79  explicit CMappingComponent(QWidget *parent = nullptr);
80 
82  virtual ~CMappingComponent() override;
83 
85  int countCurrentMappings() const;
86 
88  int countAircraftModels() const;
89 
91  void setTab(TabWidget tab);
92 
94  swift::misc::simulation::CAircraftModelList findModelsStartingWith(const QString &modelName,
95  Qt::CaseSensitivity cs);
96 
97  signals:
100 
101  private:
103  void onModelSetChanged(const swift::misc::simulation::CSimulatorInfo &dummy);
104 
106  void onRowCountChanged(int count, bool withFilter);
107 
110  void onChangedSimulatedAircraftInView(const swift::misc::CVariant &simulatedAircraft,
111  const swift::misc::CPropertyIndex &index);
112 
114  void onAircraftSelectedInView(const QModelIndex &index);
115 
117  void onSaveAircraft();
118 
120  void onResetAircraft();
121 
123  void onModelPreviewChanged(int state);
124 
126  void onModelsUpdateRequested();
127 
129  void onTempDisableModelsForMatchingRequested(const swift::misc::simulation::CAircraftModelList &models);
130 
132  void onRemoteAircraftModelChanged(const swift::misc::simulation::CSimulatedAircraft &aircraft,
133  const swift::misc::CIdentifier &originator);
134 
136  void onConnectionStatusChanged(const swift::misc::network::CConnectionStatus &from,
138 
140  void onTabWidgetChanged(int index);
141 
143  swift::misc::simulation::CSimulatorInfo getConnectedOrSelectedSimulator() const;
144 
146  bool isSimulatorAvailable() const;
147 
149  void showAircraftModelDetails(bool show);
150 
152  void onAddingRemoteAircraftFailed(const swift::misc::simulation::CSimulatedAircraft &aircraft,
153  bool disabled, bool failover, const swift::misc::CStatusMessage &message);
154 
156  void timerUpdate();
157 
159  void tokenBucketUpdate();
160 
162  void tokenBucketUpdateAircraft(const swift::misc::simulation::CSimulatedAircraft &aircraft);
163 
165  void settingsChanged();
166 
168  void onNetworkConnectionStatusChanged(const swift::misc::network::CConnectionStatus &from,
170 
172  void updateRenderedAircraftView(bool forceUpdate = false);
173 
175  swift::misc::aviation::CCallsign validateRenderedCallsign();
176 
178  void onModelSetSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator);
179 
181  void onSimulatorPluginChanged(const swift::misc::simulation::CSimulatorPluginInfo &pluginInfo);
182 
184  void onSimulatorStatusChanged(int status);
185 
187  void doMatchingsAgain();
188 
189  static constexpr std::chrono::milliseconds OverlayMessageMs { 5000 };
190  QScopedPointer<Ui::CMappingComponent> ui;
191  QTimer m_updateTimer;
192  bool m_missedRenderedAircraftUpdate = true;
193  swift::misc::CTokenBucket m_bucket { 3, 5000, 1 };
195  this, &CMappingComponent::settingsChanged
196  };
197  views::CCheckBoxDelegate *m_currentMappingsViewDelegate = nullptr;
198  };
199  } // namespace components
200 } // namespace swift::gui
201 
202 #endif // SWIFT_GUI_COMPONENTS_MAPPINGCOMPONENT_H
Helper class: If a component is residing in an dockable widget. This class provides access to its inf...
Using this class provides a QFrame with the overlay functionality already integrated.
void requestValidationDialog()
Request the validation dialog.
Base class with a member CIdentifier to be inherited by a class which has an identity in the environm...
Definition: identifiable.h:24
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition: identifier.h:29
Class template for accessing a specific value in the CSettingsCache.
Streamable status message, e.g.
Token bucket algorithm.
Definition: tokenbucket.h:21
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
Value object encapsulating information of a callsign.
Definition: callsign.h:30
Value object encapsulating information about a connection status.
Value object encapsulating a list of aircraft models.
Comprehensive information of an aircraft.
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
GUI related classes.
Free functions in swift::misc.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.