From: vsv Date: Wed, 28 Oct 2015 16:26:41 +0000 (+0300) Subject: activatePartSet pop-up menu has to be only on root label in object browser X-Git-Tag: V_2.0.0_alfa1~63 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6f45fd08debf5174c1c404bbe912f7a76c77bcd5;p=modules%2Fshaper.git activatePartSet pop-up menu has to be only on root label in object browser --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index b4f56d4a8..28013c9df 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ac927a6fc..15e86b4cd 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -891,7 +891,9 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) { XGUI_ObjectsBrowser* aOB = dynamic_cast(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(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(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); } } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 6f79f8092..0287c2b5b 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -263,6 +263,8 @@ protected slots: void onTreeViewDoubleClick(const QModelIndex&); + void onActiveDocPopup(const QPoint&); + private: /// Breaks sequense of automatically resterted operations void breakOperationSequence(); diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 56b242561..10810ee78 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -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*))); }