swift
dbownmodelscomponent.cpp
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 #include <QAction>
7 #include <QDir>
8 #include <QFileDialog>
9 #include <QIcon>
10 #include <QMessageBox>
11 #include <QPointer>
12 #include <QtGlobal>
13 
14 #include "ui_dbownmodelscomponent.h"
15 
16 #include "config/buildconfig.h"
17 #include "core/db/databaseutils.h"
18 #include "core/webdataservices.h"
20 #include "gui/guiapplication.h"
21 #include "gui/menus/aircraftmodelmenus.h"
22 #include "gui/menus/menuaction.h"
25 #include "misc/icons.h"
26 #include "misc/logmessage.h"
27 #include "misc/processctrl.h"
29 #include "misc/statusmessage.h"
30 #include "misc/swiftdirectories.h"
31 
32 using namespace swift::config;
33 using namespace swift::misc;
34 using namespace swift::misc::simulation;
35 using namespace swift::core::db;
36 using namespace swift::gui::menus;
37 using namespace swift::gui::views;
38 using namespace swift::gui::models;
39 
40 namespace swift::gui::components
41 {
42  CDbOwnModelsComponent::CDbOwnModelsComponent(QWidget *parent)
43  : COverlayMessagesFrame(parent), ui(new Ui::CDbOwnModelsComponent)
44  {
45  ui->setupUi(this);
46  ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
47  ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelMappingTool);
48  ui->tvp_OwnAircraftModels->addFilterDialog();
49  ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
50  ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
51 
52  const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue();
53  ui->tvp_OwnAircraftModels->setCorrespondingSimulator(sim,
54  m_simulatorSettings.getSimulatorDirectoryOrDefault(sim));
55 
56  bool c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this,
57  &CDbOwnModelsComponent::requestOwnModelsUpdate);
58  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
59  c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::jsonLoadCompleted, this,
60  &CDbOwnModelsComponent::onViewDiskLoadingFinished, Qt::QueuedConnection);
61  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
62  c = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this,
63  &CDbOwnModelsComponent::onSimulatorSelectorChanged);
64  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
65  c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
66  &CMultiAircraftModelLoaderProvider::loadingFinished, this,
67  &CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
68  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
69  c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
70  &CMultiAircraftModelLoaderProvider::diskLoadingStarted, this,
71  &CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted, Qt::QueuedConnection);
72  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
73  c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
74  &CMultiAircraftModelLoaderProvider::loadingProgress, this,
75  &CDbOwnModelsComponent::onModelLoadingProgress, Qt::QueuedConnection);
76  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
77  c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
78  &CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged,
79  Qt::QueuedConnection);
80  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
81  c = connect(ui->pb_ForceReload, &QPushButton::released, this,
82  &CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator, Qt::QueuedConnection);
83  Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
84 
85  // Last selection isPinned -> no sync needed
86  ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
87  const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
88  if (simulator.isSingleSimulator())
89  {
90  m_simulator = simulator;
91  this->setUiSimulatorString(simulator);
92  const bool success = this->initModelLoader(simulator, IAircraftModelLoader::CacheOnly);
93  if (!success) { CLogMessage(this).error(u"Init of model loader failed in component"); }
94  }
95 
96  // menu
97  ui->tvp_OwnAircraftModels->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_OwnAircraftModels, this));
98  }
99 
101  {
102  // void
103  }
104 
106  {
107  static const QStringList l({ CLogCategories::modelGui(), CLogCategories::guiComponent() });
108  return l;
109  }
110 
111  CAircraftModelView *CDbOwnModelsComponent::view() const { return ui->tvp_OwnAircraftModels; }
112 
113  CAircraftModelListModel *CDbOwnModelsComponent::model() const { return ui->tvp_OwnAircraftModels->derivedModel(); }
114 
115  bool CDbOwnModelsComponent::requestModelsInBackground(const CSimulatorInfo &simulator, bool onlyIfNotEmpty)
116  {
117  this->setSimulator(simulator);
118  if (onlyIfNotEmpty && this->getOwnModelsCount() > 0) { return false; }
119  const IAircraftModelLoader::LoadMode mode =
120  onlyIfNotEmpty ? IAircraftModelLoader::InBackgroundNoCache : IAircraftModelLoader::LoadInBackground;
121  this->requestSimulatorModels(simulator, mode);
122  return true;
123  }
124 
126  {
127  return this->getOwnModels().findFirstByModelStringOrDefault(modelString);
128  }
129 
131  {
132  return this->getOwnCachedModels(this->getOwnModelsSimulator());
133  }
134 
136  {
137  static const CAircraftModelList empty;
138  if (!m_modelLoader) { return empty; }
139  return m_modelLoader->getCachedModels(simulator);
140  }
141 
143  {
144  return ui->tvp_OwnAircraftModels->selectedObjects();
145  }
146 
148  {
149  return ui->comp_SimulatorSelector->getValue();
150  }
151 
152  bool CDbOwnModelsComponent::setSimulator(const CSimulatorInfo &simulator, bool forced)
153  {
154  Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
155 
156  const bool simUnchanged = (m_simulator == simulator);
157 
158  if (!simUnchanged) { emit this->ownModelsSimulatorChanged(simulator); }
159  if (!forced && simUnchanged) { return false; }
160 
161  // changed simulator
162  m_simulator = simulator;
163  this->requestSimulatorModelsWithCacheInBackground(simulator);
164  ui->comp_SimulatorSelector->setValue(simulator);
165  this->setUiSimulatorString(simulator);
166  ui->tvp_OwnAircraftModels->setCorrespondingSimulator(
167  simulator, m_simulatorSettings.getSimulatorDirectoryOrDefault(simulator));
168  return true;
169  }
170 
172  {
173  ui->comp_SimulatorSelector->setMode(mode);
174  }
175 
176  void CDbOwnModelsComponent::onSimulatorSelectorChanged()
177  {
178  const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue());
179  this->setSimulator(simulator);
180  }
181 
183  {
184  if (!m_modelLoader) { return 0; }
185  return m_modelLoader->getCachedModelsCount(this->getOwnModelsSimulator());
186  }
187 
189  {
190  if (!m_modelLoader) { return {}; }
191  return m_modelLoader->getInfoString();
192  }
193 
195  {
196  if (!m_modelLoader) { return {}; }
197  return m_modelLoader->getInfoStringFsFamily();
198  }
199 
201  {
202  const CStatusMessage m = m_modelLoader->setCachedModels(models, this->getOwnModelsSimulator());
203  if (m.isSuccess()) { ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models); }
204  return m;
205  }
206 
207  void CDbOwnModelsComponent::clearView() { ui->tvp_OwnAircraftModels->clear(); }
208 
210  {
211  // void
212  }
213 
215  {
216  if (!m_modelLoader) { return; }
217  m_modelLoader->setCachedModels(models, simulator);
218  ui->tvp_OwnAircraftModels->replaceOrAddModelsWithString(models);
219  }
220 
222  const CSimulatorInfo &simulator)
223  {
224  if (!m_modelLoader) { return 0; }
225  const int c = m_modelLoader->updateModelsForSimulator(models, simulator);
226  const CAircraftModelList allModels(m_modelLoader->getCachedModels(simulator));
227  ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(allModels);
228  return c;
229  }
230 
231  bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode load)
232  {
233  // called when simulator is changed / init
234  Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
235 
236  // already loaded
237  if (!m_modelLoader || !m_modelLoader->supportsSimulator(simulator))
238  {
239  m_modelLoader = CMultiAircraftModelLoaderProvider::multiModelLoaderInstance().loaderInstance(simulator);
240  if (m_modelLoader) { m_modelLoader->startLoading(load); }
241  }
242  this->setSaveFileName(simulator);
243  return m_modelLoader && m_modelLoader->supportsSimulator(simulator);
244  }
245 
246  void CDbOwnModelsComponent::setSaveFileName(const CSimulatorInfo &sim)
247  {
248  Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
249  const QString n("simulator models " + sim.toQString(true));
250  ui->tvp_OwnAircraftModels->setSaveFileName(n);
251  }
252 
253  QString CDbOwnModelsComponent::directorySelector(const CSimulatorInfo &simulatorInfo)
254  {
255  QString dir = m_directorySettings.get().getLastModelDirectoryOrDefault();
256  dir = QFileDialog::getExistingDirectory(this,
257  QStringLiteral("Open directory (%1)").arg(simulatorInfo.toQString()),
258  dir, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
259  const QDir d(dir);
260  if (d.exists())
261  {
262  CDirectories dirs = m_directorySettings.get();
263  dirs.setLastModelDirectory(dir);
264  const CStatusMessage m = m_directorySettings.setAndSave(dirs);
265  CLogMessage::preformatted(m);
266  }
267  return dir;
268  }
269 
270  void CDbOwnModelsComponent::setUiSimulatorString(const CSimulatorInfo &simulatorInfo)
271  {
272  const QString s = simulatorInfo.toQString(true);
273  ui->le_Simulator->setText(s);
274  ui->pb_ForceReload->setText(QStringLiteral("force reload '%1'").arg(s));
275  }
276 
277  void CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator() { this->confirmedForcedReload(m_simulator); }
278 
279  void CDbOwnModelsComponent::confirmedForcedReload(const CSimulatorInfo &simulator)
280  {
281  QMessageBox msgBox(QMessageBox::Question, "Reload models from disk",
282  QStringLiteral("Completely reload '%1' models from disk?").arg(simulator.toQString(true)),
283  QMessageBox::Ok | QMessageBox::Cancel, this);
284  msgBox.setDefaultButton(QMessageBox::Cancel);
285  const QMessageBox::StandardButton reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
286  if (reply != QMessageBox::Ok) { return; }
287 
288  this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundNoCache);
289  }
290 
291  void CDbOwnModelsComponent::runScriptCSL2XSB()
292  {
293  static const QString script = QDir(CSwiftDirectories::shareDirectory()).filePath("CSL2XSB/CSL2XSB.exe");
294  for (const QString &modelDir : m_simulatorSettings.getModelDirectoriesOrDefault(CSimulatorInfo::xplane()))
295  {
296  CLogMessage(this).info(u"Running CSL2XSB on model directory %1") << modelDir;
297  CProcessCtrl::startDetached(script, { QDir::cleanPath(modelDir) }, true);
298  }
299  }
300 
301  void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
302  {
303  if (!sGui || sGui->isShuttingDown()) { return; }
304 
305  // for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
306  const CSimulatorInfo sims = CSimulatorInfo::allSimulators();
307  const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
308  if (!noSims)
309  {
310  QPointer<CDbOwnModelsComponent> ownModelsComp(qobject_cast<CDbOwnModelsComponent *>(this->parent()));
311  Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent");
312 
313  menuActions.addMenuSimulator();
314 
315  if (sims.isXPlane() && CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::buildWordSize() == 64)
316  {
317  if (!m_csl2xsbAction)
318  {
319  m_csl2xsbAction = new QAction(CIcons::appTerminal16(), "XPlane: run CSL2XSB on all models", this);
320  connect(m_csl2xsbAction, &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
321  if (!ownModelsComp) { return; }
322  Q_UNUSED(checked)
323  ownModelsComp->runScriptCSL2XSB();
324  });
325  }
326  menuActions.addAction(m_csl2xsbAction, CMenuAction::pathSimulator());
327  }
328  }
329  this->nestedCustomMenu(menuActions);
330  }
331 
332  void CDbOwnModelsComponent::requestOwnModelsUpdate()
333  {
334  if (!m_modelLoader) { return; }
335  ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->getOwnModels());
336  }
337 
338  void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator,
339  IAircraftModelLoader::LoadMode mode,
340  const QStringList &modelDirectories)
341  {
342  if (!m_modelLoader) { return; }
343 
344  // here m_modelLoader is still the "current" loader
345  if (m_modelLoader->isLoadingInProgress())
346  {
347  if (m_modelLoader->supportsSimulator(simulator))
348  {
349  const CStatusMessage msg =
350  CLogMessage(this).warning(u"Loading for '%1' already in progress, will NOT load.")
351  << simulator.toQString();
352  this->showOverlayMessage(msg);
353  return;
354  }
355  else
356  {
357  const CStatusMessage msg =
358  CLogMessage(this).warning(
359  u"Loading for another simulator '%1' already in progress. Loading might be slow.")
360  << simulator.toQString();
361  this->showOverlayMessage(msg);
362  }
363  }
364 
365  if (!this->initModelLoader(simulator))
366  {
367  const CStatusMessage msg = CLogMessage(this).error(u"Cannot init model loader for %1")
368  << simulator.toQString();
369  this->showOverlayMessage(msg);
370  return;
371  }
372 
373  // Do not check for empty models die here, as depending on mode we could still load
374  // will be checked in model loader
375  CLogMessage(this).info(u"Starting loading for '%1' in mode '%2'")
376  << simulator.toQString() << IAircraftModelLoader::enumToString(mode);
377  ui->tvp_OwnAircraftModels->showLoadIndicator();
378  Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services");
379  m_modelLoader->startLoading(
380  mode, static_cast<int (*)(CAircraftModelList &, bool)>(&CDatabaseUtils::consolidateModelsWithDbData),
381  modelDirectories);
382  }
383 
384  void CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted(const CSimulatorInfo &simulator,
385  IAircraftModelLoader::LoadMode mode)
386  {
387  using namespace std::chrono_literals;
388  const CStatusMessage msg = CLogMessage(this).info(u"Started disk loading for '%1' in mode '%2'")
389  << simulator.toQString(true) << IAircraftModelLoader::enumToString(mode);
390  this->showOverlayHTMLMessage(msg, 5s);
391  }
392 
393  void CDbOwnModelsComponent::onModelLoadingProgress(const CSimulatorInfo &simulator, const QString &message,
394  int progress)
395  {
396  using namespace std::chrono_literals;
397 
398  const CStatusMessage loadingMsg = CStatusMessage(this).info(u"%1 loading: %2")
399  << simulator.toQString(true) << message;
400  this->showOverlayHTMLMessage(loadingMsg, 5s);
401  ui->tvp_OwnAircraftModels->showLoadIndicatorWithTimeout(5s); // trigger new load indicator
402  Q_UNUSED(progress)
403  }
404 
405  void CDbOwnModelsComponent::onModelLoaderLoadingFinished(const CStatusMessageList &statusMessages,
406  const CSimulatorInfo &simulator,
408  {
409  using namespace std::chrono_literals;
410  Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
411 
412  bool hideIndicator = false; // hide in case loading failed
413  CStatusMessage summaryMsg;
414 
415  if (IAircraftModelLoader::isLoadedInfo(info) && m_modelLoader)
416  {
417  const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
418  const int modelsLoaded = models.size();
419  ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
420 
421  if (modelsLoaded < 1)
422  {
423  // loading ok, but no data
424  summaryMsg = CLogMessage(this).warning(u"Loading completed for simulator '%1', but no models")
425  << simulator;
426  hideIndicator = true;
427  }
428  else
429  {
430  summaryMsg = CLogMessage(this).info(u"Loading completed for simulator '%1' with %2 models")
431  << simulator << modelsLoaded;
432  }
433 
434  // overlay
435  if (!summaryMsg.isEmpty() && info == IAircraftModelLoader::ParsedData)
436  {
437  this->showOverlayHTMLMessage(summaryMsg, 5s);
438  }
439 
440  // signal
441  emit this->successfullyLoadedModels(simulator, modelsLoaded);
442  }
443  else if (info == IAircraftModelLoader::LoadingSkipped)
444  {
445  CLogMessage(this).error(u"Loading of models skipped, simulator '%1'") << simulator.toQString();
446  hideIndicator = true;
447  }
448  else
449  {
450  ui->tvp_OwnAircraftModels->clear();
451  hideIndicator = true;
452  CLogMessage(this).error(u"Loading of models failed, simulator '%1'") << simulator.toQString();
453  }
454 
455  // with errors we make sure errors are on top
456  if (statusMessages.hasErrorMessages())
457  {
458  this->setOverlayMessagesSorting(CStatusMessage::IndexSeverityAsIcon, Qt::DescendingOrder);
459  this->showOverlayMessagesOrHTMLMessage(statusMessages, false, 0s);
460  }
461  else
462  {
463  // no issues, directly hide
464  const std::chrono::milliseconds timeout { statusMessages.hasWarningOrErrorMessages() ? 0 : 7500 };
465  if (statusMessages.size() < 50)
466  {
467  // small number of messages
468  this->showOverlayMessagesOrHTMLMessage(statusMessages, false, timeout);
469  }
470  else
471  {
472  QPointer<CDbOwnModelsComponent> myself(this);
473  const QString confirmMessage =
474  QStringLiteral("Do you want to see the %1 detailled messages?").arg(statusMessages.size());
475  this->showOverlayMessagesWithConfirmation(summaryMsg, false, confirmMessage, [=] {
476  if (!myself) { return; }
477  myself->showOverlayMessagesOrHTMLMessage(statusMessages);
478  });
479  }
480  }
481 
482  if (hideIndicator) { ui->tvp_OwnAircraftModels->hideLoadIndicatorForced(); }
483 
484  // cache loads may occur in background, do not adjust UI settings
485  if (info == IAircraftModelLoader::CacheLoaded) { return; }
486 
487  // parsed loads normally explicit displaying this simulator
488  this->setSimulator(simulator);
489  }
490 
491  void CDbOwnModelsComponent::onViewDiskLoadingFinished(const CStatusMessage &status)
492  {
493  if (status.isFailure()) { return; }
494  QMessageBox msgBox(
495  QMessageBox::Question, "Loaded models from disk",
496  "Loaded models from disk file.\nSave to cache or just temporarily keep them?\n\nHint: Saving them will "
497  "override the loaded models from the simulator.\nNormally you would not want that (cancel).",
498  QMessageBox::Save | QMessageBox::Cancel, this);
499  msgBox.setDefaultButton(QMessageBox::Cancel);
500  const QMessageBox::StandardButton reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
501  if (reply != QMessageBox::Cancel) { return; }
502  const CAircraftModelList models = ui->tvp_OwnAircraftModels->container();
503  if (models.isEmpty()) { return; }
504  const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
505  m_modelLoader->setModelsForSimulator(models, simulator);
506  }
507 
508  void CDbOwnModelsComponent::onCacheChanged(const CSimulatorInfo &simulator)
509  {
510  const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
511  ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
512  }
513 
514  void CDbOwnModelsComponent::requestSimulatorModels(const CSimulatorInfo &simulator,
515  IAircraftModelLoader::LoadMode mode,
516  const QStringList &modelDirectories)
517  {
518  this->loadInstalledModels(simulator, mode, modelDirectories);
519  }
520 
521  void CDbOwnModelsComponent::requestSimulatorModelsWithCacheInBackground(const CSimulatorInfo &simulator)
522  {
523  this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
524  }
525 
526  void CDbOwnModelsComponent::clearSimulatorCache(const CSimulatorInfo &simulator)
527  {
528  if (!m_modelLoader) { return; }
529  m_modelLoader->clearCachedModels(simulator);
530  }
531 } // namespace swift::gui::components
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
bool showOverlayHTMLMessage(const QString &htmlMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
bool showOverlayMessage(const swift::misc::CStatusMessage &message, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show single message.
void showOverlayMessagesWithConfirmation(const swift::misc::CStatusMessageList &messages, bool appendOldMessages, const QString &confirmationMessage, std::function< void()> okLambda, QMessageBox::StandardButton defaultButton=QMessageBox::Cancel, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages with confirmation bar.
void setOverlayMessagesSorting(const swift::misc::CPropertyIndex &property, Qt::SortOrder order)
Set sorting of overlay messages.
void showOverlayMessagesOrHTMLMessage(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Show multiple messages or a single message (HTML)
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.
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.
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)
QString getInfoString() const
Info string about models in cache.
void changed(const swift::misc::simulation::CSimulatorInfo &simulator)
Value has been changed.
Bunch of CMenuAction objects.
Definition: menuaction.h:384
CMenuAction addMenuSimulator()
Simulator menu.
Definition: menuaction.cpp:428
CMenuAction addAction(const CMenuAction &menuAction)
Add menu action.
Definition: menuaction.cpp:210
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
Definition: valuecache.h:417
T get() const
Get a copy of the current value.
Definition: valuecache.h:408
Directories (swift data directories)
Definition: directories.h:25
void setLastModelDirectory(const QString &dir)
Last view JSON model directory.
Definition: directories.cpp:31
Class for emitting a log message.
Definition: logmessage.h:27
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
bool isEmpty() const
Message empty.
Derived & error(const char16_t(&format)[N])
Set the severity to error, providing a format string.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
size_type size() const
Returns number of elements in the sequence.
Definition: sequence.h:273
bool isEmpty() const
Synonym for empty.
Definition: sequence.h:285
Streamable status message, e.g.
bool isSuccess() const
Operation considered successful.
bool isFailure() const
Operation considered unsuccessful.
Status messages, e.g. from Core -> GUI.
bool hasWarningOrErrorMessages() const
Warning or error messages.
bool hasErrorMessages() const
Error messages.
QString toQString(bool i18n=false) const
Cast as QString.
Definition: mixinstring.h:76
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Value object encapsulating a list of aircraft models.
CAircraftModel findFirstByModelStringOrDefault(const QString &modelString, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive) const
Find first by model string.
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
bool isSingleSimulator() const
Single simulator selected.
bool isNoSimulator() const
No simulator?
bool isUnspecified() const
Unspecified simulator.
void startLoading(LoadMode mode=InBackgroundWithCache, const ModelConsolidationCallback &modelConsolidation={}, const QStringList &modelDirectories={})
Start the loading process from disk. Optional DB models can be passed and used for data consolidation...
bool supportsSimulator(const CSimulatorInfo &simulator) const
Supported simulator.
bool isLoadingInProgress() const
Loading in progress.
QString getInfoStringFsFamily() const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:590
CStatusMessage setCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:550
void setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
Definition: modelcaches.h:597
CStatusMessage clearCachedModels(const CSimulatorInfo &simulator)
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:554
QString getInfoString() const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:586
int updateModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
Set models.
Definition: modelcaches.h:603
CAircraftModelList getCachedModels(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:537
int getCachedModelsCount(const CSimulatorInfo &simulator) const
Look like IMultiSimulatorModelCaches interface.
Definition: modelcaches.h:541
QStringList getModelDirectoriesOrDefault(const CSimulatorInfo &simulator) const
Model directory or default model path per simulator.
QString getSimulatorDirectoryOrDefault(const CSimulatorInfo &simulator) const
Simulator directory or default model path per simulator.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Classes interacting with the swift database (aka "datastore").
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.