X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_DataModel.cpp;h=426779d2716290cdc938c80af61a7e325fe7fd81;hb=59a007784d1e103bcb352c515eb6feafa170f1ff;hp=704fd0738e75187c4a49f7ef50e1c35d4eb8747f;hpb=fc787375f074af74e17464b400cc59797590e52b;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 704fd0738..426779d27 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -58,7 +58,7 @@ ModelAPI_Document* getSubDocument(void* theObj) // Constructor ************************************************* -XGUI_DataModel::XGUI_DataModel(QObject* theParent) : ModuleBase_IDocumentDataModel(theParent) +XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParent) { myXMLReader.readAll(); @@ -259,17 +259,20 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get()); } int aChildNb = rowCount(aParent); - rebuildBranch(aStartId, aChildNb - aStartId); + rebuildBranch(aStartId, aChildNb - aStartId, aParent); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) { DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument(); if (aDoc != aRootDoc) { QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get()); if (aDocRoot.isValid()) emit dataChanged(aDocRoot, aDocRoot); -#ifdef _DEBUG - else - Events_Error::send("Problem with Data Model definition of sub-document"); -#endif + else + // We have got a new document + rebuildDataTree(); +//#ifdef _DEBUG +// else +// Events_Error::send("Problem with Data Model definition of sub-document"); +//#endif } } } @@ -283,7 +286,8 @@ void XGUI_DataModel::clear() //****************************************************** void XGUI_DataModel::rebuildDataTree() { - + beginResetModel(); + endResetModel(); } //****************************************************** @@ -371,13 +375,13 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const case Qt::DecorationRole: return QIcon(myXMLReader.rootFolderIcon(theIndexRow).c_str()); case Qt::ForegroundRole: - if ((flags(theIndex) & Qt::ItemIsEditable) == 0) + if ((theIndex.flags() & Qt::ItemIsEditable) == 0) return QBrush(Qt::lightGray); return ACTIVE_COLOR; } } else { // an object or sub-document if (theRole == Qt::ForegroundRole) { - if ((flags(theIndex) & Qt::ItemIsEditable) == 0) + if ((theIndex.flags() & Qt::ItemIsEditable) == 0) return QBrush(Qt::lightGray); return ACTIVE_COLOR; } @@ -731,7 +735,7 @@ Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const } else if (aDoc) { // A folder under sub-document if (aActiveDoc.get() != aDoc) - return aDefaultFlag; + return aNullFlag; } return aEditingFlag; }