From 61c3ceac672c271d8c1a104fe5c5281c66cacef4 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 28 Oct 2015 19:47:13 +0300 Subject: [PATCH] Unselect root label in object browser on mouse click in Object browser --- src/XGUI/XGUI_ObjectsBrowser.cpp | 15 ++++++++++----- src/XGUI/XGUI_ObjectsBrowser.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) 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; -- 2.39.2