MCPcopy Create free account
hub / github.com/MITK/MITK / OnContextMenuRequested

Method OnContextMenuRequested

Modules/SegmentationUI/src/QmitkMultiLabelInspector.cpp:966–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

964
965
966void QmitkMultiLabelInspector::OnContextMenuRequested(const QPoint& /*pos*/)
967{
968 if (m_Segmentation.IsNull() || !this->isEnabled())
969 return;
970
971 const auto indexLevel = this->GetCurrentLevelType();
972
973 auto currentIndex = this->m_Controls->view->currentIndex();
974 //this ensures correct highlighting is the context menu is triggered while
975 //another context menu is already open.
976 if (currentIndex.isValid() && this->m_AboutToShowContextMenu) this->OnEntered(this->m_Controls->view->currentIndex());
977
978
979 QMenu* menu = new QMenu(this);
980
981 if (IndexLevelType::Group == indexLevel)
982 {
983 if (m_AllowLabelModification)
984 {
985 QAction* addInstanceAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_label_add.svg")), "&Add label", this);
986 QObject::connect(addInstanceAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnAddLabel);
987 menu->addAction(addInstanceAction);
988
989 QAction* renameAction = new QAction("Rename group", this);
990 QObject::connect(renameAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnRenameGroup);
991 menu->addAction(renameAction);
992
993 if (m_Segmentation->GetNumberOfGroups() > 1)
994 {
995 QAction* removeAction = new QAction(QmitkStyleManager::ThemeIcon(QStringLiteral(":/Qmitk/icon_group_delete.svg")), "Delete group", this);
996 QObject::connect(removeAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnDeleteGroup);
997 menu->addAction(removeAction);
998 }
999 }
1000
1001 if (m_AllowLockModification)
1002 {
1003 menu->addSeparator();
1004 QAction* lockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/lock.svg")), "Lock group", this);
1005 QObject::connect(lockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnLockAffectedLabels);
1006 menu->addAction(lockAllAction);
1007
1008 QAction* unlockAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/unlock.svg")), "Unlock group", this);
1009 QObject::connect(unlockAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnUnlockAffectedLabels);
1010 menu->addAction(unlockAllAction);
1011 }
1012
1013 if (m_AllowVisibilityModification)
1014 {
1015 menu->addSeparator();
1016
1017 QAction* viewAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/visible.svg")), "Show group", this);
1018 QObject::connect(viewAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsVisible);
1019 menu->addAction(viewAllAction);
1020
1021 QAction* hideAllAction = new QAction(QmitkStyleManager::ThemeIcon(QLatin1String(":/Qmitk/invisible.svg")), "Hide group", this);
1022 QObject::connect(hideAllAction, &QAction::triggered, this, &QmitkMultiLabelInspector::OnSetAffectedLabelsInvisible);
1023 menu->addAction(hideAllAction);

Callers

nothing calls this directly

Calls 15

GetCurrentLevelTypeMethod · 0.95
OnEnteredMethod · 0.95
CreateOpacityActionMethod · 0.95
GetSelectedLabelsMethod · 0.95
GetMultiSelectionModeMethod · 0.95
isEnabledMethod · 0.80
GetNumberOfGroupsMethod · 0.80
IsNotNullMethod · 0.80
IsNewInstanceAllowedMethod · 0.80
indexOfLabelMethod · 0.80
frontMethod · 0.80

Tested by

no test coverage detected