QModelIndex aParentIndex1, aParentIndex2;
ObjectPtr aObj;
bool aRebuildAll = false;
- bool isInserted = false;
foreach(ModuleBase_ITreeNode* aNode, aNodes) {
aObj = aNode->object();
aParentIndex2 = getParentIndex(aNode, 2);
insertRows(aRow, 1, aParentIndex1);
dataChanged(aParentIndex1, aParentIndex2);
- isInserted = true;
}
}
if (aRebuildAll)
rebuildDataTree();
- else if (isInserted)
- endInsertRows();
emit treeRebuilt();
}
}
if (aCreated.length() == 0)
return;
- bool isInsert = false;
- bool isRemove = false;
emit beforeTreeRebuild();
foreach(ObjectPtr aObj, aCreated) {
ModuleBase_ITreeNode* aNode = myRoot->subNode(aObj);
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();
}
}
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;
}