swift
dbownmodelscomponent.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_DBOWNMODELSCOMPONENT_H
7 #define SWIFT_GUI_COMPONENTS_DBOWNMODELSCOMPONENT_H
8 
9 #include <memory>
10 
11 #include <QFrame>
12 #include <QList>
13 #include <QObject>
14 #include <QScopedPointer>
15 #include <QStringList>
16 
18 #include "gui/menus/menudelegate.h"
20 #include "misc/connectionguard.h"
21 #include "misc/datacache.h"
22 #include "misc/directories.h"
29 #include "misc/statusmessage.h"
30 
31 class QAction;
32 
33 namespace Ui
34 {
35  class CDbOwnModelsComponent;
36 }
37 namespace swift::gui
38 {
39  namespace menus
40  {
41  class CMenuActions;
42  }
43  namespace models
44  {
45  class CAircraftModelListModel;
46  }
47  namespace views
48  {
49  class CAircraftModelView;
50  }
51  namespace components
52  {
57  public COverlayMessagesFrame,
62  {
63  Q_OBJECT
68 
69  public:
71  explicit CDbOwnModelsComponent(QWidget *parent = nullptr);
72 
74  virtual ~CDbOwnModelsComponent() override;
75 
77  static const QStringList &getLogCategories();
78 
81 
84 
88 
91 
94 
96  bool setSimulator(const swift::misc::simulation::CSimulatorInfo &simulator, bool forced = false);
97 
100 
102  int getOwnModelsCount() const;
103 
105  QString getInfoString() const;
106 
108  QString getInfoStringFsFamily() const;
109 
112 
114  void clearView();
115 
118 
121 
124 
127  bool onlyIfNotEmpty);
128 
130  void gracefulShutdown();
131 
134  virtual void setModels(const swift::misc::simulation::CAircraftModelList &models) override
135  {
136  this->setModelsForSimulator(models, this->getOwnModelsSimulator());
137  }
139  const swift::misc::simulation::CSimulatorInfo &simulator) override;
140  virtual int updateModels(const swift::misc::simulation::CAircraftModelList &models) override
141  {
142  return this->updateModelsForSimulator(models, this->getOwnModelsSimulator());
143  }
145  const swift::misc::simulation::CSimulatorInfo &simulator) override;
147 
148  signals:
151 
154 
155  private:
156  QScopedPointer<Ui::CDbOwnModelsComponent> ui;
158  nullptr;
161  this
162  };
164  this
165  };
166 
168  void requestOwnModelsUpdate();
169 
171  void loadInstalledModels(const swift::misc::simulation::CSimulatorInfo &simulator,
172  swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
173  const QStringList &modelDirectories = {});
174 
176  void onModelLoaderDiskLoadingStarted(const swift::misc::simulation::CSimulatorInfo &simulator,
177  swift::misc::simulation::IAircraftModelLoader::LoadMode mode);
178 
180  void onModelLoadingProgress(const swift::misc::simulation::CSimulatorInfo &simulator,
181  const QString &message, int progress);
182 
184  void onModelLoaderLoadingFinished(const swift::misc::CStatusMessageList &statusMessages,
187 
189  void onViewDiskLoadingFinished(const swift::misc::CStatusMessage &status);
190 
192  void onCacheChanged(const swift::misc::simulation::CSimulatorInfo &simulator);
193 
195  void requestSimulatorModels(const swift::misc::simulation::CSimulatorInfo &simulator,
196  swift::misc::simulation::IAircraftModelLoader::LoadMode mode,
197  const QStringList &modelDirectories = {});
198 
200  void requestSimulatorModelsWithCacheInBackground(const swift::misc::simulation::CSimulatorInfo &simulator);
201 
203  void clearSimulatorCache(const swift::misc::simulation::CSimulatorInfo &simulator);
204 
206  void onSimulatorSelectorChanged();
207 
209  bool initModelLoader(const swift::misc::simulation::CSimulatorInfo &simulator,
210  swift::misc::simulation::IAircraftModelLoader::LoadMode load =
211  swift::misc::simulation::IAircraftModelLoader::NotSet);
212 
214  void setSaveFileName(const swift::misc::simulation::CSimulatorInfo &sim);
215 
217  QString directorySelector(const swift::misc::simulation::CSimulatorInfo &simulatorInfo);
218 
220  void setUiSimulatorString(const swift::misc::simulation::CSimulatorInfo &simulatorInfo);
221 
223  void confirmedForcedReloadCurrentSimulator();
224 
226  void confirmedForcedReload(const swift::misc::simulation::CSimulatorInfo &simulator);
227 
229  void runScriptCSL2XSB();
230 
234  class CLoadModelsMenu : public menus::IMenuDelegate
235  {
236  public:
238  CLoadModelsMenu(CDbOwnModelsComponent *ownModelsComponent)
239  : swift::gui::menus::IMenuDelegate(ownModelsComponent)
240  {}
241 
243  virtual void customMenu(menus::CMenuActions &menuActions) override;
244 
245  private:
246  QAction *m_csl2xsbAction = nullptr;
247  };
248  };
249  } // namespace components
250 } // namespace swift::gui
251 #endif // SWIFT_GUI_COMPONENTS_DBOWNMODELSCOMPONENT_H
Using this class provides a QFrame with the overlay functionality already integrated.
Handling of own models on disk (the models installed for the simulator)
virtual int updateModelsForSimulator(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set models.
swift::misc::simulation::CAircraftModelList getOwnModels() const
Own models.
swift::misc::CStatusMessage updateViewAndCache(const swift::misc::simulation::CAircraftModelList &models)
Update view and cache.
models::CAircraftModelListModel * model() const
Access to aircraft model.
swift::misc::simulation::CAircraftModelList getOwnSelectedModels() const
Own models selected in view.
static const QStringList & getLogCategories()
Log categories.
int getOwnModelsCount() const
Number of own models.
CDbOwnModelsComponent(QWidget *parent=nullptr)
Constructor.
swift::misc::simulation::IAircraftModelLoader * modelLoader() const
Access to model loader.
bool requestModelsInBackground(const swift::misc::simulation::CSimulatorInfo &simulator, bool onlyIfNotEmpty)
Forced read for given simulator.
virtual void setModelsForSimulator(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Set models.
virtual int updateModels(const swift::misc::simulation::CAircraftModelList &models)
Update models.
swift::misc::simulation::CAircraftModelList getOwnCachedModels(const swift::misc::simulation::CSimulatorInfo &simulator) const
Own cached models from loader.
bool setSimulator(const swift::misc::simulation::CSimulatorInfo &simulator, bool forced=false)
Change current simulator for own models.
swift::misc::simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const
Own (installed) model for given model string.
void ownModelsSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Own models simulator has changed.
void successfullyLoadedModels(const swift::misc::simulation::CSimulatorInfo &simulator, int count)
Models have been successfully loaded.
swift::misc::simulation::CSimulatorInfo getOwnModelsSimulator() const
Own models for simulator.
swift::gui::views::CAircraftModelView * view() const
Models view.
void setSimulatorSelectorMode(CSimulatorSelector::Mode mode)
How to display.
QString getInfoStringFsFamily() const
Info string without XPlane (FSX,P3D, FS9)
virtual void setModels(const swift::misc::simulation::CAircraftModelList &models)
Set models.
QString getInfoString() const
Info string about models in cache.
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
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
Load the aircraft for a simulator.
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)
GUI related classes.