From: vsv Date: Wed, 27 May 2015 14:53:02 +0000 (+0300) Subject: Issue #565: Process double click on Object Browser header label X-Git-Tag: V_1.2.0~49 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0b64e548d2b27f6c0bfd5a52e20c1f157caa7464;p=modules%2Fshaper.git Issue #565: Process double click on Object Browser header label --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 563bd786c..7f95d0893 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -657,6 +657,8 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) aOB->treeView()->setExpandsOnDoubleClick(false); connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), SLOT(onTreeViewDoubleClick(const QModelIndex&))); + connect(aOB, SIGNAL(headerMouseDblClicked(const QModelIndex&)), + SLOT(onTreeViewDoubleClick(const QModelIndex&))); connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), myDataModel, SLOT(onMouseDoubleClick(const QModelIndex&))); } @@ -756,8 +758,14 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) { + SessionPtr aMgr = ModelAPI_Session::get(); + if (!theIndex.isValid()) { + aMgr->setActiveDocument(aMgr->moduleDocument()); + return; + } if (theIndex.column() != 0) // Use only first column return; + ObjectPtr aObj = myDataModel->object(theIndex); ResultPartPtr aPart = std::dynamic_pointer_cast(aObj); if (!aPart.get()) { // Probably this is Feature @@ -767,7 +775,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) } } if (aPart.get()) { // if this is a part - SessionPtr aMgr = ModelAPI_Session::get(); + if (aPart->partDoc() == aMgr->activeDocument()) { aMgr->setActiveDocument(aMgr->moduleDocument()); } else { diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index e8b0a1fed..81e5b9d4c 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -205,6 +205,11 @@ bool XGUI_ObjectsBrowser::eventFilter(QObject* obj, QEvent* theEvent) break; } } + } else { + if (theEvent->type() == QEvent::MouseButtonDblClick) { + emit headerMouseDblClicked(QModelIndex()); + return true; + } } } return QWidget::eventFilter(obj, theEvent); diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 530a86a51..ade333a35 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -111,6 +111,9 @@ signals: //! Emited on context menu request void contextMenuRequested(QContextMenuEvent* theEvent); + //! Segnal is emitted when user cliks by mouse in header label of object browser + void headerMouseDblClicked(const QModelIndex&); + protected: /// Redefinition of virtual method virtual bool eventFilter(QObject* obj, QEvent* theEvent);