]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
activatePartSet pop-up menu has to be only on root label in object browser
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 28 Oct 2015 16:26:41 +0000 (19:26 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 28 Oct 2015 16:26:41 +0000 (19:26 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_ObjectsBrowser.cpp

index b4f56d4a82d72233a539bef07751e7c1e24962ea..28013c9df0d51abdfbe71b16c82de80c221718d2 100644 (file)
@@ -29,7 +29,6 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_DataModel.h>
-#include <XGUI_ObjectsBrowser.h>
 #include <XGUI_OperationMgr.h>
 
 #include <Events_Loop.h>
index ac927a6fc829a29b21b12dde0f5b9876faf12d32..15e86b4cd63f56dba4af35852355ec0c387e29d5 100755 (executable)
@@ -891,7 +891,9 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
 {
   XGUI_ObjectsBrowser* aOB = dynamic_cast<XGUI_ObjectsBrowser*>(theObjectBrowser);
   if (aOB) {
-    //QLineEdit* aLabel = aOB->activeDocLabel();
+    QLineEdit* aLabel = aOB->activeDocLabel();
+    connect(aLabel, SIGNAL(customContextMenuRequested(const QPoint&)), 
+          SLOT(onActiveDocPopup(const QPoint&)));
     //QPalette aPalet = aLabel->palette();
     //aPalet.setColor(QPalette::Text, QColor(0, 72, 140));
     //aLabel->setPalette(aPalet);
@@ -901,6 +903,23 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
   }
 }
 
+void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
+{
+  SessionPtr aMgr = ModelAPI_Session::get();
+  QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD");
+
+  XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+  XGUI_Workshop* aWorkshop = aConnector->workshop();
+  QLineEdit* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
+
+  aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
+
+  QMenu aMenu;
+  aMenu.addAction(aActivatePartAction);
+  aMenu.exec(aHeader->mapToGlobal(thePnt));
+}
+
+
 ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
 {
   ObjectPtr anObject;
@@ -927,7 +946,6 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
   int aSelected = aObjects.size();
   SessionPtr aMgr = ModelAPI_Session::get();
   QAction* aActivatePartAction = myMenuMgr->action("ACTIVATE_PART_CMD");
-  QAction* aActivatePartSetAction = myMenuMgr->action("ACTIVATE_PARTSET_CMD");
 
   ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
   if (aSelected == 1) {
@@ -968,21 +986,11 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const
       ResultBodyPtr aResult = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObject);
       if( aResult.get() )
         theMenu->addAction(myMenuMgr->action("SELECT_PARENT_CMD"));
-    } else {  // If feature is 0 the it means that selected root object (document)
-      theMenu->addAction(aActivatePartSetAction);
-      aActivatePartSetAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
     }
-  } else if (aSelected == 0) {
-    // if there is no selection then it means that upper label is selected
-    QModelIndexList aIndexes = myWorkshop->selection()->selectedIndexes();
-    if (aIndexes.size() == 0) // it means that selection happens in top label outside of tree view
-      theMenu->addAction(aActivatePartSetAction);
-      aActivatePartSetAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
   }
   bool aNotDeactivate = (aCurrentOp == 0);
   if (!aNotDeactivate) {
     aActivatePartAction->setEnabled(false);
-    aActivatePartSetAction->setEnabled(false);
   }
 }
 
index 6f79f809283059866917d0d294430681e317cf8e..0287c2b5b4c287e0facbf4d5c5e23068137ec31c 100644 (file)
@@ -263,6 +263,8 @@ protected slots:
 
    void onTreeViewDoubleClick(const QModelIndex&);
 
+   void onActiveDocPopup(const QPoint&);
+
  private:
   /// Breaks sequense of automatically resterted operations
   void breakOperationSequence();
index 56b242561a2a0fce35536fd9b55a2bc73c7225d8..10810ee789645f8621d16fe4fe662d96fbb4481a 100644 (file)
@@ -301,8 +301,8 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
           this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
 
-  connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this,
-          SLOT(onLabelContextMenuRequested(const QPoint&)));
+  //connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this,
+  //        SLOT(onLabelContextMenuRequested(const QPoint&)));
   connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
           SLOT(onContextMenuRequested(QContextMenuEvent*)));
 }