mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#1840 Summary case: Cut paste with key shortcut and multiselection for copying/cutting with key shortcut
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user