}
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;
+ bool isInserted = 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);
aParentIndex2 = getParentIndex(aNode, 2);
insertRows(aRow, 1, aParentIndex1);
dataChanged(aParentIndex1, aParentIndex2);
+ isInserted = true;
}
}
+ if (aRebuildAll)
+ rebuildDataTree();
+ else if (isInserted)
+ endInsertRows();
+
+ 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 {
QSet<ModuleBase_ITreeNode*> aParents;
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();
}
}
}
aCreated.append(aObj);
}
}
+ if (aCreated.length() == 0)
+ return;
+ bool isInsert = false;
+ bool isRemove = false;
+ emit beforeTreeRebuild();
foreach(ObjectPtr aObj, aCreated) {
ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj);
if (aNode) {
if (aNewNb > aOldNb) {
insertRows(aOldNb - 1, aNewNb - aOldNb, aFirstIdx);
+ isInsert = true;
}
else if (aNewNb < aOldNb) {
if (aNewNb)
removeRows(aNewNb - 1, aOldNb - aNewNb, aFirstIdx);
else if (aOldNb)
removeRows(0, aOldNb, aFirstIdx);
+ isRemove = aNewNb || aOldNb;
}
dataChanged(aFirstIdx, aLastIdx);
}
}
+ if (isRemove)
+ endRemoveRows();
+ if (isInsert)
+ endInsertRows();
+ emit treeRebuilt();
}
}
{
beginResetModel();
endResetModel();
- emit treeRebuilt();
}
//******************************************************
bool XGUI_DataModel::insertRows(int theRow, int theCount, const QModelIndex& theParent)
{
beginInsertRows(theParent, theRow, theRow + theCount - 1);
- endInsertRows();
return true;
}
bool XGUI_DataModel::removeRows(int theRow, int theCount, const QModelIndex& theParent)
{
beginRemoveRows(theParent, theRow, theRow + theCount - 1);
- endRemoveRows();
return true;
}