]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #565: Activate part on a double click
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 27 May 2015 09:48:58 +0000 (12:48 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 27 May 2015 09:48:58 +0000 (12:48 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h

index e0a753a4b2a806136ece3642a15cafde2c76653d..563bd786c90403d2532382d3908b3091f512820a 100644 (file)
@@ -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<Events_Message>& 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<Events_Message>& 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<ModelAPI_ResultPart>(aObj);
+  if (!aPart.get()) { // Probably this is Feature
+    FeaturePtr aPartFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
+    if (aPartFeature.get() && (aPartFeature->getKind() == PartSetPlugin_Part::ID())) {
+      aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(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
index cc5e97ae051b1f43a1ac92e79f39b935e37b7888..a215774c8f949f5073902f4c41349a159800148a 100644 (file)
@@ -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<ModelAPI_ResultPart> 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();