}
}
+ void sortChildren() {
+ if (myChildren.size() > 1) {
+ int i = 0;
+ ModuleBase_ITreeNode* aNode = 0;
+ ObjectPtr aObject;
+ int aIdx;
+ int aCount = 0;
+ int aSize = myChildren.size();
+ int aMaxCount = aSize * aSize;
+ int aShift = 0;
+ while (i < aSize) {
+ aCount++;
+ // To avoid unlimited cycling
+ if (aCount > aMaxCount)
+ break;
+
+ aNode = myChildren.at(i);
+ aObject = aNode->object();
+ if (aObject.get()) {
+ aIdx = aObject->document()->index(aObject, true) + aShift;
+ if (aIdx != i) {
+ myChildren.removeAll(aNode);
+ myChildren.insert(aIdx, aNode);
+ i = 0;
+ continue;
+ }
+ }
+ else
+ aShift++;
+ i++;
+ }
+ }
+ }
+
ModuleBase_ITreeNode* myParent; //!< Parent of the node
QTreeNodesList myChildren; //!< Children of the node
};