From: vsv Date: Wed, 27 May 2015 09:48:58 +0000 (+0300) Subject: Issue #565: Activate part on a double click X-Git-Tag: V_1.2.0~58 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8e8d48e125e279e6740287a99d7f41d07fd8b78e;p=modules%2Fshaper.git Issue #565: Activate part on a double click --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e0a753a4b..563bd786c 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -654,6 +654,9 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) QPalette aPalet = aLabel->palette(); aPalet.setColor(QPalette::Text, QColor(0, 72, 140)); aLabel->setPalette(aPalet); + aOB->treeView()->setExpandsOnDoubleClick(false); + connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), + SLOT(onTreeViewDoubleClick(const QModelIndex&))); connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), myDataModel, SLOT(onMouseDoubleClick(const QModelIndex&))); } @@ -730,7 +733,8 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess if (aPart->partDoc() == aActiveDoc) { QModelIndex aIndex = myDataModel->partIndex(aPart); if (myDataModel->activatePart(aIndex)) { - aTreeView->setExpanded(aOldIndex, false); + if (aOldIndex.isValid()) + aTreeView->setExpanded(aOldIndex, false); aTreeView->setExpanded(myDataModel->activePartTree(), true); aPalet.setColor(QPalette::Text, Qt::black); } @@ -749,3 +753,25 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess aDisplayer->updateViewer(); } } + +void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) +{ + if (theIndex.column() != 0) // Use only first column + return; + ObjectPtr aObj = myDataModel->object(theIndex); + ResultPartPtr aPart = std::dynamic_pointer_cast(aObj); + if (!aPart.get()) { // Probably this is Feature + FeaturePtr aPartFeature = std::dynamic_pointer_cast(aObj); + if (aPartFeature.get() && (aPartFeature->getKind() == PartSetPlugin_Part::ID())) { + aPart = std::dynamic_pointer_cast(aPartFeature->firstResult()); + } + } + if (aPart.get()) { // if this is a part + SessionPtr aMgr = ModelAPI_Session::get(); + if (aPart->partDoc() == aMgr->activeDocument()) { + aMgr->setActiveDocument(aMgr->moduleDocument()); + } else { + aPart->activate(); + } + } +} \ No newline at end of file diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index cc5e97ae0..a215774c8 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -173,10 +173,6 @@ protected slots: /// \param theOperation the operation virtual void sendOperation(ModuleBase_Operation* theOperation); - //! Activates or deactivates a part - //! If PartPtr is Null pointer then PartSet will be activated - //void activatePart(std::shared_ptr theFeature); - private slots: /// Processing of vertex selected void onVertexSelected(); @@ -185,6 +181,8 @@ protected slots: /// \param theTrsfType type of tranformation void onViewTransformed(int theTrsfType = 2); + void onTreeViewDoubleClick(const QModelIndex&); + private: /// Breaks sequense of automatically resterted operations void breakOperationSequence();