21#include "ui_dbmappingcomponent.h"
37#include "gui/menus/aircraftmodelmenus.h"
38#include "gui/menus/menuaction.h"
54using namespace swift::misc::aviation;
55using namespace swift::misc::network;
56using namespace swift::misc::simulation;
57using namespace swift::misc::simulation::fscommon;
59using namespace swift::gui::editors;
62using namespace swift::gui::menus;
73 ui->comp_StashAircraft->setMappingComponent(
this);
74 ui->comp_OwnModelSet->setMappingComponent(
this);
78 ui->tvp_AircraftModelsForVPilot->addFilterDialog();
81 ui->comp_OwnAircraftModels->view()->setCustomMenu(
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));
87 ui->comp_OwnModelSet->view()->setCustomMenu(
new CShowSimulatorFileMenu(ui->comp_OwnModelSet->view(),
this));
88 ui->comp_OwnModelSet->view()->setCustomMenu(
new CStashToolsMenu(
this));
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));
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));
104 &CDbMappingComponent::stashCurrentModel);
109 &CDbMappingComponent::onModelRowSelected);
115 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
118 &CDbMappingComponent::onModelRowSelected);
124 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
127 &CDbMappingComponent::onStashedModelsDataChangedDigest);
129 &CDbMappingComponent::onModelRowSelected);
131 &CDbMappingComponent::handleStashDropRequest);
133 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
147 &CDbMappingComponent::onModelRowSelected);
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());
158 ui->comp_ModelMatcher->setWorkbenchView(ui->comp_ModelWorkbench->view());
161 ui->editor_AircraftModel->setSelectOnly();
171 &CDbMappingComponent::onCustomContextMenu);
175 this->initVPilotLoading();
180 void CDbMappingComponent::initVPilotLoading()
182 m_vPilotEnabled = this->vPilotSupport && m_swiftDbUser.
get().
hasAdminRole();
183 static const QString tabName(ui->tw_ModelsToBeMapped->tabText(TabVPilot));
185 if (m_vPilot1stInit && vPilotSupport)
187 m_vPilot1stInit =
false;
189 &CDbMappingComponent::onModelRowSelected);
191 &CDbMappingComponent::onVPilotDataChanged);
193 &CDbMappingComponent::onLoadVPilotDataFinished);
197 &CDbMappingComponent::onStashedModelsChangedTriggerDigest);
199 &CDbMappingComponent::requestVPilotDataUpdate);
201 ui->tvp_AircraftModelsForVPilot->setCustomMenu(
new CMappingVPilotMenu(
this));
202 ui->tvp_AircraftModelsForVPilot->setCustomMenu(
new CStashToolsMenu(
this));
203 ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(
true);
205 ui->tvp_AircraftModelsForVPilot->addFilterDialog();
207 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(vPilotModels);
208 const int noModels = vPilotModels.size();
211 ui->tab_VPilot->setEnabled(m_vPilotEnabled);
212 ui->tab_VPilot->setVisible(m_vPilotEnabled);
216 ui->tw_ModelsToBeMapped->addTab(ui->tab_VPilot, tabName);
217 this->onVPilotDataChanged(ui->tvp_AircraftModelsForVPilot->rowCount(),
218 ui->tvp_AircraftModelsForVPilot->hasFilter());
222 m_vPilotFormatted =
false;
223 ui->tw_ModelsToBeMapped->removeTab(TabVPilot);
227 void CDbMappingComponent::formatVPilotView()
229 if (!m_vPilotEnabled || m_vPilotFormatted)
233 m_vPilotFormatted =
true;
234 ui->tvp_AircraftModelsForVPilot->presizeOrFullResizeToContents();
237 CAircraftModel CDbMappingComponent::getModelFromView(
const QModelIndex &index)
const
246 if (
sender == ui->tvp_AircraftModelsForVPilot)
248 return ui->tvp_AircraftModelsForVPilot->at(index);
250 if (
sender == ui->comp_OwnAircraftModels->view())
252 return ui->comp_OwnAircraftModels->view()->at(index);
254 if (
sender == ui->comp_StashAircraft ||
sender == ui->comp_StashAircraft->view())
256 return ui->comp_StashAircraft->view()->at(index);
258 if (
sender == ui->comp_OwnModelSet->view())
260 return ui->comp_OwnModelSet->view()->at(index);
269 return mv->
at(index);
275 m_vPilotReader.gracefulShutdown();
276 ui->comp_OwnAircraftModels->gracefulShutdown();
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;
308 QString CDbMappingComponent::currentTabText()
const
310 const int i = ui->tw_ModelsToBeMapped->currentIndex();
311 return ui->tw_ModelsToBeMapped->tabText(i);
314 void CDbMappingComponent::updateEditorsWhenApplicable()
316 const CAircraftModel currentEditorModel(ui->editor_ModelMapping->getValue());
317 if (!currentEditorModel.hasModelString())
321 const QString modelString(currentEditorModel.getModelString());
322 const CAircraftModel currentStashedModel(ui->comp_StashAircraft->getStashedModel(modelString));
323 if (!currentStashedModel.hasModelString())
330 bool updated =
false;
331 const CLivery stashedLivery(currentStashedModel.getLivery());
332 if (stashedLivery.hasValidDbKey())
334 if (ui->editor_AircraftModel->setLivery(stashedLivery))
340 const CDistributor stashedDistributor(currentStashedModel.getDistributor());
341 if (stashedDistributor.hasValidDbKey())
343 if (ui->editor_AircraftModel->setDistributor(stashedDistributor))
349 const CAircraftIcaoCode stashedIcaoCode(currentStashedModel.getAircraftIcaoCode());
350 if (stashedIcaoCode.hasValidDbKey())
352 if (ui->editor_AircraftModel->setAircraftIcao(stashedIcaoCode))
360 CLogMessage(
this).info(u
"Updated editor data for '%1'") << modelString;
376 return ui->comp_StashAircraft->getStashedModels();
383 return ui->comp_StashAircraft->getStashedModelStrings();
388 if (!ui->tw_ModelsToBeMapped)
390 return CDbMappingComponent::NoValidTab;
392 const int t = ui->tw_ModelsToBeMapped->currentIndex();
402 const bool allowed = this->
currentTabIndex() == CDbMappingComponent::TabOwnModels ||
413 msgs.
push_back(ui->editor_ModelMapping->validate(
false));
414 msgs.
push_back(ui->editor_AircraftModel->validate(
true));
419 msgs.
push_back(ui->editor_ModelMapping->validate(
false));
424 void CDbMappingComponent::handleStashDropRequest(
const CAirlineIcaoCode &code)
const
426 const CLivery stdLivery(sGui->getWebDataServices()->getStdLiveryForAirlineCode(code));
427 if (!stdLivery.hasValidDbKey())
431 ui->comp_StashAircraft->applyToSelected(stdLivery);
434 void CDbMappingComponent::stashCurrentModel()
438 if (!msgs.hasErrorMessages())
444 msgs.push_back(ui->comp_StashAircraft->stashModel(editorModel,
true, consolidate));
446 if (msgs.hasErrorMessages())
452 void CDbMappingComponent::displayAutoStashingDialog() { m_autoStashDialog->exec(); }
454 void CDbMappingComponent::displayAutoSimulatorStashingDialog() { m_autoSimulatorDialog->exec(); }
456 void CDbMappingComponent::removeDbModelsFromView()
459 if (modelStrings.isEmpty())
470 void CDbMappingComponent::showChangedAttributes()
480 ui->comp_StashAircraft->showChangedAttributes();
483 void CDbMappingComponent::toggleAutoFiltering() { m_autoFilterInDbViews = !m_autoFilterInDbViews; }
485 void CDbMappingComponent::applyFormLiveryData()
487 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
491 const CStatusMessageList msgs = ui->editor_AircraftModel->validateLivery(
true);
498 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getLivery());
502 void CDbMappingComponent::applyFormAircraftIcaoData()
504 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
508 const CStatusMessageList msgs = ui->editor_AircraftModel->validateAircraftIcao(
true);
515 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getAircraftIcao());
519 void CDbMappingComponent::applyFormDistributorData()
521 if (ui->comp_StashAircraft->view()->selectedRowCount() < 1)
525 const CStatusMessageList msgs = ui->editor_AircraftModel->validateDistributor(
true);
532 ui->comp_StashAircraft->applyToSelected(ui->editor_AircraftModel->getDistributor());
539 if (ui->comp_StashAircraft->view()->hasSingleSelectedRow())
541 m_modelModifyDialog->setValue(ui->comp_StashAircraft->view()->selectedObject());
550 ui->comp_StashAircraft->applyToSelected(vm);
557 const int h = this->
height();
558 int h2 = ui->qw_EditorsScrollArea->minimumHeight();
559 h2 = qRound(h2 * 1.10);
560 int currentSize = ui->sp_MappingComponent->sizes().last();
561 if (h2 <= currentSize)
578 ui->sp_MappingComponent->setSizes(sizes);
583 const int h = this->
height();
587 ui->sp_MappingComponent->setSizes(sizes);
590 void CDbMappingComponent::loadVPilotData()
595 ui->tvp_AircraftModelsForVPilot->showLoadIndicator();
603 void CDbMappingComponent::onLoadVPilotDataFinished(
bool success)
605 if (!m_vPilotEnabled)
611 CLogMessage(
this).info(u
"Loading vPilot ruleset completed");
612 const CAircraftModelList models(m_vPilotReader.getAsModels());
613 if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
615 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(models);
620 CLogMessage(
this).error(u
"Loading vPilot ruleset failed");
622 ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
625 void CDbMappingComponent::loadRemovedModels()
627 if (!ui->comp_ModelWorkbench->view())
632 ui->comp_ModelWorkbench->view()->showFileLoadDialog(logDir);
635 void CDbMappingComponent::onVPilotCacheChanged()
637 if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
639 ui->tvp_AircraftModelsForVPilot->updateContainerMaybeAsync(m_vPilotReader.getAsModelsFromCache());
643 ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
647 void CDbMappingComponent::requestVPilotDataUpdate() { this->onVPilotCacheChanged(); }
649 void CDbMappingComponent::onStashedModelsChangedTriggerDigest()
651 m_dsStashedModelsChanged.inputSignal();
654 void CDbMappingComponent::onStashedModelsChangedDigest()
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;
664 const QStringList stashedModels(ui->comp_StashAircraft->getStashedModelStrings());
667 ui->tvp_AircraftModelsForVPilot->derivedModel()->setHighlightModelStrings(stashedModels);
669 if (highlightOwnModels)
671 ui->comp_OwnAircraftModels->view()->derivedModel()->setHighlightModelStrings(stashedModels);
673 if (highlightModelSet)
675 ui->comp_OwnModelSet->view()->derivedModel()->setHighlightModelStrings(stashedModels);
679 void CDbMappingComponent::onTabIndexChanged(
int index)
684 case CDbMappingComponent::TabOwnModelSet:
686 ui->frp_Editors->setVisible(
true);
687 ui->editor_ModelMapping->setVisible(
true);
691 case CDbMappingComponent::TabModelMatcher:
693 ui->editor_ModelMapping->setVisible(
false);
694 ui->frp_Editors->setVisible(
false);
698 case CDbMappingComponent::TabVPilot:
701 this->formatVPilotView();
706 ui->frp_Editors->setVisible(
true);
707 ui->editor_ModelMapping->setVisible(
true);
714 void CDbMappingComponent::onModelsSuccessfullyPublished(
const CAircraftModelList &models,
bool directWrite)
727 void CDbMappingComponent::onVPilotDataChanged(
int count,
bool withFilter)
731 ui->tvp_AircraftModelsForVPilot->setTabWidgetViewText(ui->tw_ModelsToBeMapped,
732 ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot));
735 void CDbMappingComponent::onWorkbenchDataChanged(
int count,
bool withFilter)
739 ui->comp_ModelWorkbench->view()->setTabWidgetViewText(ui->tw_ModelsToBeMapped,
740 ui->tw_ModelsToBeMapped->indexOf(ui->tab_Workbench));
743 void CDbMappingComponent::ps_addToOwnModelSet()
749 const CAircraftModelList models(this->
currentModelView()->selectedObjects());
754 void CDbMappingComponent::mergeWithVPilotModels()
756 if (!ui->comp_OwnAircraftModels->modelLoader())
760 if (m_vPilotReader.getModelsCount() < 1)
764 const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator());
765 if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator())
770 if (ownModels.isEmpty())
774 ui->comp_OwnAircraftModels->view()->showLoadIndicator();
776 ui->comp_OwnAircraftModels->updateViewAndCache(ownModels);
779 void CDbMappingComponent::mergeSelectedWithVPilotModels()
781 if (!ui->comp_OwnAircraftModels->modelLoader())
785 if (m_vPilotReader.getModelsCount() < 1)
789 if (!ui->comp_OwnAircraftModels->view()->hasSelection())
793 const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator());
794 if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator())
799 if (ownModels.isEmpty())
803 ui->comp_OwnAircraftModels->view()->showLoadIndicator();
807 CAircraftModelList allModels = m_vPilotReader.getAsModelsFromCache();
809 ui->comp_OwnAircraftModels->updateViewAndCache(allModels);
812 void CDbMappingComponent::onCustomContextMenu(
const QPoint &point)
815 QScopedPointer<QMenu> contextMenu(
new QMenu(
this));
821 QAction *selectedItem = contextMenu.data()->exec(globalPos);
822 Q_UNUSED(selectedItem)
825 void CDbMappingComponent::onStashedModelsDataChangedDigest(
int count,
bool withFilter)
829 ui->comp_StashAircraft->view()->setTabWidgetViewText(
830 ui->tw_ModelsToBeMapped, ui->tw_ModelsToBeMapped->indexOf(ui->tab_StashAircraftModels));
833 this->updateEditorsWhenApplicable();
836 void CDbMappingComponent::onModelSetChangedDigest(
int count,
bool withFilter)
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" :
"";
846 ui->tw_ModelsToBeMapped->setTabText(i, o);
849 void CDbMappingComponent::onOwnModelsChangedDigest(
int count,
bool withFilter)
855 const int i = ui->tw_ModelsToBeMapped->
indexOf(ui->tab_OwnModels);
856 static const QString ot(
"Stored own models");
858 const QString sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator().toQString(
true));
863 const QString f = ui->comp_OwnAircraftModels->view()->hasFilter() ?
"F" :
"";
865 ui->tw_ModelsToBeMapped->setTabText(i, o);
868 void CDbMappingComponent::onUserChanged() { this->initVPilotLoading(); }
883 void CDbMappingComponent::onModelRowSelected(
const QModelIndex &index)
886 if (!model.hasModelString())
892 bool dbModel = model.hasValidDbKey();
893 const CLivery livery(dbModel ? model.getLivery() :
894 sGui->getWebDataServices()->smartLiverySelector(model.getLivery()));
896 dbModel ? model.getAircraftIcaoCode() :
897 sGui->getWebDataServices()->smartAircraftIcaoSelector(model.getAircraftIcaoCode()));
899 dbModel ? model.getDistributor() :
900 sGui->getWebDataServices()->smartDistributorSelector(model.getDistributor()));
903 ui->editor_ModelMapping->setValue(model);
906 if (livery.hasValidDbKey())
908 ui->editor_AircraftModel->setLivery(livery);
912 ui->editor_AircraftModel->clearLivery();
914 if (aircraftIcao.hasValidDbKey())
916 ui->editor_AircraftModel->setAircraftIcao(aircraftIcao);
920 ui->editor_AircraftModel->clearAircraftIcao();
922 if (distributor.hasValidDbKey())
924 ui->editor_AircraftModel->setDistributor(distributor);
928 ui->editor_AircraftModel->clearDistributor();
932 if (m_autoFilterInDbViews)
940 void CDbMappingComponent::onOwnModelsSimulatorChanged(
const CSimulatorInfo simulator)
945 ui->comp_OwnAircraftModels->clearView();
946 this->onOwnModelsChangedDigest(0,
false);
954 model.
setLivery(ui->editor_AircraftModel->getLivery());
962 return ui->comp_OwnAircraftModels->getOwnCachedModels(simulator);
967 return ui->comp_OwnAircraftModels->getOwnSelectedModels();
972 return ui->comp_OwnAircraftModels->getOwnModelForModelString(modelString);
977 return ui->comp_OwnAircraftModels->getOwnModelsSimulator();
991 return ui->comp_OwnAircraftModels->getInfoStringFsFamily();
997 ui->comp_OwnModelSet->setSimulator(simulator);
1002 return ui->comp_OwnModelSet->getModelSetFromView();
1007 return ui->comp_StashAircraft->stashModel(model, replace);
1012 return ui->comp_StashAircraft->stashModels(
models);
1018 return ui->comp_OwnModelSet->addToModelSet(
models, simulator);
1023 return ui->comp_StashAircraft->consolidateModel(model);
1028 ui->comp_StashAircraft->replaceModelsUnvalidated(
models);
1031 void CDbMappingComponent::CMappingVPilotMenu::customMenu(
CMenuActions &menuActions)
1034 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"Cannot access mapping component");
1036 const bool canUseVPilot = mappingComponent()->
withVPilot();
1041 { mapComp, &CDbMappingComponent::loadVPilotData });
1051 CDbMappingComponent::CStashToolsMenu::CStashToolsMenu(
CDbMappingComponent *mappingComponent)
1052 : menus::IMenuDelegate(mappingComponent)
1055 void CDbMappingComponent::CStashToolsMenu::customMenu(CMenuActions &menuActions)
1058 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"no mapping component");
1059 if (!mapComp->currentModelView()->isEmpty() &&
1065 m_stashFiltering = menuActions.
addAction(
1066 m_stashFiltering,
CIcons::filter16(),
"Auto filtering in DB views (on/off)",
1068 m_stashFiltering->setCheckable(
true);
1069 m_stashFiltering->setChecked(mapComp->m_autoFilterInDbViews);
1073 { mapComp, &CDbMappingComponent::displayAutoStashingDialog });
1074 m_autoSimulatorStashing =
1077 { mapComp, &CDbMappingComponent::displayAutoSimulatorStashingDialog });
1078 if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted())
1085 else if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash)
1087 this->addStashViewSpecificMenus(menuActions);
1092 void CDbMappingComponent::CStashToolsMenu::addStashViewSpecificMenus(CMenuActions &menuActions)
1095 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"no mapping component");
1098 if (dbModels > 0 && mapComp->hasStashedModels())
1103 const QString msgDelete(
"Delete " +
QString::number(dbModels) +
" DB model(s) from '" +
1104 mapComp->currentTabText() +
"'");
1106 { mapComp, &CDbMappingComponent::removeDbModelsFromView });
1110 { mapComp, &CDbMappingComponent::showChangedAttributes });
1119 void CDbMappingComponent::COwnModelSetMenu::customMenu(CMenuActions &menuActions)
1122 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"no mapping component");
1123 if (mapComp->canAddToModelSetTab())
1132 this->nestedCustomMenu(menuActions);
1140 void CDbMappingComponent::CApplyDbDataMenu::customMenu(CMenuActions &menuActions)
1143 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"no mapping component");
1145 if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection())
1147 if (m_menuActions.isEmpty())
1149 m_menuActions = QList<QAction *>({
nullptr,
nullptr,
nullptr,
nullptr });
1157 { mapComp, &CDbMappingComponent::applyFormAircraftIcaoData });
1160 { mapComp, &CDbMappingComponent::applyFormDistributorData });
1163 { mapComp, &CDbMappingComponent::applyFormLiveryData });
1168 this->nestedCustomMenu(menuActions);
1176 CDbMappingComponent::CMergeWithVPilotMenu::CMergeWithVPilotMenu(
CDbMappingComponent *mappingComponent)
1177 : IMenuDelegate(mappingComponent)
1179 Q_ASSERT_X(mappingComponent, Q_FUNC_INFO,
"Missing vPilot reader");
1182 void CDbMappingComponent::CMergeWithVPilotMenu::customMenu(CMenuActions &menuActions)
1184 const CAircraftModelView *mv = mappingComponent()->ui->comp_OwnAircraftModels->view();
1185 const CSimulatorInfo sim = mappingComponent()->ui->comp_OwnAircraftModels->getOwnModelsSimulator();
1193 if (m_menuActions.isEmpty())
1195 m_menuActions = QList<QAction *>({
nullptr,
nullptr });
1199 { mappingComponent(), &CDbMappingComponent::mergeWithVPilotModels });
1204 { mappingComponent(), &CDbMappingComponent::mergeSelectedWithVPilotModels });
1209 void CDbMappingComponent::CRemovedModelsMenu::customMenu(CMenuActions &menuActions)
1212 Q_ASSERT_X(mapComp, Q_FUNC_INFO,
"no mapping component");
1213 if (mapComp->isWorkbenchTab())
1218 this, { mapComp, &CDbMappingComponent::loadRemovedModels });
1220 this->nestedCustomMenu(menuActions);
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.
static QString toParenthesisString(const QKeySequence &sequence)
As string for menus etc. Looks like "(CTRL + R)".
Allows to automatically update models if found in own model set, but already existing for a sibling s...
void showLastResults()
Show last result.
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).
bool isStashTab() const
Is stashed view?
~CDbMappingComponent()
Destructor.
void stashSelectedModels()
Stash models.
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.
bool isWorkbenchTab() const
Is workbench tab?
int getOwnModelsCount() const
Number of own models.
bool withVPilot() const
With vPilot rules?
swift::misc::simulation::CSimulatorInfo getOwnModelsSimulator() const
Own models for simulator.
void gracefulShutdown()
Graceful shutdown.
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).
Modify model fields as dialog.
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.
@ VPilotRuleModel
vPilot rule turned into model
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?
ContainerType selectedObjects() const
Selected objects.
const ObjectType & at(const QModelIndex &index) const
Value object at.
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.
@ MenuCanStashModels
stash models
@ MenuClear
allow clearing the view via menu
@ MenuRemoveSelectedRows
allow to remove selected rows
bool hasSelection() const
Selection (selected rows).
T get() const
Get a copy of the current value.
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.
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.
bool isEmpty() const
Synonym for empty.
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.
bool hasAdminRole() const
Admin?
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.
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.
void readFinished(bool success)
Rules read.
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.
High level reusable GUI components.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.
void doubleClicked(const QModelIndex &index)
bool isValid() const const
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)