From: vsv Date: Wed, 28 Oct 2015 16:47:13 +0000 (+0300) Subject: Unselect root label in object browser on mouse click in Object browser X-Git-Tag: V_2.0.0_alfa1~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=61c3ceac672c271d8c1a104fe5c5281c66cacef4;p=modules%2Fshaper.git Unselect root label in object browser on mouse click in Object browser --- diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 10810ee78..147d0c3be 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -199,9 +199,7 @@ void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView) mySelectionStyle += ", stop:1 " + aHighlight.lighter().name() + ");"; mySelectionStyle += "border: 1px solid lightblue; border-radius: 2px }"; - connect(myTreeView->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), - SLOT(unselect())); + myTreeView->viewport()->installEventFilter(this); } @@ -220,6 +218,15 @@ bool XGUI_ActiveDocLbl::event(QEvent* theEvent) return QLineEdit::event(theEvent); } +bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent) +{ + if (theObj == myTreeView->viewport()) { + if (theEvent->type() == QEvent::MouseButtonRelease) + unselect(); + } + return QLineEdit::eventFilter(theObj, theEvent); +} + static bool MYClearing = false; void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e) { @@ -301,8 +308,6 @@ 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(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, SLOT(onContextMenuRequested(QContextMenuEvent*))); } diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 48f97e2e4..8c33e24f9 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -40,6 +40,8 @@ public slots: protected: virtual void mouseReleaseEvent( QMouseEvent* e); + bool eventFilter(QObject* theObj, QEvent* theEvent); + private: QString myPreSelectionStyle; QString myNeutralStyle;