Ref T362, Ref T348 "removed models" context menu

This commit is contained in:
Klaus Basan
2018-09-21 17:32:43 +02:00
parent 8a5112e48d
commit 3037afabf2
3 changed files with 62 additions and 5 deletions

View File

@@ -48,6 +48,7 @@
#include <QTabWidget>
#include <QVariant>
#include <QWidget>
#include <QFileDialog>
#include <Qt>
#include <QtGlobal>
@@ -99,6 +100,7 @@ namespace BlackGui
ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this));
ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this));
ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this));
ui->comp_ModelWorkbench->view()->setCustomMenu(new CRemovedModelsMenu(this));
// connects
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::stashCurrentModel);
@@ -323,7 +325,12 @@ namespace BlackGui
bool CDbMappingComponent::isStashTab() const
{
return currentTabIndex() == TabStash;
return this->currentTabIndex() == TabStash;
}
bool CDbMappingComponent::isWorkbenchTab() const
{
return this->currentTabIndex() == TabWorkbench;
}
bool CDbMappingComponent::canAddToModelSetTab() const
@@ -531,6 +538,13 @@ namespace BlackGui
ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
}
void CDbMappingComponent::loadRemovedModels()
{
if (!ui->comp_ModelWorkbench->view()) { return; }
const QString logDir = CDirectoryUtils::logDirectory();
ui->comp_ModelWorkbench->view()->showFileLoadDialog(logDir);
}
void CDbMappingComponent::onVPilotCacheChanged()
{
if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
@@ -1021,6 +1035,24 @@ namespace BlackGui
this->nestedCustomMenu(menuActions);
}
void CDbMappingComponent::CRemovedModelsMenu::customMenu(CMenuActions &menuActions)
{
CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
if (mapComp->isWorkbenchTab())
{
menuActions.addMenuModelSet();
m_menuAction = menuActions.addAction(m_menuAction, CIcons::appModels16(), "Removed models", CMenuAction::pathModel(),
this, { mapComp, &CDbMappingComponent::loadRemovedModels });
}
this->nestedCustomMenu(menuActions);
}
CDbMappingComponent *CDbMappingComponent::CRemovedModelsMenu::mappingComponent() const
{
return qobject_cast<CDbMappingComponent *>(this->parent());
}
CDbMappingComponent *CDbMappingComponent::CMergeWithVPilotMenu::mappingComponent() const
{
return qobject_cast<CDbMappingComponent *>(this->parent());