swift
Loading...
Searching...
No Matches
dbmappingcomponent.cpp
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#include <QAction>
7#include <QDialog>
8#include <QFileDialog>
9#include <QFrame>
10#include <QMenu>
11#include <QModelIndex>
12#include <QPoint>
13#include <QShortcut>
14#include <QSplitter>
15#include <QTabWidget>
16#include <QVariant>
17#include <QWidget>
18#include <Qt>
19#include <QtGlobal>
20
21#include "ui_dbmappingcomponent.h"
22
35#include "gui/guiapplication.h"
36#include "gui/guiutility.h"
37#include "gui/menus/aircraftmodelmenus.h"
38#include "gui/menus/menuaction.h"
40#include "gui/shortcut.h"
42#include "gui/views/viewbase.h"
45#include "misc/icons.h"
46#include "misc/logmessage.h"
51
52using namespace swift::core;
53using namespace swift::misc;
54using namespace swift::misc::aviation;
55using namespace swift::misc::network;
56using namespace swift::misc::simulation;
57using namespace swift::misc::simulation::fscommon;
58using namespace swift::gui;
59using namespace swift::gui::editors;
60using namespace swift::gui::views;
61using namespace swift::gui::models;
62using namespace swift::gui::menus;
63
65{
68 m_autoStashDialog(new CDbAutoStashingComponent(this)),
69 m_autoSimulatorDialog(new CDbAutoSimulatorStashingComponent(this)),
70 m_modelModifyDialog(new CDbModelMappingModifyDialog(this))
71 {
72 ui->setupUi(this);
73 ui->comp_StashAircraft->setMappingComponent(this);
74 ui->comp_OwnModelSet->setMappingComponent(this);
75
77 ui->tvp_AircraftModelsForVPilot->setAircraftModelMode(CAircraftModelListModel::VPilotRuleModel);
78 ui->tvp_AircraftModelsForVPilot->addFilterDialog();
79
80 // model menus
81 ui->comp_OwnAircraftModels->view()->setCustomMenu(
82 new CShowSimulatorFileMenu(ui->comp_OwnAircraftModels->view(), this));
83 ui->comp_OwnAircraftModels->view()->setCustomMenu(new CMergeWithVPilotMenu(this));
84 ui->comp_OwnAircraftModels->view()->setCustomMenu(new COwnModelSetMenu(this));
85 ui->comp_OwnAircraftModels->view()->setCustomMenu(new CStashToolsMenu(this));
86
87 ui->comp_OwnModelSet->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_OwnModelSet->view(), this));
88 ui->comp_OwnModelSet->view()->setCustomMenu(new CStashToolsMenu(this));
89
90 ui->comp_StashAircraft->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_StashAircraft->view(), this));
91 ui->comp_StashAircraft->view()->setCustomMenu(new CApplyDbDataMenu(this));
92 ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this));
93 ui->comp_StashAircraft->view()->setCustomMenu(new CStashToolsMenu(this));
94
95 ui->comp_ModelWorkbench->view()->menuAddItems(CAircraftModelView::MenuClear |
97 ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this));
98 ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this));
99 ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this));
100 ui->comp_ModelWorkbench->view()->setCustomMenu(new CRemovedModelsMenu(this));
101
102 // connects
103 connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this,
104 &CDbMappingComponent::stashCurrentModel);
105
106 connect(ui->comp_OwnAircraftModels, &CDbOwnModelsComponent::ownModelsSimulatorChanged, this,
107 &CDbMappingComponent::onOwnModelsSimulatorChanged, Qt::QueuedConnection);
108 connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::doubleClicked, this,
109 &CDbMappingComponent::onModelRowSelected);
110 connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::modelDataChangedDigest, this,
111 &CDbMappingComponent::onOwnModelsChangedDigest, Qt::QueuedConnection);
112 connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::requestStash, this,
114 connect(ui->comp_OwnAircraftModels->view(), &CAircraftModelView::toggledHighlightStashedModels, this,
115 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
116
117 connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::doubleClicked, this,
118 &CDbMappingComponent::onModelRowSelected);
119 connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::modelDataChangedDigest, this,
120 &CDbMappingComponent::onWorkbenchDataChanged, Qt::QueuedConnection);
121 connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::requestStash, this,
123 connect(ui->comp_ModelWorkbench->view(), &CAircraftModelView::toggledHighlightStashedModels, this,
124 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
125
126 connect(ui->comp_StashAircraft->view(), &CAircraftModelView::modelDataChangedDigest, this,
127 &CDbMappingComponent::onStashedModelsDataChangedDigest);
128 connect(ui->comp_StashAircraft->view(), &CAircraftModelView::doubleClicked, this,
129 &CDbMappingComponent::onModelRowSelected);
130 connect(ui->comp_StashAircraft->view(), &CAircraftModelView::requestHandlingOfStashDrop, this,
131 &CDbMappingComponent::handleStashDropRequest);
132 connect(ui->comp_StashAircraft, &CDbStashComponent::stashedModelsChanged, this,
133 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
134 connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this,
135 &CDbMappingComponent::onModelsSuccessfullyPublished, Qt::QueuedConnection);
136
137 connect(ui->comp_OwnModelSet->view(), &CAircraftModelView::modelDataChangedDigest, this,
138 &CDbMappingComponent::onModelSetChangedDigest, Qt::QueuedConnection);
139 connect(ui->comp_OwnModelSet->view(), &CAircraftModelView::requestStash, this,
141
142 connect(ui->tw_ModelsToBeMapped, &QTabWidget::currentChanged, this, &CDbMappingComponent::onTabIndexChanged);
143 connect(ui->tw_ModelsToBeMapped, &QTabWidget::currentChanged, ui->comp_ModelMatcher,
145
146 connect(ui->comp_OwnModelSet->view(), &CAircraftModelView::doubleClicked, this,
147 &CDbMappingComponent::onModelRowSelected);
148
149 // initial values
150 this->onModelSetChangedDigest(ui->comp_OwnModelSet->view()->rowCount(),
151 ui->comp_OwnModelSet->view()->hasFilter());
152 this->onStashedModelsDataChangedDigest(ui->comp_StashAircraft->view()->rowCount(),
153 ui->comp_StashAircraft->view()->hasFilter());
154 this->onOwnModelsChangedDigest(ui->comp_OwnAircraftModels->view()->rowCount(),
155 ui->comp_OwnAircraftModels->view()->hasFilter());
156
157 // allow to use workbench data
158 ui->comp_ModelMatcher->setWorkbenchView(ui->comp_ModelWorkbench->view());
159
160 // how to display forms
161 ui->editor_AircraftModel->setSelectOnly();
162
163 ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
164 ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
165 ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModelSet, CIcons::appModels16());
166 ui->tw_ModelsToBeMapped->setTabIcon(TabWorkbench, CIcons::wrench16());
167
168 // custom menu and shortcut
171 &CDbMappingComponent::onCustomContextMenu);
172 new QShortcut(CShortcut::keyAddToModelSet(), this, SLOT(ps_addToOwnModelSet()));
173
174 // vPilot
175 this->initVPilotLoading();
176 }
177
179
180 void CDbMappingComponent::initVPilotLoading()
181 {
182 m_vPilotEnabled = this->vPilotSupport && m_swiftDbUser.get().hasAdminRole();
183 static const QString tabName(ui->tw_ModelsToBeMapped->tabText(TabVPilot));
184
185 if (m_vPilot1stInit && vPilotSupport)
186 {
187 m_vPilot1stInit = false;
188 connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::doubleClicked, this,
189 &CDbMappingComponent::onModelRowSelected);
190 connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::modelDataChanged, this,
191 &CDbMappingComponent::onVPilotDataChanged);
192 connect(&m_vPilotReader, &CVPilotRulesReader::readFinished, this,
193 &CDbMappingComponent::onLoadVPilotDataFinished);
194 connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestStash, this,
196 connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::toggledHighlightStashedModels, this,
197 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
198 connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestUpdate, this,
199 &CDbMappingComponent::requestVPilotDataUpdate);
200
201 ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this));
202 ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CStashToolsMenu(this));
203 ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true);
204
205 ui->tvp_AircraftModelsForVPilot->addFilterDialog();
206 const CAircraftModelList vPilotModels(m_vPilotReader.getAsModelsFromCache());
207 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(vPilotModels);
208 const int noModels = vPilotModels.size();
209 CLogMessage(this).info(u"%1 cached vPilot models loaded") << noModels;
210 }
211 ui->tab_VPilot->setEnabled(m_vPilotEnabled);
212 ui->tab_VPilot->setVisible(m_vPilotEnabled);
213 if (m_vPilotEnabled)
214 {
215 // create / restore tab
216 ui->tw_ModelsToBeMapped->addTab(ui->tab_VPilot, tabName);
217 this->onVPilotDataChanged(ui->tvp_AircraftModelsForVPilot->rowCount(),
218 ui->tvp_AircraftModelsForVPilot->hasFilter());
219 }
220 else
221 {
222 m_vPilotFormatted = false;
223 ui->tw_ModelsToBeMapped->removeTab(TabVPilot);
224 }
225 }
226
227 void CDbMappingComponent::formatVPilotView()
228 {
229 if (!m_vPilotEnabled || m_vPilotFormatted)
230 {
231 return;
232 }
233 m_vPilotFormatted = true;
234 ui->tvp_AircraftModelsForVPilot->presizeOrFullResizeToContents();
235 }
236
237 CAircraftModel CDbMappingComponent::getModelFromView(const QModelIndex &index) const
238 {
239 if (!index.isValid())
240 {
241 return {};
242 }
243 const QObject *sender = QObject::sender();
244
245 // check if we have an explicit sender
246 if (sender == ui->tvp_AircraftModelsForVPilot)
247 {
248 return ui->tvp_AircraftModelsForVPilot->at(index);
249 }
250 if (sender == ui->comp_OwnAircraftModels->view())
251 {
252 return ui->comp_OwnAircraftModels->view()->at(index);
253 }
254 if (sender == ui->comp_StashAircraft || sender == ui->comp_StashAircraft->view())
255 {
256 return ui->comp_StashAircraft->view()->at(index);
257 }
258 if (sender == ui->comp_OwnModelSet->view())
259 {
260 return ui->comp_OwnModelSet->view()->at(index);
261 }
262
263 // no sender, use current tab
264 const CAircraftModelView *mv = this->currentModelView();
265 if (!mv)
266 {
267 return {};
268 }
269 return mv->at(index);
270 }
271
273 {
274 this->disconnect();
275 m_vPilotReader.gracefulShutdown();
276 ui->comp_OwnAircraftModels->gracefulShutdown();
277 }
278
280 {
281 const CAircraftModelView *mv = this->currentModelView();
282 if (!mv)
283 {
284 return false;
285 }
286 return mv->hasSelectedModelsToStash();
287 }
288
290 {
291 const TabIndex tab = currentTabIndex();
292 return this->modelView(tab);
293 }
294
296 {
297 switch (tab)
298 {
299 case TabOwnModels: return ui->comp_OwnAircraftModels->view();
300 case TabVPilot: return ui->tvp_AircraftModelsForVPilot;
301 case TabWorkbench: return ui->comp_ModelWorkbench->view();
302 case TabStash: return ui->comp_StashAircraft->view();
303 case TabOwnModelSet: return ui->comp_OwnModelSet->view();
304 default: return nullptr;
305 }
306 }
307
308 QString CDbMappingComponent::currentTabText() const
309 {
310 const int i = ui->tw_ModelsToBeMapped->currentIndex();
311 return ui->tw_ModelsToBeMapped->tabText(i);
312 }
313
314 void CDbMappingComponent::updateEditorsWhenApplicable()
315 {
316 const CAircraftModel currentEditorModel(ui->editor_ModelMapping->getValue());
317 if (!currentEditorModel.hasModelString())
318 {
319 return;
320 } // no related model
321 const QString modelString(currentEditorModel.getModelString());
322 const CAircraftModel currentStashedModel(ui->comp_StashAircraft->getStashedModel(modelString));
323 if (!currentStashedModel.hasModelString())
324 {
325 return;
326 }
327
328 // we have found a model in the stashed models and this is the one currently displayed
329 // in the editors
330 bool updated = false;
331 const CLivery stashedLivery(currentStashedModel.getLivery());
332 if (stashedLivery.hasValidDbKey())
333 {
334 if (ui->editor_AircraftModel->setLivery(stashedLivery))
335 {
336 updated = true;
337 }
338 }
339
340 const CDistributor stashedDistributor(currentStashedModel.getDistributor());
341 if (stashedDistributor.hasValidDbKey())
342 {
343 if (ui->editor_AircraftModel->setDistributor(stashedDistributor))
344 {
345 updated = true;
346 }
347 }
348
349 const CAircraftIcaoCode stashedIcaoCode(currentStashedModel.getAircraftIcaoCode());
350 if (stashedIcaoCode.hasValidDbKey())
351 {
352 if (ui->editor_AircraftModel->setAircraftIcao(stashedIcaoCode))
353 {
354 updated = true;
355 }
356 }
357
358 if (updated)
359 {
360 CLogMessage(this).info(u"Updated editor data for '%1'") << modelString;
361 }
362 }
363
365 {
366 const CAircraftModelView *mv = this->currentModelView();
367 if (!mv || !mv->hasSelectedModelsToStash())
368 {
369 return {};
370 }
371 return mv->selectedObjects();
372 }
373
375 {
376 return ui->comp_StashAircraft->getStashedModels();
377 }
378
380
382 {
383 return ui->comp_StashAircraft->getStashedModelStrings();
384 }
385
387 {
388 if (!ui->tw_ModelsToBeMapped)
389 {
390 return CDbMappingComponent::NoValidTab;
391 }
392 const int t = ui->tw_ModelsToBeMapped->currentIndex();
393 return static_cast<TabIndex>(t);
394 }
395
396 bool CDbMappingComponent::isStashTab() const { return this->currentTabIndex() == TabStash; }
397
398 bool CDbMappingComponent::isWorkbenchTab() const { return this->currentTabIndex() == TabWorkbench; }
399
401 {
402 const bool allowed = this->currentTabIndex() == CDbMappingComponent::TabOwnModels ||
403 this->currentTabIndex() == CDbMappingComponent::TabStash;
404 return allowed && this->currentModelView()->hasSelection();
405 }
406
408 {
410 if (withNestedForms)
411 {
412 // tests the 3 subforms and the model itself lenient
413 msgs.push_back(ui->editor_ModelMapping->validate(false));
414 msgs.push_back(ui->editor_AircraftModel->validate(true));
415 }
416 else
417 {
418 // model lenient
419 msgs.push_back(ui->editor_ModelMapping->validate(false));
420 }
421 return msgs;
422 }
423
424 void CDbMappingComponent::handleStashDropRequest(const CAirlineIcaoCode &code) const
425 {
426 const CLivery stdLivery(sGui->getWebDataServices()->getStdLiveryForAirlineCode(code));
427 if (!stdLivery.hasValidDbKey())
428 {
429 return;
430 }
431 ui->comp_StashAircraft->applyToSelected(stdLivery);
432 }
433
434 void CDbMappingComponent::stashCurrentModel()
435 {
436 const bool nested = this->isStashTab(); // on stash tab, full validation, otherwise not
437 CStatusMessageList msgs(this->validateCurrentModel(nested));
438 if (!msgs.hasErrorMessages())
439 {
440 const CAircraftModel editorModel(getEditorAircraftModel());
441
442 // from stash, do not consolidate, because we want to keep data as they are from the editor
443 const bool consolidate = !this->isStashTab();
444 msgs.push_back(ui->comp_StashAircraft->stashModel(editorModel, true, consolidate));
445 }
446 if (msgs.hasErrorMessages())
447 {
449 }
450 }
451
452 void CDbMappingComponent::displayAutoStashingDialog() { m_autoStashDialog->exec(); }
453
454 void CDbMappingComponent::displayAutoSimulatorStashingDialog() { m_autoSimulatorDialog->exec(); }
455
456 void CDbMappingComponent::removeDbModelsFromView()
457 {
458 const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings());
459 if (modelStrings.isEmpty())
460 {
461 return;
462 }
463 CAircraftModelView *mv = this->currentModelView();
464 if (mv)
465 {
466 mv->removeModelsWithModelString(modelStrings);
467 }
468 }
469
470 void CDbMappingComponent::showChangedAttributes()
471 {
472 if (!this->hasStashedModels())
473 {
474 return;
475 }
476 if (this->currentTabIndex() != TabStash)
477 {
478 return;
479 }
480 ui->comp_StashAircraft->showChangedAttributes();
481 }
482
483 void CDbMappingComponent::toggleAutoFiltering() { m_autoFilterInDbViews = !m_autoFilterInDbViews; }
484
485 void CDbMappingComponent::applyFormLiveryData()
486 {
487 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
488 {
489 return;
490 }
491 const CStatusMessageList msgs = ui->editor_AircraftModel->validateLivery(true);
492 if (msgs.hasErrorMessages())
493 {
495 }
496 else
497 {
498 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getLivery());
499 }
500 }
501
502 void CDbMappingComponent::applyFormAircraftIcaoData()
503 {
504 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
505 {
506 return;
507 }
508 const CStatusMessageList msgs = ui->editor_AircraftModel->validateAircraftIcao(true);
509 if (msgs.hasErrorMessages())
510 {
512 }
513 else
514 {
515 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getAircraftIcao());
516 }
517 }
518
519 void CDbMappingComponent::applyFormDistributorData()
520 {
521 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
522 {
523 return;
524 }
525 const CStatusMessageList msgs = ui->editor_AircraftModel->validateDistributor(true);
526 if (msgs.hasErrorMessages())
527 {
529 }
530 else
531 {
532 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getDistributor());
533 }
534 }
535
537 {
538 // only one model selected, use as default
539 if (ui->comp_StashAircraft->view()->hasSingleSelectedRow())
540 {
541 m_modelModifyDialog->setValue(ui->comp_StashAircraft->view()->selectedObject());
542 }
543
544 const auto s = static_cast<QDialog::DialogCode>(m_modelModifyDialog->exec());
545 if (s == QDialog::Rejected)
546 {
547 return;
548 }
549 const CPropertyIndexVariantMap vm = m_modelModifyDialog->getValues();
550 ui->comp_StashAircraft->applyToSelected(vm);
551 }
552
554
556 {
557 const int h = this->height(); // total height
558 int h2 = ui->qw_EditorsScrollArea->minimumHeight();
559 h2 = qRound(h2 * 1.10); // desired height of inner widget + some space for scrollarea
560 int currentSize = ui->sp_MappingComponent->sizes().last(); // current size
561 if (h2 <= currentSize)
562 {
563 return;
564 }
565
566 int h1 {};
567 if (h * 0.90 > h2)
568 {
569 // enough space to display as whole
570 h1 = h - h2;
571 }
572 else
573 {
574 h1 = h / 3;
575 h2 = h / 3 * 2;
576 }
577 const QList<int> sizes({ h1, h2 });
578 ui->sp_MappingComponent->setSizes(sizes);
579 }
580
582 {
583 const int h = this->height();
584 const int h1 = h;
585 const int h2 = 0;
586 const QList<int> sizes({ h1, h2 });
587 ui->sp_MappingComponent->setSizes(sizes);
588 }
589
590 void CDbMappingComponent::loadVPilotData()
591 {
592 if (m_vPilotReader.readInBackground(true))
593 {
594 CLogMessage(this).info(u"Start loading vPilot rulesets");
595 ui->tvp_AircraftModelsForVPilot->showLoadIndicator();
596 }
597 else
598 {
599 CLogMessage(this).warning(u"Loading vPilot rulesets already in progress");
600 }
601 }
602
603 void CDbMappingComponent::onLoadVPilotDataFinished(bool success)
604 {
605 if (!m_vPilotEnabled)
606 {
607 return;
608 }
609 if (success)
610 {
611 CLogMessage(this).info(u"Loading vPilot ruleset completed");
612 const CAircraftModelList models(m_vPilotReader.getAsModels());
613 if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
614 {
615 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(models);
616 }
617 }
618 else
619 {
620 CLogMessage(this).error(u"Loading vPilot ruleset failed");
621 }
622 ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
623 }
624
625 void CDbMappingComponent::loadRemovedModels()
626 {
627 if (!ui->comp_ModelWorkbench->view())
628 {
629 return;
630 }
631 const QString logDir = CSwiftDirectories::logDirectory();
632 ui->comp_ModelWorkbench->view()->showFileLoadDialog(logDir);
633 }
634
635 void CDbMappingComponent::onVPilotCacheChanged()
636 {
637 if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
638 {
639 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(m_vPilotReader.getAsModelsFromCache());
640 }
641 else
642 {
643 ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
644 }
645 }
646
647 void CDbMappingComponent::requestVPilotDataUpdate() { this->onVPilotCacheChanged(); }
648
649 void CDbMappingComponent::onStashedModelsChangedTriggerDigest()
650 {
651 m_dsStashedModelsChanged.inputSignal(); // will call onStashedModelsChangedDigest
652 }
653
654 void CDbMappingComponent::onStashedModelsChangedDigest()
655 {
656 const bool highlightVPilot = ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModels();
657 const bool highlightOwnModels = ui->comp_OwnAircraftModels->view()->derivedModel()->highlightModels();
658 const bool highlightModelSet = ui->comp_OwnModelSet->view()->derivedModel()->highlightModels();
659 const bool highlight = highlightOwnModels || highlightModelSet || highlightVPilot;
660 if (!highlight)
661 {
662 return;
663 }
664 const QStringList stashedModels(ui->comp_StashAircraft->getStashedModelStrings());
665 if (highlightVPilot)
666 {
667 ui->tvp_AircraftModelsForVPilot->derivedModel()->setHighlightModelStrings(stashedModels);
668 }
669 if (highlightOwnModels)
670 {
671 ui->comp_OwnAircraftModels->view()->derivedModel()->setHighlightModelStrings(stashedModels);
672 }
673 if (highlightModelSet)
674 {
675 ui->comp_OwnModelSet->view()->derivedModel()->setHighlightModelStrings(stashedModels);
676 }
677 }
678
679 void CDbMappingComponent::onTabIndexChanged(int index)
680 {
681 const auto ti = static_cast<CDbMappingComponent::TabIndex>(index);
682 switch (ti)
683 {
684 case CDbMappingComponent::TabOwnModelSet:
685 {
686 ui->frp_Editors->setVisible(true);
687 ui->editor_ModelMapping->setVisible(true);
688 this->resizeForSelect();
689 }
690 break;
691 case CDbMappingComponent::TabModelMatcher:
692 {
693 ui->editor_ModelMapping->setVisible(false);
694 ui->frp_Editors->setVisible(false);
695 this->resizeForSelect();
696 }
697 break;
698 case CDbMappingComponent::TabVPilot:
699 {
700 // fall thru intended
701 this->formatVPilotView();
702 }
703 [[fallthrough]];
704 default:
705 {
706 ui->frp_Editors->setVisible(true);
707 ui->editor_ModelMapping->setVisible(true);
708 }
709 break;
710 }
711 emit this->tabIndexChanged(index);
712 }
713
714 void CDbMappingComponent::onModelsSuccessfullyPublished(const CAircraftModelList &models, bool directWrite)
715 {
716 if (models.isEmpty())
717 {
718 return;
719 }
720 if (!directWrite)
721 {
722 return;
723 } // no models wwritten, but CRs
725 }
726
727 void CDbMappingComponent::onVPilotDataChanged(int count, bool withFilter)
728 {
729 Q_UNUSED(count)
730 Q_UNUSED(withFilter)
731 ui->tvp_AircraftModelsForVPilot->setTabWidgetViewText(ui->tw_ModelsToBeMapped,
732 ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot));
733 }
734
735 void CDbMappingComponent::onWorkbenchDataChanged(int count, bool withFilter)
736 {
737 Q_UNUSED(count)
738 Q_UNUSED(withFilter)
739 ui->comp_ModelWorkbench->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped,
740 ui->tw_ModelsToBeMapped->indexOf(ui->tab_Workbench));
741 }
742
743 void CDbMappingComponent::ps_addToOwnModelSet()
744 {
745 if (!this->canAddToModelSetTab())
746 {
747 return;
748 }
749 const CAircraftModelList models(this->currentModelView()->selectedObjects());
750 const CStatusMessage m = this->addToOwnModelSet(models, this->getOwnModelsSimulator());
752 }
753
754 void CDbMappingComponent::mergeWithVPilotModels()
755 {
756 if (!ui->comp_OwnAircraftModels->modelLoader())
757 {
758 return;
759 }
760 if (m_vPilotReader.getModelsCount() < 1)
761 {
762 return;
763 }
764 const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator());
765 if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator())
766 {
767 return;
768 }
769 CAircraftModelList ownModels(getOwnModels());
770 if (ownModels.isEmpty())
771 {
772 return;
773 }
774 ui->comp_OwnAircraftModels->view()->showLoadIndicator();
775 CAircraftModelUtilities::mergeWithVPilotData(ownModels, m_vPilotReader.getAsModelsFromCache(), true);
776 ui->comp_OwnAircraftModels->updateViewAndCache(ownModels);
777 }
778
779 void CDbMappingComponent::mergeSelectedWithVPilotModels()
780 {
781 if (!ui->comp_OwnAircraftModels->modelLoader())
782 {
783 return;
784 }
785 if (m_vPilotReader.getModelsCount() < 1)
786 {
787 return;
788 }
789 if (!ui->comp_OwnAircraftModels->view()->hasSelection())
790 {
791 return;
792 }
793 const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator());
794 if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator())
795 {
796 return;
797 }
798 CAircraftModelList ownModels(this->getOwnSelectedModels()); // subset
799 if (ownModels.isEmpty())
800 {
801 return;
802 }
803 ui->comp_OwnAircraftModels->view()->showLoadIndicator();
804 CAircraftModelUtilities::mergeWithVPilotData(ownModels, m_vPilotReader.getAsModelsFromCache(), true);
805
806 // full models
807 CAircraftModelList allModels = m_vPilotReader.getAsModelsFromCache();
809 ui->comp_OwnAircraftModels->updateViewAndCache(allModels);
810 }
811
812 void CDbMappingComponent::onCustomContextMenu(const QPoint &point)
813 {
814 QPoint globalPos = this->mapToGlobal(point);
815 QScopedPointer<QMenu> contextMenu(new QMenu(this));
816
817 contextMenu->addAction("Max.data area", QKeySequence(static_cast<Qt::Key>(Qt::CTRL) + Qt::Key_M, Qt::Key_D),
819 contextMenu->addAction("Max.mapping area", QKeySequence(static_cast<Qt::Key>(Qt::CTRL) + Qt::Key_M, Qt::Key_M),
821 QAction *selectedItem = contextMenu.data()->exec(globalPos);
822 Q_UNUSED(selectedItem)
823 }
824
825 void CDbMappingComponent::onStashedModelsDataChangedDigest(int count, bool withFilter)
826 {
827 Q_UNUSED(count)
828 Q_UNUSED(withFilter)
829 ui->comp_StashAircraft->view()->setTabWidgetViewText(
830 ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels));
831
832 // update editors
833 this->updateEditorsWhenApplicable();
834 }
835
836 void CDbMappingComponent::onModelSetChangedDigest(int count, bool withFilter)
837 {
838 Q_UNUSED(count)
839 Q_UNUSED(withFilter)
840
841 // none standard with simulator
842 int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModelSet);
843 QString o = "Active model set " + ui->comp_OwnModelSet->getModelSetSimulator().toQString(true);
844 const QString f = ui->comp_OwnModelSet->view()->hasFilter() ? "F" : "";
845 o = CGuiUtility::replaceTabCountValue(o, ui->comp_OwnModelSet->view()->rowCount()) + f;
846 ui->tw_ModelsToBeMapped->setTabText(i, o);
847 }
848
849 void CDbMappingComponent::onOwnModelsChangedDigest(int count, bool withFilter)
850 {
851 Q_UNUSED(count)
852 Q_UNUSED(withFilter)
853
854 // non standard with sim
855 const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_OwnModels);
856 static const QString ot("Stored own models");
857 QString o(ot);
858 const QString sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator().toQString(true));
859 if (!sim.isEmpty())
860 {
861 o = o.append(" ").append(sim);
862 }
863 const QString f = ui->comp_OwnAircraftModels->view()->hasFilter() ? "F" : "";
864 o = CGuiUtility::replaceTabCountValue(o, ui->comp_OwnAircraftModels->view()->rowCount()) + f;
865 ui->tw_ModelsToBeMapped->setTabText(i, o);
866 }
867
868 void CDbMappingComponent::onUserChanged() { this->initVPilotLoading(); }
869
871 {
872 if (!this->hasSelectedModelsToStash())
873 {
874 return;
875 }
876 CStatusMessageList msgs = ui->comp_StashAircraft->stashModels(this->getSelectedModelsToStash());
877 if (msgs.hasWarningOrErrorMessages())
878 {
880 }
881 }
882
883 void CDbMappingComponent::onModelRowSelected(const QModelIndex &index)
884 {
885 CAircraftModel model(this->getModelFromView(index)); // data from view
886 if (!model.hasModelString())
887 {
888 return;
889 }
890
891 // we either use the model, or try to resolve the data to DB data
892 bool dbModel = model.hasValidDbKey();
893 const CLivery livery(dbModel ? model.getLivery() :
894 sGui->getWebDataServices()->smartLiverySelector(model.getLivery()));
895 const CAircraftIcaoCode aircraftIcao(
896 dbModel ? model.getAircraftIcaoCode() :
897 sGui->getWebDataServices()->smartAircraftIcaoSelector(model.getAircraftIcaoCode()));
898 const CDistributor distributor(
899 dbModel ? model.getDistributor() :
900 sGui->getWebDataServices()->smartDistributorSelector(model.getDistributor()));
901
902 // set model part
903 ui->editor_ModelMapping->setValue(model);
904
905 // if found, then set in editor
906 if (livery.hasValidDbKey())
907 {
908 ui->editor_AircraftModel->setLivery(livery);
909 }
910 else
911 {
912 ui->editor_AircraftModel->clearLivery();
913 }
914 if (aircraftIcao.hasValidDbKey())
915 {
916 ui->editor_AircraftModel->setAircraftIcao(aircraftIcao);
917 }
918 else
919 {
920 ui->editor_AircraftModel->clearAircraftIcao();
921 }
922 if (distributor.hasValidDbKey())
923 {
924 ui->editor_AircraftModel->setDistributor(distributor);
925 }
926 else
927 {
928 ui->editor_AircraftModel->clearDistributor();
929 }
930
931 // request filtering
932 if (m_autoFilterInDbViews)
933 {
934 emit filterByLivery(model.getLivery());
935 emit filterByAircraftIcao(model.getAircraftIcaoCode());
936 emit filterByDistributor(model.getDistributor());
937 }
938 }
939
940 void CDbMappingComponent::onOwnModelsSimulatorChanged(const CSimulatorInfo simulator)
941 {
942 // loading of models can fail, so we clean the tab text
943 Q_UNUSED(simulator)
944
945 ui->comp_OwnAircraftModels->clearView();
946 this->onOwnModelsChangedDigest(0, false);
947 }
948
950 {
951 CAircraftModel model(ui->editor_ModelMapping->getValue());
952 model.setDistributor(ui->editor_AircraftModel->getDistributor());
953 model.setAircraftIcaoCode(ui->editor_AircraftModel->getAircraftIcao());
954 model.setLivery(ui->editor_AircraftModel->getLivery());
955 return model;
956 }
957
958 CAircraftModelList CDbMappingComponent::getOwnModels() const { return ui->comp_OwnAircraftModels->getOwnModels(); }
959
961 {
962 return ui->comp_OwnAircraftModels->getOwnCachedModels(simulator);
963 }
964
966 {
967 return ui->comp_OwnAircraftModels->getOwnSelectedModels();
968 }
969
971 {
972 return ui->comp_OwnAircraftModels->getOwnModelForModelString(modelString);
973 }
974
976 {
977 return ui->comp_OwnAircraftModels->getOwnModelsSimulator();
978 }
979
981 {
982 ui->comp_OwnAircraftModels->setSimulator(simulator);
983 }
984
985 int CDbMappingComponent::getOwnModelsCount() const { return ui->comp_OwnAircraftModels->getOwnModelsCount(); }
986
987 QString CDbMappingComponent::getOwnModelsInfoString() const { return ui->comp_OwnAircraftModels->getInfoString(); }
988
990 {
991 return ui->comp_OwnAircraftModels->getInfoStringFsFamily();
992 }
993
995 {
996 Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
997 ui->comp_OwnModelSet->setSimulator(simulator);
998 }
999
1001 {
1002 return ui->comp_OwnModelSet->getModelSetFromView();
1003 }
1004
1006 {
1007 return ui->comp_StashAircraft->stashModel(model, replace);
1008 }
1009
1011 {
1012 return ui->comp_StashAircraft->stashModels(models);
1013 }
1014
1016 const CSimulatorInfo &simulator)
1017 {
1018 return ui->comp_OwnModelSet->addToModelSet(models, simulator);
1019 }
1020
1022 {
1023 return ui->comp_StashAircraft->consolidateModel(model);
1024 }
1025
1027 {
1028 ui->comp_StashAircraft->replaceModelsUnvalidated(models);
1029 }
1030
1031 void CDbMappingComponent::CMappingVPilotMenu::customMenu(CMenuActions &menuActions)
1032 {
1033 auto *mapComp = qobject_cast<CDbMappingComponent *>(this->parent());
1034 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "Cannot access mapping component");
1035
1036 const bool canUseVPilot = mappingComponent()->withVPilot();
1037 if (canUseVPilot)
1038 {
1039 m_menuAction = menuActions.addAction(m_menuAction, CIcons::appMappings16(), "Load vPilot Rules",
1041 { mapComp, &CDbMappingComponent::loadVPilotData });
1042 }
1043 this->nestedCustomMenu(menuActions);
1044 }
1045
1046 CDbMappingComponent *CDbMappingComponent::CMappingVPilotMenu::mappingComponent() const
1047 {
1049 }
1050
1051 CDbMappingComponent::CStashToolsMenu::CStashToolsMenu(CDbMappingComponent *mappingComponent)
1052 : menus::IMenuDelegate(mappingComponent)
1053 {}
1054
1055 void CDbMappingComponent::CStashToolsMenu::customMenu(CMenuActions &menuActions)
1056 {
1057 CDbMappingComponent *mapComp = mappingComponent();
1058 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
1059 if (!mapComp->currentModelView()->isEmpty() &&
1060 mapComp->currentModelView()->getMenu().testFlag(CViewBaseNonTemplate::MenuCanStashModels))
1061 {
1062 menuActions.addMenuStash();
1063
1064 // auto filter in DB views
1065 m_stashFiltering = menuActions.addAction(
1066 m_stashFiltering, CIcons::filter16(), "Auto filtering in DB views (on/off)",
1067 CMenuAction::pathModelStash(), this, { mapComp, &CDbMappingComponent::toggleAutoFiltering });
1068 m_stashFiltering->setCheckable(true);
1069 m_stashFiltering->setChecked(mapComp->m_autoFilterInDbViews);
1070
1071 m_autoStashing = menuActions.addAction(m_autoStashing, CIcons::appDbStash16(), "Auto stashing",
1073 { mapComp, &CDbMappingComponent::displayAutoStashingDialog });
1074 m_autoSimulatorStashing =
1075 menuActions.addAction(m_autoSimulatorStashing, CIcons::appDbStash16(),
1076 "Cross simulator updating (FSX-P3D-FS9)", CMenuAction::pathModelStash(), this,
1077 { mapComp, &CDbMappingComponent::displayAutoSimulatorStashingDialog });
1078 if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted())
1079 {
1080 menuActions.addAction(
1081 CIcons::appDbStash16(), "Last auto stash run", CMenuAction::pathModelStash(), nullptr,
1082 { mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults });
1083 }
1084 }
1085 else if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash)
1086 {
1087 this->addStashViewSpecificMenus(menuActions);
1088 }
1089 this->nestedCustomMenu(menuActions);
1090 }
1091
1092 void CDbMappingComponent::CStashToolsMenu::addStashViewSpecificMenus(CMenuActions &menuActions)
1093 {
1094 CDbMappingComponent *mapComp = mappingComponent();
1095 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
1096
1097 const int dbModels = sGui->getWebDataServices()->getModelsCount();
1098 if (dbModels > 0 && mapComp->hasStashedModels())
1099 {
1100 menuActions.addMenu(CIcons::appDbStash16(), "Stash", CMenuAction::pathModelStash());
1101
1102 // we have keys and data by which we could delete them from view
1103 const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from '" +
1104 mapComp->currentTabText() + "'");
1105 menuActions.addAction(CIcons::delete16(), msgDelete, CMenuAction::pathModelStash(), nullptr,
1106 { mapComp, &CDbMappingComponent::removeDbModelsFromView });
1107
1108 // attribute info
1109 menuActions.addAction(CIcons::info16(), "Show changed attributes", CMenuAction::pathModelStash(), nullptr,
1110 { mapComp, &CDbMappingComponent::showChangedAttributes });
1111 }
1112 }
1113
1114 CDbMappingComponent *CDbMappingComponent::CStashToolsMenu::mappingComponent() const
1115 {
1117 }
1118
1119 void CDbMappingComponent::COwnModelSetMenu::customMenu(CMenuActions &menuActions)
1120 {
1121 CDbMappingComponent *mapComp = mappingComponent();
1122 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
1123 if (mapComp->canAddToModelSetTab())
1124 {
1125 menuActions.addMenuModelSet();
1126 m_menuAction = menuActions.addAction(
1127 m_menuAction, CIcons::appModels16(),
1129 CMenuAction::pathModelSet(), this, { mapComp, &CDbMappingComponent::ps_addToOwnModelSet },
1131 }
1132 this->nestedCustomMenu(menuActions);
1133 }
1134
1135 CDbMappingComponent *CDbMappingComponent::COwnModelSetMenu::mappingComponent() const
1136 {
1138 }
1139
1140 void CDbMappingComponent::CApplyDbDataMenu::customMenu(CMenuActions &menuActions)
1141 {
1142 CDbMappingComponent *mapComp = mappingComponent();
1143 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
1144
1145 if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection())
1146 {
1147 if (m_menuActions.isEmpty())
1148 {
1149 m_menuActions = QList<QAction *>({ nullptr, nullptr, nullptr, nullptr });
1150 }
1151
1152 // stash view and selection
1153 menuActions.addMenuStashEditor();
1154
1155 m_menuActions[0] = menuActions.addAction(m_menuActions[0], CIcons::appAircraftIcao16(),
1156 "Current aircraft ICAO", CMenuAction::pathModelStashEditor(), this,
1157 { mapComp, &CDbMappingComponent::applyFormAircraftIcaoData });
1158 m_menuActions[1] = menuActions.addAction(m_menuActions[1], CIcons::appDistributors16(),
1159 "Current distributor", CMenuAction::pathModelStashEditor(), this,
1160 { mapComp, &CDbMappingComponent::applyFormDistributorData });
1161 m_menuActions[2] = menuActions.addAction(m_menuActions[2], CIcons::appLiveries16(), "Current livery",
1163 { mapComp, &CDbMappingComponent::applyFormLiveryData });
1164 m_menuActions[3] = menuActions.addAction(m_menuActions[3], CIcons::databaseTable16(),
1165 "Modify DB model data", CMenuAction::pathModelStashEditor(), this,
1167 }
1168 this->nestedCustomMenu(menuActions);
1169 }
1170
1171 CDbMappingComponent *CDbMappingComponent::CApplyDbDataMenu::mappingComponent() const
1172 {
1174 }
1175
1176 CDbMappingComponent::CMergeWithVPilotMenu::CMergeWithVPilotMenu(CDbMappingComponent *mappingComponent)
1177 : IMenuDelegate(mappingComponent)
1178 {
1179 Q_ASSERT_X(mappingComponent, Q_FUNC_INFO, "Missing vPilot reader");
1180 }
1181
1182 void CDbMappingComponent::CMergeWithVPilotMenu::customMenu(CMenuActions &menuActions)
1183 {
1184 const CAircraftModelView *mv = mappingComponent()->ui->comp_OwnAircraftModels->view();
1185 const CSimulatorInfo sim = mappingComponent()->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
1186 if (!mappingComponent()->withVPilot() || mv->isEmpty() || !sim.isSingleSimulator() ||
1188 {
1189 this->nestedCustomMenu(menuActions);
1190 return;
1191 }
1192
1193 if (m_menuActions.isEmpty())
1194 {
1195 m_menuActions = QList<QAction *>({ nullptr, nullptr });
1196 }
1197 menuActions.addMenu("Merge with vPilot data", CMenuAction::pathVPilot());
1198 m_menuActions[0] = menuActions.addAction(m_menuActions[0], "All", CMenuAction::pathVPilot(), this,
1199 { mappingComponent(), &CDbMappingComponent::mergeWithVPilotModels });
1200 if (mv->hasSelection())
1201 {
1202 m_menuActions[1] =
1203 menuActions.addAction(m_menuActions[1], "Selected only", CMenuAction::pathVPilot(), this,
1204 { mappingComponent(), &CDbMappingComponent::mergeSelectedWithVPilotModels });
1205 }
1206 this->nestedCustomMenu(menuActions);
1207 }
1208
1209 void CDbMappingComponent::CRemovedModelsMenu::customMenu(CMenuActions &menuActions)
1210 {
1211 CDbMappingComponent *mapComp = mappingComponent();
1212 Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
1213 if (mapComp->isWorkbenchTab())
1214 {
1215 menuActions.addMenuModelSet();
1216 m_menuAction =
1217 menuActions.addAction(m_menuAction, CIcons::appModels16(), "Removed models", CMenuAction::pathModel(),
1218 this, { mapComp, &CDbMappingComponent::loadRemovedModels });
1219 }
1220 this->nestedCustomMenu(menuActions);
1221 }
1222
1223 CDbMappingComponent *CDbMappingComponent::CRemovedModelsMenu::mappingComponent() const
1224 {
1226 }
1227
1228 CDbMappingComponent *CDbMappingComponent::CMergeWithVPilotMenu::mappingComponent() const
1229 {
1231 }
1232} // namespace swift::gui::components
CWebDataServices * getWebDataServices() const
Get the web data services.
int getModelsCount() const
Models count.
QStringList getModelStrings(bool sort=false) const
Model strings.
static QString replaceTabCountValue(const QString &oldName, int count)
Replace count in name such as "stations (4)".
void showOverlayMessagesOrHTMLMessage(const swift::misc::CStatusMessageList &messages, bool appendOldMessages=false, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
COverlayMessagesFrame(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags())
Constructor.
static const QKeySequence & keyAddToModelSet()
Add to model set.
Definition shortcut.cpp:18
static QString toParenthesisString(const QKeySequence &sequence)
As string for menus etc. Looks like "(CTRL + R)".
Definition shortcut.cpp:97
Allows to automatically update models if found in own model set, but already existing for a sibling s...
bool hasSelectedModelsToStash() const
Any models which can be stashed?
TabIndex currentTabIndex() const
Current tab index.
void setOwnModelSetSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Set simulator for own models.
void replaceStashedModelsUnvalidated(const swift::misc::simulation::CAircraftModelList &models) const
Replace models, no validation.
void tabIndexChanged(int index)
Tab index has been changed.
swift::misc::CStatusMessageList stashModels(const swift::misc::simulation::CAircraftModelList &models)
Stash given models (includes validation and consolidation with DB data).
swift::misc::simulation::CAircraftModelList getSelectedModelsToStash() const
Models to be stashed from currently activated tab (table view).
void maxTableView()
Max. space for table view.
swift::misc::simulation::CAircraftModelList getOwnSelectedModels() const
Own selected models.
swift::misc::CStatusMessage addToOwnModelSet(const swift::misc::simulation::CAircraftModelList &models, const swift::misc::simulation::CSimulatorInfo &simulator)
Add to model set.
bool canAddToModelSetTab() const
Tab can contribute to model set.
int getOwnModelsCount() const
Number of own models.
bool withVPilot() const
With vPilot rules?
swift::misc::simulation::CSimulatorInfo getOwnModelsSimulator() const
Own models for simulator.
void requestUpdatedData(swift::misc::network::CEntityFlags::Entity entities)
Request latest (incremental) data from backend.
swift::misc::simulation::CAircraftModelList getOwnModelSet() const
Own model set.
void resizeForMapping()
Resize so that mapping is easier.
swift::misc::CStatusMessageList validateCurrentModel(bool withNestedForms) const
Validate, empty list means OK.
void filterByAircraftIcao(const swift::misc::aviation::CAircraftIcaoCode &icao)
Request to filter by aircraft ICAO.
swift::misc::simulation::CAircraftModelList getOwnModels() const
Own cached models.
CDbMappingComponent(QWidget *parent=nullptr)
Constructor.
views::CAircraftModelView * currentModelView() const
Current model view.
swift::misc::simulation::CAircraftModel getEditorAircraftModel() const
Unvalidated consolidated aircraft model from the editor subparts (icao, distributor).
QString getOwnModelsInfoString() const
Info string about models in cache.
void setOwnModelsSimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Set simulator for own models.
void modifyModelDialog()
Open model modify dialog.
views::CAircraftModelView * modelView(TabIndex tab) const
Current model view.
swift::misc::simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const
Own (installed) model for given model string.
swift::misc::simulation::CAircraftModelList getOwnCachedModels(const swift::misc::simulation::CSimulatorInfo &simulator) const
Own cached models.
void filterByDistributor(const swift::misc::simulation::CDistributor &distributor)
Request to filter by distributor.
swift::misc::CStatusMessage stashModel(const swift::misc::simulation::CAircraftModel &model, bool replace=false)
Stash given model (includes validation and consolidation with DB data).
void filterByLivery(const swift::misc::aviation::CLivery &livery)
Request to filter by livery.
const swift::misc::simulation::CAircraftModelList & getStashedModels() const
Any stashed models?
bool hasStashedModels() const
Any stashed models?
QString getOwnModelsInfoStringFsFamily() const
Info string without XPlane (FSX,P3D, FS9).
QStringList getStashedModelStrings() const
Stashed model strings.
swift::misc::simulation::CAircraftModel consolidateModel(const swift::misc::simulation::CAircraftModel &model) const
Consolidate with other available data.
void resizeForSelect()
Resize so that selection is easy (larger table view).
void ownModelsSimulatorChanged(const swift::misc::simulation::CSimulatorInfo &simulator)
Own models simulator has changed.
void stashedModelsChanged()
Stashed models have been changed.
void modelsSuccessfullyPublished(const swift::misc::simulation::CAircraftModelList &publishedModels, bool directWrite)
Models succesfully published.
void tabIndexChanged(int index)
Tab (where this component is embedded) has been changed.
void requestStash()
Request stashing for model.
static const QString & pathModel()
Model.
Definition menuaction.h:143
static const QString & pathModelStashEditor()
Stash editor sub menu.
Definition menuaction.h:178
static const QString & pathVPilot()
vPilot data
Definition menuaction.h:186
static const QString & pathModelSet()
Model set.
Definition menuaction.h:150
static const QString & pathModelStash()
Stash sub menu.
Definition menuaction.h:171
Bunch of CMenuAction objects.
Definition menuaction.h:384
CMenuAction addMenuStash()
Stash menu.
CMenuAction addAction(const CMenuAction &menuAction)
Add menu action.
CMenuAction addMenuStashEditor()
Stash menu.
CMenuAction addMenu(const CMenuAction &subdirAction)
Add a sub menu.
CMenuAction addMenuModelSet()
Model set menu.
Open the simulator file (e.g. aircraft.cfg) in the standard text editor.
void nestedCustomMenu(CMenuActions &menuActions) const
Delegate down one level.
int removeModelsWithModelString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity=Qt::CaseInsensitive)
Remove models with model strings.
void toggledHighlightStashedModels()
Highlight stashed models has been toggled.
void requestHandlingOfStashDrop(const swift::misc::aviation::CAirlineIcaoCode &airlineIcao)
Request further handling of drops I cannot handle on my own.
bool hasSelectedModelsToStash() const
Has any models to stash and it is allowed to stash.
void requestStash(const swift::misc::simulation::CAircraftModelList &models)
Request to stash if applicable.
bool isEmpty() const
Empty?
Definition viewbase.cpp:481
ContainerType selectedObjects() const
Selected objects.
Definition viewbase.cpp:267
const ObjectType & at(const QModelIndex &index) const
Value object at.
Definition viewbase.cpp:214
void requestUpdate()
Ask for new data from currently loaded data.
void modelDataChangedDigest(int count, bool withFilter)
Model data changed,.
void modelDataChanged(int count, bool withFilter)
Model data changed.
@ MenuClear
allow clearing the view via menu
Definition viewbase.h:120
@ MenuRemoveSelectedRows
allow to remove selected rows
Definition viewbase.h:121
bool hasSelection() const
Selection (selected rows).
T get() const
Get a copy of the current value.
Definition valuecache.h:411
static const QPixmap & appModels16()
Models.
static const QPixmap & appLiveries16()
Liveries.
static const QPixmap & wrench16()
Wrench.
static const QPixmap & databaseTable16()
Database table.
static const QPixmap & appDbStash16()
Stash.
static const QPixmap & appMappings16()
Application mappings.
static const QPixmap & info16()
Info.
static const QPixmap & appAircraftIcao16()
Aircraft ICAO.
static const QPixmap & appDistributors16()
Distributors.
static const QPixmap & delete16()
Delete.
static const QPixmap & filter16()
Filter.
Class for emitting a log message.
Definition logmessage.h:27
static void preformatted(const CStatusMessage &statusMessage)
Sends a verbatim, preformatted message to the log.
Derived & warning(const char16_t(&format)[N])
Set the severity to warning, providing a format string.
Derived & info(const char16_t(&format)[N])
Set the severity to info, providing a format string.
Specialized value object compliant map for variants, based on indexes.
void push_back(const T &value)
Appends an element at the end of the sequence.
Definition sequence.h:308
bool isEmpty() const
Synonym for empty.
Definition sequence.h:285
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
bool hasWarningOrErrorMessages() const
Warning or error messages.
bool hasErrorMessages() const
Error messages.
static const QString & logDirectory()
Directory for log files.
Value object for ICAO classification.
Value object for ICAO classification.
Value object encapsulating information about an airpot.
Definition livery.h:29
Aircraft model (used by another pilot, my models on disk).
void setLivery(const aviation::CLivery &livery)
Livery.
void setDistributor(const CDistributor &distributor)
Set distributor.
bool setAircraftIcaoCode(const aviation::CAircraftIcaoCode &aircraftIcaoCode)
Set aircraft ICAO code.
Value object encapsulating a list of aircraft models.
int replaceOrAddModelsWithString(const CAircraftModelList &addOrReplaceList, Qt::CaseSensitivity sensitivity)
Replace or add based on model string.
static bool mergeWithVPilotData(swift::misc::simulation::CAircraftModelList &modelToBeModified, const swift::misc::simulation::CAircraftModelList &vPilotModels, bool force=false)
Merge with vPilot data if possible.
Value object encapsulating information of software distributor.
Definition distributor.h:33
Simple hardcoded info about the corresponding simulator.
bool isSingleSimulator() const
Single simulator selected.
void setSimulator(Simulator s)
Simulator.
bool isMicrosoftOrPrepare3DSimulator() const
Microsoft Simulator or P3D?
swift::misc::simulation::CAircraftModelList getAsModelsFromCache() const
Get as models from cache.
swift::misc::CWorker * readInBackground(bool convertToModels)
Load data in background thread.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
High level reusable GUI components.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
GUI related classes.
Free functions in swift::misc.
void doubleClicked(const QModelIndex &index)
bool isValid() const const
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QObject * parent() const const
T qobject_cast(QObject *object)
QObject * sender() const const
QString & append(QChar ch)
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString number(double n, char format, int precision)
CaseInsensitive
QueuedConnection
CustomContextMenu
void currentChanged(int index)
QWidget(QWidget *parent, Qt::WindowFlags f)
void setContextMenuPolicy(Qt::ContextMenuPolicy policy)
void customContextMenuRequested(const QPoint &pos)
QPoint mapToGlobal(const QPoint &pos) const const