]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Apr 2014 06:42:33 +0000 (10:42 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 14 Apr 2014 06:42:33 +0000 (10:42 +0400)
src/XGUI/XGUI_DocumentDataModel.cpp
src/XGUI/XGUI_Workshop.cpp

index cb765c74f858d02792e95a2490bc1e9b30eafb46..f73c58ce1c253a75b589e41fb988fbeaf6341892 100644 (file)
@@ -149,9 +149,10 @@ QVariant XGUI_DocumentDataModel::headerData(int theSection, Qt::Orientation theO
 
 int XGUI_DocumentDataModel::rowCount(const QModelIndex& theParent) const
 {
-  if (!theParent.isValid()) 
+  if (!theParent.isValid()) {
+    int aVal = myModel->rowCount(theParent) + myPartModels.size();
     return myModel->rowCount(theParent) + myPartModels.size();
-
+  }
   QModelIndex aParent = toSourceModelIndex(theParent);
   return aParent.model()->rowCount(aParent);
 }
@@ -168,9 +169,15 @@ QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QMode
     int aOffs = myModel->rowCount();
     if (theRow < aOffs) 
       aIndex = myModel->index(theRow, theColumn, theParent);
-    else
-      aIndex = myPartModels.at(theRow - aOffs)->index(theRow - aOffs, theColumn, theParent);
-
+    else  {
+      if (myPartModels.size() > 0) {
+        int aPos = theRow - aOffs;
+        if (aPos >= myPartModels.size())
+          aPos = 0;
+        aIndex = myPartModels.at(aPos)->index(aPos, theColumn, theParent);
+      } else 
+        return aIndex;
+    }
     aIndex = createIndex(theRow, theColumn, (void*)getModelIndex(aIndex));
   } else {
     QModelIndex* aParent = (QModelIndex*)theParent.internalPointer();
@@ -185,6 +192,7 @@ QModelIndex XGUI_DocumentDataModel::index(int theRow, int theColumn, const QMode
 QModelIndex XGUI_DocumentDataModel::parent(const QModelIndex& theIndex) const
 {
   QModelIndex aParent = toSourceModelIndex(theIndex);
+  const QAbstractItemModel* a = aParent.model();
   aParent = aParent.model()->parent(aParent);
   if (aParent.isValid())
     return createIndex(aParent.row(), aParent.column(), (void*)getModelIndex(aParent));
index 02a02ec868276213c3114f6f0e49207787a96b63..4a5aa5c4e4605aca6b6b7d617ea94cc373769bc2 100644 (file)
@@ -10,6 +10,7 @@
 #include "XGUI_Viewer.h"
 #include "XGUI_WidgetFactory.h"
 #include "XGUI_SelectionMgr.h"
+#include "XGUI_ObjectsBrowser.h"
 
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Feature.h>
@@ -288,6 +289,7 @@ void XGUI_Workshop::onSaveAs()
 //******************************************************
 void XGUI_Workshop::onUndo()
 {
+  myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
   std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
   aDoc->undo();
@@ -297,6 +299,7 @@ void XGUI_Workshop::onUndo()
 //******************************************************
 void XGUI_Workshop::onRedo()
 {
+  myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex());
   std::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
   std::shared_ptr<ModelAPI_Document> aDoc = aMgr->rootDocument();
   aDoc->redo();