swift
dbstashcomponent.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_DBSTASHCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_DBSTASHCOMPONENT_H
8 
9 #include <functional>
10 
11 #include <QFrame>
12 #include <QList>
13 #include <QMessageBox>
14 #include <QObject>
15 #include <QScopedPointer>
16 #include <QStringList>
17 
21 #include "gui/swiftguiexport.h"
28 #include "misc/statusmessage.h"
29 #include "misc/statusmessagelist.h"
30 
31 class QWidget;
32 
33 namespace swift::misc
34 {
35  class CLogCategoryList;
36  namespace aviation
37  {
38  class CAircraftIcaoCode;
39  class CLivery;
40  } // namespace aviation
41 } // namespace swift::misc
42 namespace Ui
43 {
44  class CDbStashComponent;
45 }
46 namespace swift::gui
47 {
48  namespace views
49  {
50  class CAircraftModelView;
51  }
52  namespace components
53  {
58  public QFrame,
61  {
62  Q_OBJECT
63 
64  public:
66  static constexpr int MaxModelPublished = 1000;
67 
69  explicit CDbStashComponent(QWidget *parent = nullptr);
70 
72  virtual ~CDbStashComponent();
73 
76  bool allowReplace) const;
77 
79  int unstashModels(const QSet<int> &keys);
80 
82  int unstashModels(const QStringList &modelStrings);
83 
85  int unstashModels(const swift::misc::simulation::CAircraftModelList &models);
86 
89 
91  bool hasStashedModels() const;
92 
94  int getStashedModelsCount() const;
95 
97  QStringList getStashedModelStrings() const;
98 
100  const swift::misc::simulation::CAircraftModelList &getStashedModels() const;
101 
103  swift::misc::simulation::CAircraftModel getStashedModel(const QString &modelString) const;
104 
106  void applyToSelected(const swift::misc::aviation::CLivery &livery, bool acceptWarnings = true);
107 
109  void applyToSelected(const swift::misc::aviation::CAircraftIcaoCode &icao, bool acceptWarnings = true);
110 
112  void applyToSelected(const swift::misc::aviation::CAirlineIcaoCode &icao, bool acceptWarnings = true);
113 
115  void applyToSelected(const swift::misc::simulation::CDistributor &distributor, bool acceptWarnings = true);
116 
118  void applyToSelected(const swift::misc::CPropertyIndexVariantMap &vm);
119 
122  consolidateModel(const swift::misc::simulation::CAircraftModel &model) const;
123 
125  void showChangedAttributes();
126 
128  void clearValidationHighlighting();
129 
130  public slots:
133  bool replace = false, bool consolidateWithDbData = true,
134  bool clearHighlighting = true);
135 
138  bool replace = false, bool consolidateWithDbData = true,
139  bool clearHighlighting = true);
140 
142  void replaceModelsUnvalidated(const swift::misc::simulation::CAircraftModelList &models);
143 
144  signals:
147 
150  bool directWrite);
151 
152  private:
153  QScopedPointer<Ui::CDbStashComponent> ui;
155  this, &CDbStashComponent::onUserChanged
156  };
157 
159  void onUnstashPressed();
160 
162  void onValidatePressed();
163 
165  void onRemoveInvalidPressed();
166 
168  void onPublishPressed();
169 
171  void onPublishedModelsResponse(const swift::misc::simulation::CAircraftModelList &publishedModels,
172  const swift::misc::simulation::CAircraftModelList &skippedModels,
173  const swift::misc::CStatusMessageList &msgs, bool sendingSuccesful,
174  bool directWrite);
175 
177  void copyOverValuesToSelectedModels();
178 
180  void modifyModelDialog();
181 
183  void onRowCountChanged(int number, bool filter);
184 
186  void onUserChanged();
187 
189  bool showOverlayMessages(const swift::misc::CStatusMessageList &msgs, bool onlyErrors = false,
190  bool appendOldMessages = false,
191  std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
192 
194  bool showOverlayMessagesWithConfirmation(const swift::misc::CStatusMessageList &msgs,
195  bool appendOldMessages, const QString &confirmation,
196  std::function<void()> okLambda,
197  QMessageBox::StandardButton defaultButton, bool onlyErrors = false,
198  std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
199 
201  bool showOverlayMessage(const swift::misc::CStatusMessage &msg,
202  std::chrono::milliseconds timeout = std::chrono::milliseconds(0));
203 
205  void clearOverlayMessages();
206 
209  swift::misc::simulation::CAircraftModelList &invalidModels) const;
210 
212  bool validateAndDisplay(swift::misc::simulation::CAircraftModelList &validModels,
214  bool displayInfo = false);
215 
217  void enableButtonRow();
218 
220  const swift::misc::CLogCategoryList &validationCategories() const;
221 
223  swift::misc::simulation::CAircraftModelList getSelectedOrAllModels() const;
224 
227  consolidateWithDbData(const swift::misc::simulation::CAircraftModel &model, bool forced) const;
228 
231  consolidateWithOwnModels(const swift::misc::simulation::CAircraftModel &model) const;
232 
234  swift::misc::network::CAuthenticatedUser getSwiftDbUser() const;
235  };
236  } // namespace components
237 } // namespace swift::gui
238 
239 #endif // SWIFT_GUI_COMPONENTS_DBSTASHCOMPONENT_H
Helper class: If a component is residing in an dockable widget. This class provides access to its inf...
Allows subcomponents to gain access to model component.
void stashedModelsChanged()
Stashed models have been changed.
void modelsSuccessfullyPublished(const swift::misc::simulation::CAircraftModelList &publishedModels, bool directWrite)
Models succesfully published.
A sequence of log categories.
Specialized value object compliant map for variants, based on indexes.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Value object for ICAO classification.
Value object for ICAO classification.
Value object encapsulating information about an airpot.
Definition: livery.h:29
Value object encapsulating information of an authentiated user.
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Value object encapsulating a list of aircraft models.
Value object encapsulating information of software distributor.
Definition: distributor.h:33
GUI related classes.
Free functions in swift::misc.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.