mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#1840 Summary case: Cut paste with key shortcut and multiselection for copying/cutting with key shortcut
This commit is contained in:
parent
018aea4f58
commit
334a9c5bc4
@ -83,6 +83,7 @@ void RicCutReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setText("Cut");
|
||||
actionToSetup->setIcon(QIcon(":/Clipboard.png"));
|
||||
actionToSetup->setShortcut(QKeySequence::Cut);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -106,6 +106,7 @@ void RicPasteSummaryCaseFeature::setupActionLook(QAction* action)
|
||||
{
|
||||
action->setText("Paste Summary Case");
|
||||
action->setIcon(QIcon(":/clipboard.png"));
|
||||
action->setShortcut(QKeySequence::Paste);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -59,32 +59,36 @@ bool RiuTreeViewEventFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
||||
caf::PdmUiItem* uiItem = caf::SelectionManager::instance()->selectedItem();
|
||||
if (uiItem)
|
||||
std::vector<caf::PdmUiItem*> uiItems;
|
||||
caf::SelectionManager::instance()->selectedItems(uiItems);
|
||||
|
||||
if (uiItems.size() > 0)
|
||||
{
|
||||
std::vector<caf::CmdFeature*> matches;
|
||||
if (keyEvent->matches(QKeySequence::Copy))
|
||||
{
|
||||
QAction* actionToTrigger = caf::CmdFeatureManager::instance()->action("RicCopyReferencesToClipboardFeature");
|
||||
assert(actionToTrigger);
|
||||
|
||||
actionToTrigger->trigger();
|
||||
|
||||
keyEvent->setAccepted(true);
|
||||
return true;
|
||||
matches.push_back(caf::CmdFeatureManager::instance()->getCommandFeature("RicCopyReferencesToClipboardFeature"));
|
||||
}
|
||||
else if (keyEvent->matches(QKeySequence::Cut))
|
||||
{
|
||||
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingSubString("Cut");
|
||||
}
|
||||
else if (keyEvent->matches(QKeySequence::Paste))
|
||||
{
|
||||
std::vector<caf::CmdFeature*> matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingSubString("Paste");
|
||||
|
||||
for (caf::CmdFeature* feature : matches)
|
||||
if (uiItems.size() == 1)
|
||||
{
|
||||
if (feature->canFeatureBeExecuted())
|
||||
{
|
||||
feature->actionTriggered(false);
|
||||
matches = caf::CmdFeatureManager::instance()->commandFeaturesMatchingSubString("Paste");
|
||||
}
|
||||
}
|
||||
|
||||
keyEvent->setAccepted(true);
|
||||
return true;
|
||||
}
|
||||
for (caf::CmdFeature* feature : matches)
|
||||
{
|
||||
if (feature->canFeatureBeExecuted())
|
||||
{
|
||||
feature->actionTriggered(false);
|
||||
|
||||
keyEvent->setAccepted(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user