From: asl Date: Tue, 18 Aug 2015 11:39:11 +0000 (+0300) Subject: Issue #845: rename and delete actions are disabled in deactivated part X-Git-Tag: V_1.4.0_beta4~360 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2005e7ee527c15e0aaa70d5f0c76a0cf8b89fccf;p=modules%2Fshaper.git Issue #845: rename and delete actions are disabled in deactivated part --- diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 7e7b90446..8557a43f9 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -54,6 +54,10 @@ void XGUI_ContextMenuMgr::createActions() aAction->setShortcut(Qt::Key_Delete); aAction->setShortcutContext(Qt::ApplicationShortcut); + aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this); + addAction("RENAME_CMD", aAction); + connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onRename())); + aAction = new QAction(QIcon(":pictures/move.png"), tr("Move..."), this); addAction("MOVE_CMD", aAction); @@ -186,6 +190,12 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() } else if (hasFeature && myWorkshop->canMoveFeature()) action("MOVE_CMD")->setEnabled(true); + + if( aMgr->activeDocument() == aObject->document() ) + { + action("RENAME_CMD")->setEnabled(true); + action("DELETE_CMD")->setEnabled(true); + } } } else { if (hasResult && (!hasParameter)) { @@ -196,7 +206,14 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("WIREFRAME_CMD")->setEnabled(true); } } - if (!hasSubFeature) { + bool allActive = true; + foreach( ObjectPtr aObject, aObjects ) + if( aMgr->activeDocument() != aObject->document() ) + { + allActive = false; + break; + } + if (!hasSubFeature && allActive ) { if (hasFeature || hasParameter) action("DELETE_CMD")->setEnabled(true); } @@ -278,6 +295,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("HIDE_CMD")); aList.append(action("SHOW_ONLY_CMD")); aList.append(action("COLOR_CMD")); + aList.append(mySeparator); + aList.append(action("RENAME_CMD")); myObjBrowserMenus[ModelAPI_ResultConstruction::group()] = aList; //------------------------------------- // Result body menu @@ -289,6 +308,8 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.append(action("SHOW_CMD")); aList.append(action("HIDE_CMD")); aList.append(action("SHOW_ONLY_CMD")); + aList.append(mySeparator); + aList.append(action("RENAME_CMD")); myObjBrowserMenus[ModelAPI_ResultBody::group()] = aList; // Group menu myObjBrowserMenus[ModelAPI_ResultGroup::group()] = aList; @@ -299,10 +320,14 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.clear(); aList.append(action("DELETE_CMD")); aList.append(action("MOVE_CMD")); + aList.append(mySeparator); + aList.append(action("RENAME_CMD")); myObjBrowserMenus[ModelAPI_Feature::group()] = aList; aList.clear(); aList.append(action("DELETE_CMD")); + aList.append(mySeparator); + aList.append(action("RENAME_CMD")); myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList; //------------------------------------- } @@ -420,3 +445,8 @@ QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName) } return aGroups; } + +void XGUI_ContextMenuMgr::onRename() +{ + myWorkshop->objectBrowser()->onEditItem(); +} diff --git a/src/XGUI/XGUI_ContextMenuMgr.h b/src/XGUI/XGUI_ContextMenuMgr.h index 1ce4bcb1b..db0e71e85 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.h +++ b/src/XGUI/XGUI_ContextMenuMgr.h @@ -81,6 +81,8 @@ signals: /// \param theEvent a context menu event void onContextMenuRequest(QContextMenuEvent* theEvent); + void onRename(); + private: /** * Add action diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index acdd5e5fb..58e5fb3de 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -225,12 +225,6 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) SLOT(onLabelContextMenuRequested(const QPoint&))); connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SLOT(onContextMenuRequested(QContextMenuEvent*))); - - // Create internal actions - QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this); - aAction->setData("RENAME_CMD"); - connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEditItem())); - addAction(aAction); } //*************************************************** diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 5352ffe58..6137fb29f 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -116,6 +116,10 @@ Q_OBJECT /// Set Data Model for the Object Browser void setDataModel(ModuleBase_IDocumentDataModel* theModel); +public slots: + //! Called on Edit command request + void onEditItem(); + signals: //! Emited when selection is changed void selectionChanged(); @@ -139,9 +143,6 @@ signals: /// \param thePnt a position of context menu void onLabelContextMenuRequested(const QPoint& thePnt); - //! Called on Edit command request - void onEditItem(); - //! Called when selection in Data Tree is changed void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);