mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 03:45:30 +08:00
Ref T362, Ref T348 "removed models" context menu
This commit is contained in:
@@ -48,6 +48,7 @@
|
|||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
@@ -99,6 +100,7 @@ namespace BlackGui
|
|||||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this));
|
ui->comp_ModelWorkbench->view()->setCustomMenu(new CApplyDbDataMenu(this));
|
||||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this));
|
ui->comp_ModelWorkbench->view()->setCustomMenu(new COwnModelSetMenu(this));
|
||||||
ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this));
|
ui->comp_ModelWorkbench->view()->setCustomMenu(new CStashToolsMenu(this));
|
||||||
|
ui->comp_ModelWorkbench->view()->setCustomMenu(new CRemovedModelsMenu(this));
|
||||||
|
|
||||||
// connects
|
// connects
|
||||||
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::stashCurrentModel);
|
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::stashCurrentModel);
|
||||||
@@ -323,7 +325,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CDbMappingComponent::isStashTab() const
|
bool CDbMappingComponent::isStashTab() const
|
||||||
{
|
{
|
||||||
return currentTabIndex() == TabStash;
|
return this->currentTabIndex() == TabStash;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDbMappingComponent::isWorkbenchTab() const
|
||||||
|
{
|
||||||
|
return this->currentTabIndex() == TabWorkbench;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDbMappingComponent::canAddToModelSetTab() const
|
bool CDbMappingComponent::canAddToModelSetTab() const
|
||||||
@@ -531,6 +538,13 @@ namespace BlackGui
|
|||||||
ui->tvp_AircraftModelsForVPilot->hideLoadIndicator();
|
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()
|
void CDbMappingComponent::onVPilotCacheChanged()
|
||||||
{
|
{
|
||||||
if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
|
if (ui->tvp_AircraftModelsForVPilot->displayAutomatically())
|
||||||
@@ -1021,6 +1035,24 @@ namespace BlackGui
|
|||||||
this->nestedCustomMenu(menuActions);
|
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
|
CDbMappingComponent *CDbMappingComponent::CMergeWithVPilotMenu::mappingComponent() const
|
||||||
{
|
{
|
||||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||||
|
|||||||
@@ -105,9 +105,12 @@ namespace BlackGui
|
|||||||
//! Current tab index
|
//! Current tab index
|
||||||
TabIndex currentTabIndex() const;
|
TabIndex currentTabIndex() const;
|
||||||
|
|
||||||
//! Is stashed view
|
//! Is stashed view?
|
||||||
bool isStashTab() const;
|
bool isStashTab() const;
|
||||||
|
|
||||||
|
//! Is workbench tab?
|
||||||
|
bool isWorkbenchTab() const;
|
||||||
|
|
||||||
//! Tab can contribute to model set
|
//! Tab can contribute to model set
|
||||||
bool canAddToModelSetTab() const;
|
bool canAddToModelSetTab() const;
|
||||||
|
|
||||||
@@ -233,6 +236,9 @@ namespace BlackGui
|
|||||||
//! Data for vPilot have been loaded
|
//! Data for vPilot have been loaded
|
||||||
void onLoadVPilotDataFinished(bool success);
|
void onLoadVPilotDataFinished(bool success);
|
||||||
|
|
||||||
|
//! Load removed models
|
||||||
|
void loadRemovedModels();
|
||||||
|
|
||||||
//! Merge with vPilot models
|
//! Merge with vPilot models
|
||||||
void mergeWithVPilotModels();
|
void mergeWithVPilotModels();
|
||||||
|
|
||||||
@@ -413,6 +419,25 @@ namespace BlackGui
|
|||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Menu for removed models
|
||||||
|
class CRemovedModelsMenu : public Menus::IMenuDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CRemovedModelsMenu(CDbMappingComponent *mappingComponent) :
|
||||||
|
Menus::IMenuDelegate(mappingComponent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! \copydoc IMenuDelegate::customMenu
|
||||||
|
virtual void customMenu(Menus::CMenuActions &menuActions) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Mapping component
|
||||||
|
CDbMappingComponent *mappingComponent() const;
|
||||||
|
|
||||||
|
QAction *m_menuAction = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
//! Apply DB data to selected models
|
//! Apply DB data to selected models
|
||||||
class CApplyDbDataMenu : public Menus::IMenuDelegate
|
class CApplyDbDataMenu : public Menus::IMenuDelegate
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -437,9 +437,9 @@ namespace BlackGui
|
|||||||
CMenuAction CMenuActions::addMenuStash()
|
CMenuAction CMenuActions::addMenuStash()
|
||||||
{
|
{
|
||||||
if (this->containsMenu(CMenuAction::pathModelStash())) { return CMenuAction(); }
|
if (this->containsMenu(CMenuAction::pathModelStash())) { return CMenuAction(); }
|
||||||
const bool canConnectDb = sGui->getWebDataServices()->hasSuccesfullyConnectedSwiftDb();
|
const bool canConnectDb = sGui && sGui->getWebDataServices() && sGui->getWebDataServices()->hasSuccesfullyConnectedSwiftDb();
|
||||||
const QString txt(canConnectDb ? "Stash tools" : "Stash tools (Warning: no DB!)");
|
const QString text(canConnectDb ? "Stash tools" : "Stash tools (Warning: no DB!)");
|
||||||
return this->addMenu(CIcons::appDbStash16(), txt, CMenuAction::pathModelStash());
|
return this->addMenu(CIcons::appDbStash16(), text, CMenuAction::pathModelStash());
|
||||||
}
|
}
|
||||||
|
|
||||||
CMenuAction CMenuActions::addMenuStashEditor()
|
CMenuAction CMenuActions::addMenuStashEditor()
|
||||||
|
|||||||
Reference in New Issue
Block a user