]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #943: Process double clock on root label in ObjectBrowser
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 11 Nov 2015 09:22:42 +0000 (12:22 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 11 Nov 2015 09:23:31 +0000 (12:23 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_MenuMgr.h
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_ObjectsBrowser.cpp
src/XGUI/XGUI_ObjectsBrowser.h

index b840d7b373f8a7b5d7aceeebcaec3ab49a5517a3..d2a2f4efec3e7a80509ad230b6df387ae52fbaca 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <QAction>
 #include <QMenu>
+#include <QEvent>
 
 #include <TopoDS.hxx>
 #include <BRep_Tool.hxx>
@@ -506,3 +507,13 @@ void PartSet_MenuMgr::onSelectParentFeature()
   aSelection.append( aParentFeature );
   myModule->workshop()->selection()->setSelectedObjects( aSelection );
 }
+
+bool PartSet_MenuMgr::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+  if (theEvent->type() == QEvent::MouseButtonDblClick) {
+    SessionPtr aMgr = ModelAPI_Session::get();
+    if (aMgr->activeDocument() != aMgr->moduleDocument())
+      activatePartSet();
+  }
+  return QObject::eventFilter(theObj, theEvent);
+}
\ No newline at end of file
index 738c6f3652e8e5f0605c711920d1fd34e2a180e1..0e8333caa4a968dcfc71cb0e26bc8dfd9875c361 100644 (file)
@@ -82,6 +82,9 @@ private slots:
 
   void onSelectParentFeature();
 
+protected:
+  bool eventFilter(QObject* theObj, QEvent* theEvent);
+
 private:
   /// Returns true if the current operation is sketch entity create operation
   /// \param theValue the current auxiliary value
index abf7f605ff13e08c8fbe16039be43cbad8414bb1..d52f41057c7be87ab608a9ebb8a13052552834c5 100755 (executable)
@@ -780,7 +780,8 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser)
 {
   XGUI_ObjectsBrowser* aOB = dynamic_cast<XGUI_ObjectsBrowser*>(theObjectBrowser);
   if (aOB) {
-    QLineEdit* aLabel = aOB->activeDocLabel();
+    QLabel* aLabel = aOB->activeDocLabel();
+    aLabel->installEventFilter(myMenuMgr);
     connect(aLabel, SIGNAL(customContextMenuRequested(const QPoint&)), 
           SLOT(onActiveDocPopup(const QPoint&)));
     //QPalette aPalet = aLabel->palette();
@@ -799,7 +800,7 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
 
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
   XGUI_Workshop* aWorkshop = aConnector->workshop();
-  QLineEdit* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
+  QLabel* aHeader = aWorkshop->objectBrowser()->activeDocLabel();
 
   aActivatePartAction->setEnabled((aMgr->activeDocument() != aMgr->moduleDocument()));
 
@@ -899,7 +900,7 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
     XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
     XGUI_Workshop* aWorkshop = aConnector->workshop();
     XGUI_DataTree* aTreeView = aWorkshop->objectBrowser()->treeView();
-    QLineEdit* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
+    QLabel* aLabel = aWorkshop->objectBrowser()->activeDocLabel();
     QPalette aPalet = aLabel->palette();
 
     SessionPtr aMgr = ModelAPI_Session::get();
index 6612e32887d3f2ecd7a218e001f20ce54a27b7d1..5171a65c15a3c5091770b28ca5a1a5108ba882eb 100644 (file)
@@ -13,7 +13,7 @@
 #include <ModuleBase_Tools.h>
 
 #include <QLayout>
-#include <QLabel>
+#include <QLineEdit>
 #include <QPixmap>
 #include <QEvent>
 #include <QMouseEvent>
@@ -223,7 +223,7 @@ void XGUI_TreeViewStyle::drawPrimitive(PrimitiveElement theElement,
 //********************************************************************
 //********************************************************************
 XGUI_ActiveDocLbl::XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent )
-  : QLineEdit(theText, theParent), 
+  : QLabel(theText, theParent), 
   myPreSelectionStyle(""), 
   myNeutralStyle(""), 
   mySelectionStyle(""),
@@ -238,21 +238,21 @@ void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
   QColor aHighlight = aPalet.highlight().color();
   QColor aHighlightText = aPalet.highlightedText().color();
 
-  myPreSelectionStyle = "QLineEdit {background-color: ";
+  myPreSelectionStyle = "QLabel {background-color: ";
   myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " + aHighlight.lighter(170).name() + ");"; 
   myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
 
   QString aName = aPalet.color(QPalette::Base).name();
-  myNeutralStyle = "QLineEdit { border: 1px solid " + aName + " }";
+  myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
 
 
 #if (!defined HAVE_SALOME) && (defined WIN32)
-  mySelectionStyle = "QLineEdit {background-color: ";
+  mySelectionStyle = "QLabel {background-color: ";
   mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
   mySelectionStyle += ", stop:1 rgb(208, 229, 255));"; 
   mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
 #else
-  mySelectionStyle = "QLineEdit {background-color: " + aHighlight.name();
+  mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
   mySelectionStyle += "; color : " + aHighlightText.name() + "}";
 #endif
 
@@ -273,7 +273,7 @@ bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
         setStyleSheet(myNeutralStyle);
       break;
   }
-  return QLineEdit::event(theEvent);
+  return QLabel::event(theEvent);
 }
 #endif
 
@@ -283,7 +283,7 @@ bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
     if (theEvent->type() == QEvent::MouseButtonRelease)
       unselect();
   }
-  return QLineEdit::eventFilter(theObj, theEvent);
+  return QLabel::eventFilter(theObj, theEvent);
 }
 
 static bool MYClearing = false;
@@ -295,7 +295,7 @@ void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
   // We can not block signals because on 
   // clear selection the View state will not be updated
   myTreeView->clearSelection();
-  QLineEdit::mouseReleaseEvent(e);
+  QLabel::mouseReleaseEvent(e);
   MYClearing = false;
 }
 
@@ -338,8 +338,8 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   DocumentPtr aDoc = aMgr->moduleDocument();
 
   myActiveDocLbl = new XGUI_ActiveDocLbl(tr("Part set"), aLabelWgt);
-  myActiveDocLbl->setReadOnly(true);
-  myActiveDocLbl->setFrame(false);
+//  myActiveDocLbl->setReadOnly(true);
+//  myActiveDocLbl->setFrame(false);
   myActiveDocLbl->setContextMenuPolicy(Qt::CustomContextMenu);
 
   aLabelLay->addWidget(myActiveDocLbl);
index b80a51c12ab388b54adfde507b0fe479417e606f..b376969bc4e0cc09003ba5dc2edd213332c6e097 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <QWidget>
 #include <QTreeView>
-#include <QLineEdit>
+#include <QLabel>
 
 class ModuleBase_IDocumentDataModel;
 class XGUI_DataModel;
@@ -20,7 +20,7 @@ class XGUI_DataModel;
 * \ingroup GUI
 * Implementation of root label in Object Browser
 */
-class XGUI_ActiveDocLbl: public QLineEdit
+class XGUI_ActiveDocLbl: public QLabel
 {
 Q_OBJECT
  public:
@@ -172,7 +172,7 @@ Q_OBJECT
   }
 
   /// Returns active doc label object
-  QLineEdit* activeDocLabel() const { return myActiveDocLbl; }
+  QLabel* activeDocLabel() const { return myActiveDocLbl; }
 
   /// Rebuild data tree
   void rebuildDataTree();