Salome HOME
Set font of the Root Label the same as in Tree View
[modules/shaper.git] / src / XGUI / XGUI_ContextMenuMgr.cpp
index 190f2ef3d50e54ab4cc89b3d33ffc4c52079ec43..7c40774ddf0edbc0d0206e3ca33c9a0de7a1b15d 100644 (file)
@@ -12,7 +12,9 @@
 #include "XGUI_OperationMgr.h"
 #include "XGUI_Tools.h"
 
+#ifndef HAVE_SALOME
 #include <AppElements_MainWindow.h>
+#endif
 
 //#include "PartSetPlugin_Part.h"
 
@@ -34,6 +36,7 @@
 #include <QContextMenuEvent>
 #include <QMenu>
 #include <QMdiArea>
+#include <QMainWindow>
 
 
 XGUI_ContextMenuMgr::XGUI_ContextMenuMgr(XGUI_Workshop* theParent)
@@ -49,10 +52,13 @@ XGUI_ContextMenuMgr::~XGUI_ContextMenuMgr()
 
 void XGUI_ContextMenuMgr::createActions()
 {
-  QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
+#ifdef HAVE_SALOME
+  QMainWindow* aDesktop = myWorkshop->salomeConnector()->desktop();
+#else
   QMainWindow* aDesktop = myWorkshop->mainWindow();
-  if (!aDesktop)
-    aDesktop = myWorkshop->salomeConnector()->desktop();
+#endif
+
+  QAction* aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
   aDesktop->addAction(aAction);
 
   addAction("DELETE_CMD", aAction);
@@ -212,7 +218,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu()
         if( aMgr->activeDocument() == aObject->document() )
         {
           action("RENAME_CMD")->setEnabled(true);
-          action("DELETE_CMD")->setEnabled(true);
+          action("DELETE_CMD")->setEnabled(!hasSubFeature);
         }
       }
     } else {
@@ -462,14 +468,14 @@ void XGUI_ContextMenuMgr::addViewerMenu(QMenu* theMenu) const
   }
   theMenu->addActions(aActions);
 
-  if (!myWorkshop->isSalomeMode()) {
-    theMenu->addSeparator();
-    QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
-    if (aMDI->actions().size() > 0) {
-      QMenu* aSubMenu = theMenu->addMenu(tr("Windows"));
-      aSubMenu->addActions(aMDI->actions());
-    }
+#ifndef HAVE_SALOME
+  theMenu->addSeparator();
+  QMdiArea* aMDI = myWorkshop->mainWindow()->mdiArea();
+  if (aMDI->actions().size() > 0) {
+    QMenu* aSubMenu = theMenu->addMenu(tr("Windows"));
+    aSubMenu->addActions(aMDI->actions());
   }
+#endif
 }
 
 QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
@@ -495,9 +501,10 @@ QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName)
 
 void XGUI_ContextMenuMgr::onRename()
 {
-  ModuleBase_OperationAction* anAction = new ModuleBase_OperationAction("Rename", this);
-  XGUI_OperationMgr* anOpMgr = myWorkshop->operationMgr();
-  anOpMgr->startOperation(anAction);
+  QObjectPtrList anObjects = myWorkshop->selector()->selection()->selectedObjects();
+  if (!myWorkshop->abortAllOperations())
+    return; 
+  // restore selection in case if dialog box was shown
+  myWorkshop->objectBrowser()->setObjectsSelected(anObjects);
   myWorkshop->objectBrowser()->onEditItem();
-  anOpMgr->commitOperation();
 }