swift
dbownmodelsetcomponent.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2016 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_CDBOWNMODELSETCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_CDBOWNMODELSETCOMPONENT_H
8 
9 #include <QFrame>
10 #include <QList>
11 #include <QObject>
12 #include <QScopedPointer>
13 
16 #include "gui/menus/menudelegate.h"
23 #include "misc/statusmessage.h"
24 
25 class QAction;
26 
27 namespace Ui
28 {
29  class CDbOwnModelSetComponent;
30 }
31 namespace swift::misc::simulation
32 {
33  class CAircraftModel;
34 }
35 namespace swift::gui
36 {
37  namespace menus
38  {
39  class CMenuActions;
40  }
41  namespace views
42  {
43  class CAircraftModelView;
44  class CAircraftModelStatisticsDialog;
45  } // namespace views
46  namespace components
47  {
48  class CDbMappingComponent;
49  class CDbOwnModelSetFormDialog;
50  class CDbReduceModelDuplicates;
51  class CCopyModelsFromOtherSwiftVersionsDialog;
52  class CFirstModelSetDialog;
53 
58  public QFrame,
64  {
65  Q_OBJECT
72 
73  public:
75  explicit CDbOwnModelSetComponent(QWidget *parent = nullptr);
76 
78  virtual ~CDbOwnModelSetComponent() override;
79 
82 
86 
90 
94 
97  int getModelSetCountFromView() const;
98 
101  {
102  return this->getCachedModels(m_simulator);
103  }
104 
106  int getModelSetCount() const { return this->getCachedModelsCount(m_simulator); }
107 
109  QString getModelCacheCountAndTimestamp() const { return QString::number(getModelSetCount()); }
110 
113 
116 
119 
121  virtual void setMappingComponent(CDbMappingComponent *component) override;
122 
125 
128  virtual void setModels(const swift::misc::simulation::CAircraftModelList &models) override
129  {
130  this->setModelSet(models, this->getModelSetSimulator());
131  }
132  virtual int updateModels(const swift::misc::simulation::CAircraftModelList &models) override
133  {
134  return this->replaceOrAddModelSet(models, this->getModelSetSimulator());
135  }
137  {
138  return this->getModelSetSimulator();
139  }
141 
143  void enableButtons(bool firstSet, bool newSet);
144 
147  const swift::misc::simulation::CSimulatorInfo &simulator);
148 
151  const swift::misc::simulation::CSimulatorInfo &simulator);
152 
153  private:
155  void tabIndexChanged(int index);
156 
158  void buttonClicked();
159 
161  void onRowCountChanged(int count, bool withFilter);
162 
164  void onJsonDataLoaded(const swift::misc::simulation::CSimulatorInfo &simulator);
165 
167  void viewModelChanged();
168 
170  void distributorPreferencesChanged();
171 
173  void reduceModels();
174 
176  void removeExcludedModels();
177 
179  void removeNonDBModels();
180 
182  void setSaveFileName(const swift::misc::simulation::CSimulatorInfo &simulator);
183 
185  void updateViewToCurrentModels();
186 
188  void createNewSet();
189 
191  void firstSet();
192 
194  void copyFromAnotherSwift();
195 
197  void showModelStatistics();
198 
200  void updateDistributorOrder(const swift::misc::simulation::CSimulatorInfo &simulator);
201 
203  bool runsInDialog();
204 
205  QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
206  QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
207  QScopedPointer<CFirstModelSetDialog> m_firstModelSetDialog;
208  QScopedPointer<CDbReduceModelDuplicates> m_reduceModelsDialog;
209  QScopedPointer<CCopyModelsFromOtherSwiftVersionsDialog> m_copyFromAnotherSwiftDialog;
210  QScopedPointer<views::CAircraftModelStatisticsDialog> m_modelStatisticsDialog;
211 
214  m_distributorPreferences {
215  this, &CDbOwnModelSetComponent::distributorPreferencesChanged
216  };
218  this
219  };
221  this
222  };
223 
224  // -------------------------- custom menus -----------------------------------
225 
229  class CLoadModelSetMenu : public menus::IMenuDelegate
230  {
231  public:
233  CLoadModelSetMenu(CDbOwnModelSetComponent *ownModelSetComponent)
234  : menus::IMenuDelegate(ownModelSetComponent)
235  {}
236 
238  virtual void customMenu(swift::gui::menus::CMenuActions &menuActions) override;
239 
240  private:
241  QList<QAction *> m_setActions;
242  QList<QAction *> m_setNewActions;
243  };
244  };
245  } // namespace components
246 } // namespace swift::gui
247 
248 #endif // SWIFT_GUI_COMPONENTS_CDBOWNMODELSETCOMPONENT_H
Allows subcomponents to gain access to model component.
const swift::misc::simulation::CAircraftModelList & getModelSetFromView() const
Current model set for simulator CDbOwnModelSetComponent::getModelSetSimulator.
swift::misc::simulation::CAircraftModelList getModelSet() const
Cached models for current simulator.
int getModelSetCountFromView() const
Current sount of model set for simulator CDbOwnModelSetComponent::getModelSetSimulator.
int replaceOrAddModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Replace or add models provided for a given simulator.
void setSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Simulator.
swift::misc::CStatusMessage addToModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Add to model set.
views::CAircraftModelView * view() const
Corresponding view.
void setSimulatorSelectorMode(CSimulatorSelector::Mode mode)
How to display.
swift::misc::simulation::CSimulatorInfo getModelSetSimulator() const
Model set is for simulator.
virtual void setMappingComponent(CDbMappingComponent *component)
Set the corresponding component.
void triggerSetSimulatorDeferred(const swift::misc::simulation::CSimulatorInfo &simulator)
Deferred init of simulator.
CDbOwnModelSetComponent(QWidget *parent=nullptr)
Constructor.
void setModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set the model set for a given simulator.
virtual swift::misc::simulation::CSimulatorInfo getSelectedSimulator() const
Simulator.
QString getModelCacheCountAndTimestamp() const
Count and cache timestamp.
virtual int updateModels(const swift::misc::simulation::CAircraftModelList &models)
Update models.
int getModelSetCount() const
Cached models count for current simulator.
void enableButtons(bool firstSet, bool newSet)
Enable buttons.
virtual void setModels(const swift::misc::simulation::CAircraftModelList &models)
Set models.
Bunch of CMenuAction objects.
Definition: menuaction.h:384
Streamable status message, e.g.
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Value object encapsulating a list of aircraft models.
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
Interface to "something" backing models, which can be set.
Interface to "something" backing models, which can be modified (updated)
Interface to "something" backing models, which can be set.
Interface to "something" backing models, which can be modified (updated)
Interface to "something" allowing a simulator selection.
Basically a QObject free (delegate based) version of CCentralMultiSimulatorModelSetCachesProvider.
Definition: modelcaches.h:640
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:644
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:648
GUI related classes.