In this way works. Thank you so much Andreas, you've saved my life...<br><br><div><span class="gmail_quote">2006/9/8, Andreas Pakulat <<a href="mailto:apaku@gmx.de">apaku@gmx.de</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 08.09.06 16:29:32, Oscar Cossu wrote:<br>> def child(self, i):<br>> if self.childItems.has_key(i):<br>> return self.childItems[i]<br>><br>> if i >= 0 and i < self.domNode.childNodes
().count():<br>> childNode = self.domNode.childNodes().item(i)<br>> childItem = DomItem(childNode, i, self)<br>> self.childItems[i] = childItem<br>> return childItem
<br><br>I think the problem lies here, for caching you put the child nodes into<br>a dict, but in the removeRows function, you never update this dict. Now<br>when a row is removed the tree thinks there are only 2 childs left and
<br>thus always asks for items 0 and 1. Due to the dict still containing a<br>reference to the DomItem and the underlying QDomElement you return the<br>wrong element.<br><br>> def findNodeByTagNameID(self,tagName,id):
<br>> element = self.domDocument.elementsByTagName(tagName)<br>> for e in range(element.length()) :<br>> tmp=element.item(e).attributes().namedItem("id").nodeValue()<br>> if tmp==id:
<br>> return element.item(e)<br>><br>> return None<br>><br>> def removeRows(self,arow,count,parent):<br>> print "removeRow"<br>> self.beginRemoveRows
(parent,arow,arow+count-1)<br>> for ii in range(count):<br>> nodoIndex=self.index(arow+ii,0,parent)<br>> NomeNodo= nodoIndex.data().toString()<br>> IdNodo=self.index
(arow+ii,1,parent).data().toString()<br>><br>> if IdNodo.contains("id"):<br>> i=IdNodo.indexOf("id")<br>> i=IdNodo.indexOf("\"",i)
<br>> f=IdNodo.indexOf("\"",i+1)<br>> IdNodo=IdNodo.mid(i+1,f-i-1)<br>> else:<br>> return False<br>><br>> nodo=
self.findNodeByTagNameID(NomeNodo,IdNodo)<br>> nodo.parentNode().removeChild(nodo)<br><br>Why do you make it so complicated? You have a row and the parent. Just<br>use something like<br><br>parentdomitem = index(
parent.internalPointer().row(),0, parent.parent()).internalPointer()<br>childdomitem = parentdomitem.child(arow+ii)<br>childdomitem.node.parentNode().removeChild(childdomitem.node)<br>del parentdomitem.childItems[arow+ii]
<br><br>I think that should do it inside the for loop.<br><br>Andreas<br><br>--<br>Green light in A.M. for new projects. Red light in P.M. for traffic tickets.<br><br>_______________________________________________<br>PyKDE mailing list
<a href="mailto:PyKDE@mats.imk.fraunhofer.de">PyKDE@mats.imk.fraunhofer.de</a><br><a href="http://mats.imk.fraunhofer.de/mailman/listinfo/pykde">http://mats.imk.fraunhofer.de/mailman/listinfo/pykde</a><br></blockquote></div>
<br>