From: vsv Date: Mon, 7 Sep 2015 12:53:28 +0000 (+0300) Subject: Process "Move to the end" event X-Git-Tag: V_1.4.0_beta4~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac50f1ed10dc88778742c38e4b485f6d9ed3b125;p=modules%2Fshaper.git Process "Move to the end" event --- diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 31f8f893f..c08fd734b 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -207,24 +207,33 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } } } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) { - std::shared_ptr aUpdMsg = - std::dynamic_pointer_cast(theMessage); - std::set aObjects = aUpdMsg->objects(); - - std::set::const_iterator aIt; - std::string aObjType; - for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { - ObjectPtr aObject = (*aIt); - // We do not show objects which not has to be shown in object browser - if (!aObject->isInHistory()) - continue; - QModelIndex aIndex = objectIndex(aObject); - QModelIndex aParent = parent(aIndex); - int aChildNb = rowCount(aParent); - QModelIndex aStartIndex = index(0, 0, aParent); - QModelIndex aEndIndex = index(aChildNb - 1, 0, aParent); - emit dataChanged(aStartIndex, aEndIndex); + std::shared_ptr aUpdMsg = + std::dynamic_pointer_cast(theMessage); + DocumentPtr aDoc = aUpdMsg->document(); + std::string aGroup = aUpdMsg->group(); + + QModelIndex aParent; + int aSartId = 0; + if (aDoc == aRootDoc) { + // Update a group under root + if (aGroup == myXMLReader.rootType()) // Update objects under root + aSartId = foldersCount(); + else // Update objects in folder under root + aParent = createIndex(folderId(aGroup), 0, -1); + } else { + // Update a sub-document + if (aGroup == myXMLReader.subType()) { + // Update sub-document root + aParent = findDocumentRootIndex(aDoc.get()); + aSartId = foldersCount(aDoc.get()); + } else + // update folder in sub-document + aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get()); } + int aChildNb = rowCount(aParent); + // Rebuild all indexes + removeRows(aSartId, aChildNb - aSartId, aParent); + insertRows(aSartId, aChildNb - aSartId, aParent); } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) { DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument(); if (aDoc != aRootDoc) {