]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Unselect root label in object browser on mouse click in Object browser
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 28 Oct 2015 16:47:13 +0000 (19:47 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 28 Oct 2015 16:47:13 +0000 (19:47 +0300)
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h

index 10810ee789645f8621d16fe4fe662d96fbb4481a..147d0c3beb9ccf86155b07d74647d85169a6e3d3 100644 (file)
@@ -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*)));
 }
index 48f97e2e4878f4edb05697f0e166e1a7de424321..8c33e24f9b8bc83f09ddcec3277a97f3ebc9294f 100644 (file)
@@ -40,6 +40,8 @@ public slots:
 protected:
   virtual void mouseReleaseEvent( QMouseEvent* e);
 
+  bool eventFilter(QObject* theObj, QEvent* theEvent);
+
 private:
   QString myPreSelectionStyle;
   QString myNeutralStyle;