mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Made the menu builder in RimProject handle separators.
Also rigging for Script commands and generic toggle
This commit is contained in:
parent
48cef84069
commit
b9343fd21e
@ -45,6 +45,7 @@
|
||||
#include <QDir>
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -529,13 +530,13 @@ void RimProject::computeUtmAreaOfInterest()
|
||||
#include "RimGeoMechView.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseFaultColors.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||
{
|
||||
QStringList commandIds;
|
||||
|
||||
@ -613,7 +614,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
commandIds << "RicRangeFilterNewSliceI";
|
||||
commandIds << "RicRangeFilterNewSliceJ";
|
||||
commandIds << "RicRangeFilterNewSliceK";
|
||||
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimEclipsePropertyFilterCollection*>(uiItem))
|
||||
@ -623,7 +624,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
else if (dynamic_cast<RimEclipsePropertyFilter*>(uiItem))
|
||||
{
|
||||
commandIds << "RicEclipsePropertyFilterInsert";
|
||||
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimGeoMechPropertyFilterCollection*>(uiItem))
|
||||
@ -633,7 +634,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
else if (dynamic_cast<RimGeoMechPropertyFilter*>(uiItem))
|
||||
{
|
||||
commandIds << "RicGeoMechPropertyFilterInsert";
|
||||
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicDeleteItemFeature";
|
||||
}
|
||||
else if (dynamic_cast<RimWellPathCollection*>(uiItem))
|
||||
@ -650,6 +651,12 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
|
||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||
for (int i = 0; i < commandIds.size(); i++)
|
||||
{
|
||||
if (commandIds[i] == "Separator")
|
||||
{
|
||||
contextMenu.addSeparator();
|
||||
}
|
||||
else
|
||||
{
|
||||
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
|
||||
if (feature->canFeatureBeExecuted())
|
||||
@ -657,7 +664,8 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
||||
QAction* act = commandManager->action(commandIds[i]);
|
||||
CVF_ASSERT(act);
|
||||
|
||||
actions.push_back(act);
|
||||
contextMenu.addAction(act);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ namespace caf
|
||||
|
||||
|
||||
class QAction;
|
||||
class QMenu;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -80,7 +81,7 @@ public:
|
||||
|
||||
RimOilField* activeOilField();
|
||||
|
||||
void actionsBasedOnSelection(std::vector<QAction*>& actions);
|
||||
void actionsBasedOnSelection(QMenu& contextMenu);
|
||||
|
||||
protected:
|
||||
// Overridden methods
|
||||
|
@ -2240,15 +2240,8 @@ void RiuMainWindow::customMenuRequested(const QPoint& pos)
|
||||
{
|
||||
QMenu menu;
|
||||
|
||||
std::vector<QAction*> actions;
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
app->project()->actionsBasedOnSelection(actions);
|
||||
|
||||
for (size_t i = 0; i < actions.size(); i++)
|
||||
{
|
||||
menu.addAction(actions[i]);
|
||||
}
|
||||
app->project()->actionsBasedOnSelection(menu);
|
||||
|
||||
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
||||
QPoint globalPos = m_projectTreeView->treeView()->viewport()->mapToGlobal(pos);
|
||||
|
Loading…
Reference in New Issue
Block a user