return;
// Remove extra sub-nodes
- QTreeNodesList aDelList;
int aIndex;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != aIndex))
- aDelList.append(aNode);
- }
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
+ if ((aIndex == -1) || (aId != aIndex)) {
+ myChildren.removeAll(aNode);
+ delete aNode;
+ } else
+ aId++;
}
// Add new nodes
if ((theGroup.toStdString() == groupName()) && (theDoc == aDoc)) {
QTreeNodesList aDelList;
int aIndex;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ bool aRemoved = false;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != aIndex))
- aDelList.append(aNode);
- }
- if (aDelList.size() > 0) {
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
+ if ((aIndex == -1) || (aId != aIndex)) {
myChildren.removeAll(aNode);
delete aNode;
- }
- aResult.append(this);
+ aRemoved = true;
+ } else
+ aId++;
}
+ if (aRemoved)
+ aResult.append(this);
}
return aResult;
}
bool isGroup = ((theGroup.toStdString() == ModelAPI_Feature::group()) ||
(theGroup.toStdString() == ModelAPI_Folder::group()));
if ((theDoc == aDoc) && isGroup) {
- QTreeNodesList aDelList;
int aIndex;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ bool aRemoved = false;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
if (aNode->object().get()) {
aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != (aIndex + aNb)))
- aDelList.append(aNode);
+ if ((aIndex == -1) || (aId != (aIndex + aNb))) {
+ myChildren.removeAll(aNode);
+ delete aNode;
+ aRemoved = true;
+ continue;
+ }
}
+ aId++;
}
- if (aDelList.size() > 0) {
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
- }
+ if (aRemoved)
aResult.append(this);
- }
}
return aResult;
}
int aNb = numberOfFolders();
// Remove extra sub-nodes
- QTreeNodesList aDelList;
int aIndex;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
if (aNode->object().get()) {
aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != (aIndex + aNb)))
- aDelList.append(aNode);
+ if ((aIndex == -1) || (aId != (aIndex + aNb))) {
+ myChildren.removeAll(aNode);
+ delete aNode;
+ continue;
+ }
}
- }
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
+ aId++;
}
// Add new nodes
int aRows = numberOfFolders();
// Remove extra sub-nodes
- QTreeNodesList aDelList;
int aIndex = -1;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
if (aNode->object().get()) {
aIndex = aDoc->index(aNode->object(), true);
- if ((aIndex == -1) || (aId != (aIndex + aRows)))
- aDelList.append(aNode);
+ if ((aIndex == -1) || (aId != (aIndex + aRows))) {
+ myChildren.removeAll(aNode);
+ delete aNode;
+ continue;
+ }
}
- }
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
+ aId++;
}
std::string aGroup = ModelAPI_Feature::group();
DocumentPtr aDoc = myObject->document();
// Delete obsolete nodes
- QTreeNodesList aDelList;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ int aId = 0;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(aId);
if ((aFirst + aId) < aDoc->size(ModelAPI_Feature::group(), true)) {
if (aNode->object() != aDoc->object(ModelAPI_Feature::group(), aFirst + aId)) {
- aDelList.append(aNode);
+ myChildren.removeAll(aNode);
+ delete aNode;
+ continue;
}
- } else {
- aDelList.append(aNode);
}
- }
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
+ aId++;
}
// Add new nodes
}
DocumentPtr aDoc = myObject->document();
// Delete obsolete nodes
- QTreeNodesList aDelList;
- int aId = -1;
- foreach(ModuleBase_ITreeNode* aNode, myChildren) {
- aId++;
+ bool aRemoved = false;
+ int aId = 0;
+ while (aId < myChildren.size()) {
+ ModuleBase_ITreeNode* aNode = myChildren.at(1);
if ((aFirst + aId) < aDoc->size(ModelAPI_Feature::group(), true)) {
if (aNode->object() != aDoc->object(ModelAPI_Feature::group(), aFirst + aId)) {
- aDelList.append(aNode);
+ myChildren.removeAll(aNode);
+ delete aNode;
+ aRemoved = true;
+ continue;
}
- } else {
- aDelList.append(aNode);
}
+ aId++;
}
- if (aDelList.size() > 0) {
+ if (aRemoved) {
aResult.append(this);
- foreach(ModuleBase_ITreeNode* aNode, aDelList) {
- myChildren.removeAll(aNode);
- delete aNode;
- }
}
return aResult;
}