]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #845: rename and delete actions are disabled in deactivated part
authorasl <asl@opencascade.com>
Tue, 18 Aug 2015 11:39:11 +0000 (14:39 +0300)
committerasl <asl@opencascade.com>
Tue, 18 Aug 2015 11:40:32 +0000 (14:40 +0300)
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_ContextMenuMgr.h
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h

index 7e7b904465e4d809d9bd5d8fb447b62797fb2f86..8557a43f972489ffbb5c490282131b11e69f11b6 100644 (file)
@@ -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();
+}
index 1ce4bcb1bad95365a0f77d0571b93bce9cd7df5e..db0e71e8541c533142b3a9c49c337b4d66d95e64 100644 (file)
@@ -81,6 +81,8 @@ signals:
   /// \param theEvent a context menu event
   void onContextMenuRequest(QContextMenuEvent* theEvent);
 
+  void onRename();
+
  private:
   /** 
    * Add action
index acdd5e5fb4806d2b37b0190e62d802d55a60c197..58e5fb3deb0ac43294b6e69fb9a9d5303bd4ecd2 100644 (file)
@@ -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);
 }
 
 //***************************************************
index 5352ffe585f454ba50c403d626a1cfa9a63dc9ac..6137fb29f631d10cdc4ec973510ca281709a1808 100644 (file)
@@ -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);