- //if (myIsEventsProcessingBlocked)
- // return;
- //DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument();
- //std::string aRootType = myXMLReader->rootType();
- //std::string aSubType = myXMLReader->subType();
- //int aNbFolders = foldersCount();
-
- //// Created object event *******************
- //if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
- // std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
- // std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- // std::set<ObjectPtr> aObjects = aUpdMsg->objects();
-
- // std::set<ObjectPtr>::const_iterator aIt;
- // std::string aObjType;
- // for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
- // ObjectPtr aObject = (*aIt);
- // // We do not show objects which does not need to be shown in object browser
- // if (!aObject->isInHistory())
- // continue;
-
- // aObjType = aObject->groupName();
- // DocumentPtr aDoc = aObject->document();
- // if (aDoc == aRootDoc) {
- // // Check that new folders could appear
- // QStringList aNotEmptyFolders = listOfShowNotEmptyFolders();
- // foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
- // if ((aNotEmptyFolder.toStdString() == aObjType) && (aRootDoc->size(aObjType) > 0)) {
- // // Appears first object in folder which can not be shown empty
- // if (!hasShownFolder(aRootDoc, aNotEmptyFolder)) {
- // insertRow(myXMLReader->rootFolderId(aObjType));
- // addShownFolder(aRootDoc, aNotEmptyFolder);
- // }
- // }
- // }
- // // Insert new object
- // int aRow = aRootDoc->size(aObjType) - 1;
- // if (aRow != -1) {
- // if ((aObjType == aRootType) || (aObjType == ModelAPI_Folder::group())) {
- // insertRow(aRow + aNbFolders + 1);
- // } else {
- // int aFolderId = myXMLReader->rootFolderId(aObjType);
- // if (aFolderId != -1) {
- // insertRow(aRow, createIndex(aFolderId, 0, (void*)Q_NULLPTR));
- // }
- // }
- // }
- // } else {
- // // Object created in sub-document
- // QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get(), 0);
- // if (aDocRoot.isValid()) {
- // // Check that new folders could appear
- // QStringList aNotEmptyFolders = listOfShowNotEmptyFolders(false);
- // foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
- // if ((aNotEmptyFolder.toStdString() == aObjType) && (aDoc->size(aObjType) > 0)) {
- // // Appears first object in folder which can not be shown empty
- // if (!hasShownFolder(aDoc, aNotEmptyFolder)) {
- // insertRow(myXMLReader->subFolderId(aObjType), aDocRoot);
- // addShownFolder(aDoc, aNotEmptyFolder);
- // }
- // }
- // }
- // int aRow = aDoc->index(aObject, true);
- // if (aRow != -1) {
- // int aNbSubFolders = foldersCount(aDoc.get());
- // if ((aObjType == aSubType) || (aObjType == ModelAPI_Folder::group())) {
- // // List of objects under document root
- // insertRow(aRow + aNbSubFolders, aDocRoot);
- // } else {
- // // List of objects under a folder
- // if (aRow != -1) {
- // int aFolderId = folderId(aObjType, aDoc.get());
- // if (aFolderId != -1) {
- // QModelIndex aParentFolder = createIndex(aFolderId, 0, aDoc.get());
- // insertRow(aRow, aParentFolder);
- // emit dataChanged(aParentFolder, aParentFolder);
- // }
- // }
- // }
- // } else {
- // rebuildDataTree();
- // break;
- // }
- // } else {
- // rebuildDataTree();
- // break;
- // }
- // }
- // }
- // // Deleted object event ***********************
- //} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
- // std::shared_ptr<ModelAPI_ObjectDeletedMessage> aUpdMsg =
- // std::dynamic_pointer_cast<ModelAPI_ObjectDeletedMessage>(theMessage);
- // DocumentPtr aDoc = aUpdMsg->document();
- // std::set<std::string> aMsgGroups = aUpdMsg->groups();
-
- // /// Sort groups because RootType deletion has to be done after others
- // std::string aType = (aDoc == aRootDoc)? aRootType : aSubType;
- // std::list<std::string> aGroups;
- // std::set<std::string>::const_iterator aSetIt;
- // for (aSetIt = aMsgGroups.begin(); aSetIt != aMsgGroups.end(); ++aSetIt) {
- // std::string aGroup = (*aSetIt);
- // if (aGroup == aType)
- // aGroups.push_back(aGroup);
- // else
- // aGroups.push_front(aGroup);
- // }