From deaa01144bf5597e7700845a25e3d9bd384e347a Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 14 Apr 2014 09:37:54 +0400 Subject: [PATCH] Update tree debug --- src/XGUI/XGUI_DocumentDataModel.cpp | 18 +++++++++++++----- src/XGUI/XGUI_Workshop.cpp | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index cb765c74f..f73c58ce1 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -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)); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 0aac474da..35cf57e53 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -10,6 +10,7 @@ #include "XGUI_Viewer.h" #include "XGUI_WidgetFactory.h" #include "XGUI_SelectionMgr.h" +#include "XGUI_ObjectsBrowser.h" #include #include @@ -288,6 +289,7 @@ void XGUI_Workshop::onSaveAs() //****************************************************** void XGUI_Workshop::onUndo() { + myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex()); std::shared_ptr aMgr = ModelAPI_PluginManager::get(); std::shared_ptr aDoc = aMgr->rootDocument(); aDoc->undo(); @@ -297,6 +299,7 @@ void XGUI_Workshop::onUndo() //****************************************************** void XGUI_Workshop::onRedo() { + myMainWindow->objectBrowser()->setCurrentIndex(QModelIndex()); std::shared_ptr aMgr = ModelAPI_PluginManager::get(); std::shared_ptr aDoc = aMgr->rootDocument(); aDoc->redo(); -- 2.39.2