Yeahhh! Find the way this morning :P
I slightly changed the order algorithm in this way:
@
function searchForChilds(itemId, startingFrom, currLevel) {
for(var i = startingFrom; i < xmlListModel.count; i++) {
var item = xmlListModel.get(i);
if(item.parentId === itemId) {
item.commentLevel = currLevel;
push(item);
searchForChilds(item.commentId, i + 1, currLevel + 1);
}
}
}
function reconstructCommentsTree() {
if(xmlListModel.count === 0)
return;
var item;// = xmlListModel.get(0);
for(var i = 0; i < xmlListModel.count; i++) {
item = xmlListModel.get(i);
if(item.parentId === 0) {
item.commentLevel = 0;
push(item);
searchForChilds(item.commentId, i + 1, 1);
}
}
}
@
In this way, i add the property commentLevel to the items of the outer listmodel, so that I can use this value in the delegate of the listview. ;)
hope this is not to much complex as an algorithm for a mobile device...