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 <QDir>
|
||||||
#include "cafCmdFeature.h"
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject");
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@ -529,13 +530,13 @@ void RimProject::computeUtmAreaOfInterest()
|
|||||||
#include "RimGeoMechView.h"
|
#include "RimGeoMechView.h"
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
#include "RimEclipseFaultColors.h"
|
#include "RimEclipseFaultColors.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
void RimProject::actionsBasedOnSelection(QMenu& contextMenu)
|
||||||
{
|
{
|
||||||
QStringList commandIds;
|
QStringList commandIds;
|
||||||
|
|
||||||
@ -613,7 +614,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
commandIds << "RicRangeFilterNewSliceI";
|
commandIds << "RicRangeFilterNewSliceI";
|
||||||
commandIds << "RicRangeFilterNewSliceJ";
|
commandIds << "RicRangeFilterNewSliceJ";
|
||||||
commandIds << "RicRangeFilterNewSliceK";
|
commandIds << "RicRangeFilterNewSliceK";
|
||||||
|
commandIds << "Separator";
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimEclipsePropertyFilterCollection*>(uiItem))
|
else if (dynamic_cast<RimEclipsePropertyFilterCollection*>(uiItem))
|
||||||
@ -623,7 +624,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
else if (dynamic_cast<RimEclipsePropertyFilter*>(uiItem))
|
else if (dynamic_cast<RimEclipsePropertyFilter*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicEclipsePropertyFilterInsert";
|
commandIds << "RicEclipsePropertyFilterInsert";
|
||||||
|
commandIds << "Separator";
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimGeoMechPropertyFilterCollection*>(uiItem))
|
else if (dynamic_cast<RimGeoMechPropertyFilterCollection*>(uiItem))
|
||||||
@ -633,7 +634,7 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
else if (dynamic_cast<RimGeoMechPropertyFilter*>(uiItem))
|
else if (dynamic_cast<RimGeoMechPropertyFilter*>(uiItem))
|
||||||
{
|
{
|
||||||
commandIds << "RicGeoMechPropertyFilterInsert";
|
commandIds << "RicGeoMechPropertyFilterInsert";
|
||||||
|
commandIds << "Separator";
|
||||||
commandIds << "RicDeleteItemFeature";
|
commandIds << "RicDeleteItemFeature";
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<RimWellPathCollection*>(uiItem))
|
else if (dynamic_cast<RimWellPathCollection*>(uiItem))
|
||||||
@ -651,13 +652,20 @@ void RimProject::actionsBasedOnSelection(std::vector<QAction*>& actions)
|
|||||||
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
|
||||||
for (int i = 0; i < commandIds.size(); i++)
|
for (int i = 0; i < commandIds.size(); i++)
|
||||||
{
|
{
|
||||||
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
|
if (commandIds[i] == "Separator")
|
||||||
if (feature->canFeatureBeExecuted())
|
|
||||||
{
|
{
|
||||||
QAction* act = commandManager->action(commandIds[i]);
|
contextMenu.addSeparator();
|
||||||
CVF_ASSERT(act);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caf::CmdFeature* feature = commandManager->getCommandFeature(commandIds[i].toStdString());
|
||||||
|
if (feature->canFeatureBeExecuted())
|
||||||
|
{
|
||||||
|
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 QAction;
|
||||||
|
class QMenu;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
///
|
///
|
||||||
@ -80,7 +81,7 @@ public:
|
|||||||
|
|
||||||
RimOilField* activeOilField();
|
RimOilField* activeOilField();
|
||||||
|
|
||||||
void actionsBasedOnSelection(std::vector<QAction*>& actions);
|
void actionsBasedOnSelection(QMenu& contextMenu);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Overridden methods
|
// Overridden methods
|
||||||
|
@ -2240,15 +2240,8 @@ void RiuMainWindow::customMenuRequested(const QPoint& pos)
|
|||||||
{
|
{
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
||||||
std::vector<QAction*> actions;
|
|
||||||
|
|
||||||
RiaApplication* app = RiaApplication::instance();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
app->project()->actionsBasedOnSelection(actions);
|
app->project()->actionsBasedOnSelection(menu);
|
||||||
|
|
||||||
for (size_t i = 0; i < actions.size(); i++)
|
|
||||||
{
|
|
||||||
menu.addAction(actions[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Qt doc: QAbstractScrollArea and its subclasses that map the context menu event to coordinates of the viewport().
|
// 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);
|
QPoint globalPos = m_projectTreeView->treeView()->viewport()->mapToGlobal(pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user