#1840 Summary case: Cut paste with key shortcut and multiselection for copying/cutting with key shortcut

This commit is contained in:
Rebecca Cox 2017-09-13 11:09:49 +02:00
parent 018aea4f58
commit 334a9c5bc4
3 changed files with 24 additions and 18 deletions

View File

@ -83,6 +83,7 @@ void RicCutReferencesToClipboardFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Cut");
actionToSetup->setIcon(QIcon(":/Clipboard.png"));
actionToSetup->setShortcut(QKeySequence::Cut);
}
//--------------------------------------------------------------------------------------------------

View File

@ -106,6 +106,7 @@ void RicPasteSummaryCaseFeature::setupActionLook(QAction* action)
{
action->setText("Paste Summary Case");
action->setIcon(QIcon(":/clipboard.png"));
action->setShortcut(QKeySequence::Paste);
}
//--------------------------------------------------------------------------------------------------

View File

@ -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;
}
}
}