From: vsv Date: Wed, 11 Nov 2015 09:22:42 +0000 (+0300) Subject: Issue #943: Process double clock on root label in ObjectBrowser X-Git-Tag: V_2.0.0_alfa2~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bcd129a37269cc48e354119fa98d527211101987;p=modules%2Fshaper.git Issue #943: Process double clock on root label in ObjectBrowser --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index b840d7b37..d2a2f4efe 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -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 diff --git a/src/PartSet/PartSet_MenuMgr.h b/src/PartSet/PartSet_MenuMgr.h index 738c6f365..0e8333caa 100644 --- a/src/PartSet/PartSet_MenuMgr.h +++ b/src/PartSet/PartSet_MenuMgr.h @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index abf7f605f..d52f41057 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -780,7 +780,8 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) { XGUI_ObjectsBrowser* aOB = dynamic_cast(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(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& theMess XGUI_ModuleConnector* aConnector = dynamic_cast(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(); diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 6612e3288..5171a65c1 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include @@ -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); diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index b80a51c12..b376969bc 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -11,7 +11,7 @@ #include #include -#include +#include 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();