-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathdbownmodelscomponent.cpp
More file actions
547 lines (473 loc) · 23.8 KB
/
Copy pathdbownmodelscomponent.cpp
File metadata and controls
547 lines (473 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
#include "gui/components/dbownmodelscomponent.h"
#include <QAction>
#include <QDir>
#include <QFileDialog>
#include <QIcon>
#include <QMessageBox>
#include <QPointer>
#include <QtGlobal>
#include "ui_dbownmodelscomponent.h"
#include "config/buildconfig.h"
#include "core/db/databaseutils.h"
#include "core/webdataservices.h"
#include "gui/components/simulatorselector.h"
#include "gui/guiapplication.h"
#include "gui/menus/aircraftmodelmenus.h"
#include "gui/menus/menuaction.h"
#include "gui/models/aircraftmodellistmodel.h"
#include "gui/views/aircraftmodelview.h"
#include "misc/icons.h"
#include "misc/logmessage.h"
#include "misc/processctrl.h"
#include "misc/simulation/aircraftmodelloaderprovider.h"
#include "misc/statusmessage.h"
#include "misc/swiftdirectories.h"
using namespace swift::config;
using namespace swift::misc;
using namespace swift::misc::simulation;
using namespace swift::core::db;
using namespace swift::gui::menus;
using namespace swift::gui::views;
using namespace swift::gui::models;
namespace swift::gui::components
{
CDbOwnModelsComponent::CDbOwnModelsComponent(QWidget *parent)
: COverlayMessagesFrame(parent), ui(new Ui::CDbOwnModelsComponent)
{
ui->setupUi(this);
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
ui->tvp_OwnAircraftModels->setAircraftModelMode(CAircraftModelListModel::OwnAircraftModelMappingTool);
ui->tvp_OwnAircraftModels->addFilterDialog();
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
ui->tvp_OwnAircraftModels->setCustomMenu(new CLoadModelsMenu(this));
const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue();
ui->tvp_OwnAircraftModels->setCorrespondingSimulator(sim,
m_simulatorSettings.getSimulatorDirectoryOrDefault(sim));
bool c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::requestUpdate, this,
&CDbOwnModelsComponent::requestOwnModelsUpdate);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(ui->tvp_OwnAircraftModels, &CAircraftModelView::jsonLoadCompleted, this,
&CDbOwnModelsComponent::onViewDiskLoadingFinished, Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this,
&CDbOwnModelsComponent::onSimulatorSelectorChanged);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
&CMultiAircraftModelLoaderProvider::loadingFinished, this,
&CDbOwnModelsComponent::onModelLoaderLoadingFinished, Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
&CMultiAircraftModelLoaderProvider::diskLoadingStarted, this,
&CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted, Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
&CMultiAircraftModelLoaderProvider::loadingProgress, this,
&CDbOwnModelsComponent::onModelLoadingProgress, Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(&CMultiAircraftModelLoaderProvider::multiModelLoaderInstance(),
&CMultiAircraftModelLoaderProvider::cacheChanged, this, &CDbOwnModelsComponent::onCacheChanged,
Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
c = connect(ui->pb_ForceReload, &QPushButton::released, this,
&CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator, Qt::QueuedConnection);
Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed");
// Last selection isPinned -> no sync needed
ui->comp_SimulatorSelector->setRememberSelectionAndSetToLastSelection();
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
if (simulator.isSingleSimulator())
{
m_simulator = simulator;
this->setUiSimulatorString(simulator);
const bool success = this->initModelLoader(simulator, IAircraftModelLoader::CacheOnly);
if (!success) { CLogMessage(this).error(u"Init of model loader failed in component"); }
}
// menu
ui->tvp_OwnAircraftModels->setCustomMenu(new CConsolidateWithDbDataMenu(ui->tvp_OwnAircraftModels, this));
}
CDbOwnModelsComponent::~CDbOwnModelsComponent() = default;
const QStringList &CDbOwnModelsComponent::getLogCategories()
{
static const QStringList l({ CLogCategories::modelGui(), CLogCategories::guiComponent() });
return l;
}
CAircraftModelView *CDbOwnModelsComponent::view() const { return ui->tvp_OwnAircraftModels; }
CAircraftModelListModel *CDbOwnModelsComponent::model() const { return ui->tvp_OwnAircraftModels->derivedModel(); }
bool CDbOwnModelsComponent::requestModelsInBackground(const CSimulatorInfo &simulator, bool onlyIfNotEmpty)
{
this->setSimulator(simulator);
if (onlyIfNotEmpty && this->getOwnModelsCount() > 0) { return false; }
const IAircraftModelLoader::LoadMode mode =
onlyIfNotEmpty ? IAircraftModelLoader::InBackgroundNoCache : IAircraftModelLoader::LoadInBackground;
this->requestSimulatorModels(simulator, mode);
return true;
}
CAircraftModel CDbOwnModelsComponent::getOwnModelForModelString(const QString &modelString) const
{
return this->getOwnModels().findFirstByModelStringOrDefault(modelString);
}
CAircraftModelList CDbOwnModelsComponent::getOwnModels() const
{
return this->getOwnCachedModels(this->getOwnModelsSimulator());
}
CAircraftModelList CDbOwnModelsComponent::getOwnCachedModels(const CSimulatorInfo &simulator) const
{
static const CAircraftModelList empty;
if (!m_modelLoader) { return empty; }
return m_modelLoader->getCachedModels(simulator);
}
CAircraftModelList CDbOwnModelsComponent::getOwnSelectedModels() const
{
return ui->tvp_OwnAircraftModels->selectedObjects();
}
CSimulatorInfo CDbOwnModelsComponent::getOwnModelsSimulator() const
{
return ui->comp_SimulatorSelector->getValue();
}
bool CDbOwnModelsComponent::setSimulator(const CSimulatorInfo &simulator, bool forced)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const bool simUnchanged = (m_simulator == simulator);
if (!simUnchanged) { emit this->ownModelsSimulatorChanged(simulator); }
if (!forced && simUnchanged) { return false; }
// changed simulator
m_simulator = simulator;
this->requestSimulatorModelsWithCacheInBackground(simulator);
ui->comp_SimulatorSelector->setValue(simulator);
this->setUiSimulatorString(simulator);
ui->tvp_OwnAircraftModels->setCorrespondingSimulator(
simulator, m_simulatorSettings.getSimulatorDirectoryOrDefault(simulator));
return true;
}
void CDbOwnModelsComponent::setSimulatorSelectorMode(CSimulatorSelector::Mode mode)
{
ui->comp_SimulatorSelector->setMode(mode);
}
void CDbOwnModelsComponent::onSimulatorSelectorChanged()
{
const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue());
this->setSimulator(simulator);
}
int CDbOwnModelsComponent::getOwnModelsCount() const
{
if (!m_modelLoader) { return 0; }
return m_modelLoader->getCachedModelsCount(this->getOwnModelsSimulator());
}
QString CDbOwnModelsComponent::getInfoString() const
{
if (!m_modelLoader) { return {}; }
return m_modelLoader->getInfoString();
}
QString CDbOwnModelsComponent::getInfoStringFsFamily() const
{
if (!m_modelLoader) { return {}; }
return m_modelLoader->getInfoStringFsFamily();
}
CStatusMessage CDbOwnModelsComponent::updateViewAndCache(const CAircraftModelList &models)
{
const CStatusMessage m = m_modelLoader->setCachedModels(models, this->getOwnModelsSimulator());
if (m.isSuccess()) { ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models); }
return m;
}
void CDbOwnModelsComponent::clearView() { ui->tvp_OwnAircraftModels->clear(); }
void CDbOwnModelsComponent::gracefulShutdown()
{
// void
}
void CDbOwnModelsComponent::setModelsForSimulator(const CAircraftModelList &models, const CSimulatorInfo &simulator)
{
if (!m_modelLoader) { return; }
m_modelLoader->setCachedModels(models, simulator);
ui->tvp_OwnAircraftModels->replaceOrAddModelsWithString(models);
}
int CDbOwnModelsComponent::updateModelsForSimulator(const CAircraftModelList &models,
const CSimulatorInfo &simulator)
{
if (!m_modelLoader) { return 0; }
const int c = m_modelLoader->updateModelsForSimulator(models, simulator);
const CAircraftModelList allModels(m_modelLoader->getCachedModels(simulator));
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(allModels);
return c;
}
bool CDbOwnModelsComponent::initModelLoader(const CSimulatorInfo &simulator, IAircraftModelLoader::LoadMode load)
{
// called when simulator is changed / init
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
// already loaded
if (!m_modelLoader || !m_modelLoader->supportsSimulator(simulator))
{
m_modelLoader = CMultiAircraftModelLoaderProvider::multiModelLoaderInstance().loaderInstance(simulator);
if (m_modelLoader) { m_modelLoader->startLoading(load); }
}
this->setSaveFileName(simulator);
return m_modelLoader && m_modelLoader->supportsSimulator(simulator);
}
void CDbOwnModelsComponent::setSaveFileName(const CSimulatorInfo &sim)
{
Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
const QString n("simulator models " + sim.toQString(true));
ui->tvp_OwnAircraftModels->setSaveFileName(n);
}
QString CDbOwnModelsComponent::directorySelector(const CSimulatorInfo &simulatorInfo)
{
QString dir = m_directorySettings.get().getLastModelDirectoryOrDefault();
dir = QFileDialog::getExistingDirectory(this,
QStringLiteral("Open directory (%1)").arg(simulatorInfo.toQString()),
dir, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
const QDir d(dir);
if (d.exists())
{
CDirectories dirs = m_directorySettings.get();
dirs.setLastModelDirectory(dir);
const CStatusMessage m = m_directorySettings.setAndSave(dirs);
CLogMessage::preformatted(m);
}
return dir;
}
void CDbOwnModelsComponent::setUiSimulatorString(const CSimulatorInfo &simulatorInfo)
{
const QString s = simulatorInfo.toQString(true);
ui->le_Simulator->setText(s);
ui->pb_ForceReload->setText(QStringLiteral("force reload '%1'").arg(s));
}
void CDbOwnModelsComponent::confirmedForcedReloadCurrentSimulator() { this->confirmedForcedReload(m_simulator); }
void CDbOwnModelsComponent::confirmedForcedReload(const CSimulatorInfo &simulator)
{
QMessageBox msgBox(QMessageBox::Question, "Reload models from disk",
QStringLiteral("Completely reload '%1' models from disk?").arg(simulator.toQString(true)),
QMessageBox::Yes | QMessageBox::No, this);
msgBox.setDefaultButton(QMessageBox::Cancel);
const auto reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
if (reply != QMessageBox::Yes) { return; }
this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundNoCache);
}
void CDbOwnModelsComponent::runScriptCSL2XSB()
{
static const QString script = QDir(CSwiftDirectories::shareDirectory()).filePath("CSL2XSB/CSL2XSB.exe");
for (const QString &modelDir : m_simulatorSettings.getModelDirectoriesOrDefault(CSimulatorInfo::xplane()))
{
CLogMessage(this).info(u"Running CSL2XSB on model directory %1") << modelDir;
CProcessCtrl::startDetached(script, { QDir::cleanPath(modelDir) }, true);
}
}
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
{
if (!sGui || sGui->isShuttingDown()) { return; }
// for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
const CSimulatorInfo sims = CSimulatorInfo::allSimulators();
const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
if (!noSims)
{
QPointer<CDbOwnModelsComponent> ownModelsComp(qobject_cast<CDbOwnModelsComponent *>(this->parent()));
Q_ASSERT_X(ownModelsComp, Q_FUNC_INFO, "Cannot access parent");
menuActions.addMenuSimulator();
if (sims.isXPlane() && CBuildConfig::isRunningOnWindowsNtPlatform() && CBuildConfig::buildWordSize() == 64)
{
if (!m_csl2xsbAction)
{
m_csl2xsbAction = new QAction(CIcons::appTerminal16(), "XPlane: run CSL2XSB on all models", this);
connect(m_csl2xsbAction, &QAction::triggered, ownModelsComp, [ownModelsComp](bool checked) {
if (!ownModelsComp) { return; }
Q_UNUSED(checked)
ownModelsComp->runScriptCSL2XSB();
});
}
menuActions.addAction(m_csl2xsbAction, CMenuAction::pathSimulator());
}
}
this->nestedCustomMenu(menuActions);
}
void CDbOwnModelsComponent::requestOwnModelsUpdate()
{
if (!m_modelLoader) { return; }
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->getOwnModels());
}
// TODO TZ this is a stub for SimConnect loading
void CDbOwnModelsComponent::loadInstalledModelsSimConnect(const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
{
Q_UNUSED(mode);
Q_UNUSED(modelDirectories);
using namespace std::chrono_literals;
const CStatusMessage msg = CLogMessage(this).info(u"Triiger loading models for %1 from SimConnect")
<< simulator.toQString();
this->showOverlayHTMLMessage(msg, 2s);
return;
}
void CDbOwnModelsComponent::loadInstalledModels(const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
{
if (!m_modelLoader) { return; }
// here m_modelLoader is still the "current" loader
if (m_modelLoader->isLoadingInProgress())
{
if (m_modelLoader->supportsSimulator(simulator))
{
const CStatusMessage msg =
CLogMessage(this).warning(u"Loading for '%1' already in progress, will NOT load.")
<< simulator.toQString();
this->showOverlayMessage(msg);
return;
}
else
{
const CStatusMessage msg =
CLogMessage(this).warning(
u"Loading for another simulator '%1' already in progress. Loading might be slow.")
<< simulator.toQString();
this->showOverlayMessage(msg);
}
}
if (!this->initModelLoader(simulator))
{
const CStatusMessage msg = CLogMessage(this).error(u"Cannot init model loader for %1")
<< simulator.toQString();
this->showOverlayMessage(msg);
return;
}
// Do not check for empty models die here, as depending on mode we could still load
// will be checked in model loader
CLogMessage(this).info(u"Starting loading for '%1' in mode '%2'")
<< simulator.toQString() << IAircraftModelLoader::enumToString(mode);
ui->tvp_OwnAircraftModels->showLoadIndicator();
Q_ASSERT_X(sGui && sGui->getWebDataServices(), Q_FUNC_INFO, "missing web data services");
m_modelLoader->startLoading(
mode, static_cast<int (*)(CAircraftModelList &, bool)>(&CDatabaseUtils::consolidateModelsWithDbData),
modelDirectories);
}
void CDbOwnModelsComponent::onModelLoaderDiskLoadingStarted(const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadMode mode)
{
using namespace std::chrono_literals;
const CStatusMessage msg = CLogMessage(this).info(u"Started disk loading for '%1' in mode '%2'")
<< simulator.toQString(true) << IAircraftModelLoader::enumToString(mode);
this->showOverlayHTMLMessage(msg, 5s);
}
void CDbOwnModelsComponent::onModelLoadingProgress(const CSimulatorInfo &simulator, const QString &message,
int progress)
{
using namespace std::chrono_literals;
const CStatusMessage loadingMsg = CStatusMessage(this).info(u"%1 loading: %2")
<< simulator.toQString(true) << message;
this->showOverlayHTMLMessage(loadingMsg, 5s);
ui->tvp_OwnAircraftModels->showLoadIndicatorWithTimeout(5s); // trigger new load indicator
Q_UNUSED(progress)
}
void CDbOwnModelsComponent::onModelLoaderLoadingFinished(const CStatusMessageList &statusMessages,
const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadFinishedInfo info)
{
using namespace std::chrono_literals;
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Expect single simulator");
bool hideIndicator = false; // hide in case loading failed
CStatusMessage summaryMsg;
if (IAircraftModelLoader::isLoadedInfo(info) && m_modelLoader)
{
const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
const int modelsLoaded = models.size();
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
if (modelsLoaded < 1)
{
// loading ok, but no data
summaryMsg = CLogMessage(this).warning(u"Loading completed for simulator '%1', but no models")
<< simulator;
hideIndicator = true;
}
else
{
summaryMsg = CLogMessage(this).info(u"Loading completed for simulator '%1' with %2 models")
<< simulator << modelsLoaded;
}
// overlay
if (!summaryMsg.isEmpty() && info == IAircraftModelLoader::ParsedData)
{
this->showOverlayHTMLMessage(summaryMsg, 5s);
}
// signal
emit this->successfullyLoadedModels(simulator, modelsLoaded);
}
else if (info == IAircraftModelLoader::LoadingSkipped)
{
CLogMessage(this).error(u"Loading of models skipped, simulator '%1'") << simulator.toQString();
hideIndicator = true;
}
else
{
ui->tvp_OwnAircraftModels->clear();
hideIndicator = true;
CLogMessage(this).error(u"Loading of models failed, simulator '%1'") << simulator.toQString();
}
// with errors we make sure errors are on top
if (statusMessages.hasErrorMessages())
{
this->setOverlayMessagesSorting(CStatusMessage::IndexSeverityAsIcon, Qt::DescendingOrder);
this->showOverlayMessagesOrHTMLMessage(statusMessages, false, 0s);
}
else
{
// no issues, directly hide
const std::chrono::milliseconds timeout { statusMessages.hasWarningOrErrorMessages() ? 0 : 7500 };
if (statusMessages.size() < 50)
{
// small number of messages
this->showOverlayMessagesOrHTMLMessage(statusMessages, false, timeout);
}
else
{
QPointer<CDbOwnModelsComponent> myself(this);
const QString confirmMessage =
QStringLiteral("Do you want to see the %1 detailled messages?").arg(statusMessages.size());
this->showOverlayMessagesWithConfirmation(summaryMsg, false, confirmMessage, [=] {
if (!myself) { return; }
myself->showOverlayMessagesOrHTMLMessage(statusMessages);
});
}
}
if (hideIndicator) { ui->tvp_OwnAircraftModels->hideLoadIndicatorForced(); }
// cache loads may occur in background, do not adjust UI settings
if (info == IAircraftModelLoader::CacheLoaded) { return; }
// parsed loads normally explicit displaying this simulator
this->setSimulator(simulator);
}
void CDbOwnModelsComponent::onViewDiskLoadingFinished(const CStatusMessage &status)
{
if (status.isFailure()) { return; }
QMessageBox msgBox(
QMessageBox::Question, "Loaded models from disk",
"Loaded models from disk file.\nSave to cache or just temporarily keep them?\n\nHint: Saving them will "
"override the loaded models from the simulator.\nNormally you would not want that (cancel).",
QMessageBox::Save | QMessageBox::Cancel, this);
msgBox.setDefaultButton(QMessageBox::Cancel);
const auto reply = static_cast<QMessageBox::StandardButton>(msgBox.exec());
if (reply != QMessageBox::Cancel) { return; }
const CAircraftModelList models = ui->tvp_OwnAircraftModels->container();
if (models.isEmpty()) { return; }
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
m_modelLoader->setModelsForSimulator(models, simulator);
}
void CDbOwnModelsComponent::onCacheChanged(const CSimulatorInfo &simulator)
{
const CAircraftModelList models(m_modelLoader->getCachedModels(simulator));
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(models);
}
void CDbOwnModelsComponent::requestSimulatorModels(const CSimulatorInfo &simulator,
IAircraftModelLoader::LoadMode mode,
const QStringList &modelDirectories)
{
// TODO TZ add SimConnect loading
if (simulator.isMSFS2024()) this->loadInstalledModelsSimConnect(simulator, mode, modelDirectories);
this->loadInstalledModels(simulator, mode, modelDirectories);
}
void CDbOwnModelsComponent::requestSimulatorModelsWithCacheInBackground(const CSimulatorInfo &simulator)
{
this->requestSimulatorModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
}
void CDbOwnModelsComponent::clearSimulatorCache(const CSimulatorInfo &simulator)
{
if (!m_modelLoader) { return; }
m_modelLoader->clearCachedModels(simulator);
}
} // namespace swift::gui::components