Salome HOME
Issue #904 - Fatal error aftre delete sketch from dataset used in extrusion in part
[modules/shaper.git] / src / XGUI / XGUI_ObjectsBrowser.cpp
index acdd5e5fb4806d2b37b0190e62d802d55a60c197..c43ca86fa984f2763438d973f0266923fb7f1d79 100644 (file)
@@ -130,16 +130,17 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
 {
   if (theIndex.column() != 1)
     return;
+  SessionPtr aMgr = ModelAPI_Session::get();
+  // When operation is opened then we can not change history
+  if (aMgr->isOperation())
+    return;
   ModuleBase_IDocumentDataModel* aModel = dataModel();
   if (aModel->flags(theIndex) == 0)
     return;
   ObjectPtr aObj = aModel->object(theIndex);
 
-  SessionPtr aMgr = ModelAPI_Session::get();
   DocumentPtr aDoc = aMgr->activeDocument();
   
-  QModelIndex aOldIndex = aModel->lastHistoryIndex();
-
   std::string aOpName = tr("History change").toStdString();
   if (aObj.get()) {
     if (aObj->document() != aDoc)
@@ -162,13 +163,10 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
   }
   QModelIndex aNewIndex = aModel->lastHistoryIndex();
   QModelIndex aParent = theIndex.parent();
-  int aStartRow = std::min(aOldIndex.row(), aNewIndex.row());
-  int aEndRow = std::max(aOldIndex.row(), aNewIndex.row());
-  for (int i = aStartRow; i <= aEndRow; i++) {
+  int aSize = aModel->rowCount(aParent);
+  for (int i = 0; i < aSize; i++) {
     update(aModel->index(i, 0, aParent));
   }
-  update(aOldIndex);
-  update(aNewIndex);
 }
 
 //********************************************************************
@@ -221,16 +219,18 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   aLabelWgt->setFrameShape(myTreeView->frameShape());
   aLabelWgt->setFrameShadow(myTreeView->frameShadow());
 
+#ifndef ModuleDataModel
+  myDocModel = new XGUI_DataModel(this);
+  myTreeView->setModel(myDocModel);
+  QItemSelectionModel* aSelMod = myTreeView->selectionModel();
+  connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
+          this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
+#endif
+
   connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this,
           SLOT(onLabelContextMenuRequested(const QPoint&)));
   connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
           SLOT(onContextMenuRequested(QContextMenuEvent*)));
-
-  // Create internal actions
-  QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this);
-  aAction->setData("RENAME_CMD");
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEditItem()));
-  addAction(aAction);
 }
 
 //***************************************************
@@ -382,18 +382,17 @@ void XGUI_ObjectsBrowser::clearContent()
   myTreeView->clear(); 
 }
 
+#ifdef ModuleDataModel
 void XGUI_ObjectsBrowser::setDataModel(ModuleBase_IDocumentDataModel* theModel)
 {
-#ifdef ModuleDataModel
   myDocModel = theModel;
-#else
-  myDocModel = new XGUI_DataModel(this);
-#endif
+  //myDocModel = new XGUI_DataModel(this);
   myTreeView->setModel(myDocModel);
   QItemSelectionModel* aSelMod = myTreeView->selectionModel();
   connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
           this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
 }
+#endif
 
 void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
                                        const QItemSelection& theDeselected)