-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "XGUI_DataModel.h"
#include <cassert>
+#ifdef _MSC_VER
+#pragma warning(disable: 4100)
+#endif
+
// Constructor *************************************************
for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) {
if ((*aIt)->isInHistory())
aCreated.append(*aIt);
+ if ((*aIt)->groupName() == ModelAPI_ResultPart::group()) {
+ emit beforeTreeRebuild();
+ myRoot->update();
+ rebuildDataTree();
+ emit treeRebuilt();
+ return;
+ }
}
+ if (aCreated.length() == 0)
+ return;
+
+ emit beforeTreeRebuild();
QTreeNodesList aNodes = myRoot->objectCreated(aCreated);
ModuleBase_ITreeNode* aParent;
int aRow = 0;
QModelIndex aParentIndex1, aParentIndex2;
ObjectPtr aObj;
+ bool aRebuildAll = false;
+
foreach(ModuleBase_ITreeNode* aNode, aNodes) {
aObj = aNode->object();
aParent = aNode->parent();
if (aObj.get() && (aObj->groupName() == ModelAPI_Folder::group())) {
aParent->update();
- rebuildDataTree();
+ aRebuildAll = true;
}
else {
aRow = aParent->nodeRow(aNode);
dataChanged(aParentIndex1, aParentIndex2);
}
}
+ if (aRebuildAll)
+ rebuildDataTree();
+
+ emit treeRebuilt();
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED)) {
std::shared_ptr<ModelAPI_ObjectDeletedMessage> aUpdMsg =
aUpdMsg->groups();
QTreeNodesList aList;
std::list<std::pair<std::shared_ptr<ModelAPI_Document>, std::string>>::const_iterator aIt;
+ emit beforeTreeRebuild();
for (aIt = aMsgGroups.cbegin(); aIt != aMsgGroups.cend(); aIt++) {
aList.append(myRoot->objectsDeleted(aIt->first, aIt->second.c_str()));
}
aNode->parent()->update();
}
rebuildDataTree();
+ emit treeRebuilt();
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
QObjectPtrList aCreated;
std::set<ObjectPtr>::const_iterator aIt;
bool aRebuildAll = false;
+ emit beforeTreeRebuild();
for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) {
ObjectPtr aObj = (*aIt);
if (!aObj->isInHistory())
}
if (aRebuildAll) {
myRoot->update();
- rebuildDataTree();
}
else {
- QTreeNodesList aParents;
+ QSet<ModuleBase_ITreeNode*> aParents;
foreach(ObjectPtr aObj, aCreated) {
ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj);
if (aNode) {
- if (aNode->parent())
- aNode = aNode->parent();
- if (!aParents.contains(aNode))
- aParents.append(aNode);
+ if (aNode->parent()) {
+ if (aNode->parent() == myRoot) {
+ aParents.clear();
+ aParents.insert(myRoot);
+ break;
+ }
+ else {
+ aNode = aNode->parent();
+ }
+ }
+ aParents.insert(aNode);
}
}
foreach(ModuleBase_ITreeNode* aNode, aParents) {
aNode->update();
}
- rebuildDataTree();
}
+ rebuildDataTree();
+ emit treeRebuilt();
}
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) {
std::shared_ptr<ModelAPI_OrderUpdatedMessage> aUpdMsg =
std::string aGroup = aUpdMsg->reordered()->group();
ModuleBase_ITreeNode* aNode = myRoot->findParent(aDoc, aGroup.c_str());
if (aNode) {
+ emit beforeTreeRebuild();
aNode->update();
rebuildDataTree();
+ emit treeRebuilt();
}
}
}
QObjectPtrList aCreated;
std::set<ObjectPtr>::const_iterator aIt;
- bool aRebuildAll = false;
for (aIt = aObjects.cbegin(); aIt != aObjects.cend(); aIt++) {
ObjectPtr aObj = (*aIt);
if (aObj->groupName() == ModelAPI_ResultField::group()) {
aCreated.append(aObj);
}
}
+ if (aCreated.length() == 0)
+ return;
+ emit beforeTreeRebuild();
foreach(ObjectPtr aObj, aCreated) {
ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj);
if (aNode) {
dataChanged(aFirstIdx, aLastIdx);
}
}
+ emit treeRebuilt();
}
}
{
beginResetModel();
endResetModel();
- emit treeRebuilt();
}
//******************************************************
ModuleBase_ITreeNode* aNode = (ModuleBase_ITreeNode*)theIndex.internalPointer();
return aNode->document();
}
+
+
+//******************************************************
+bool XGUI_DataModel::hasNode(ModuleBase_ITreeNode* theNode) const
+{
+ return myRoot->hasSubNode(theNode);
+}