This is a multi-part message in MIME format. --===============1517607588== Content-Type: multipart/alternative; boundary="------------080101050207070207070907" This is a multi-part message in MIME format. --------------080101050207070207070907 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Andreas Pakulat wrote: > On 20.11.06 10:51:05, Matt Chambers wrote: > >> Andreas Pakulat wrotee >> >>>> I can detect if one of these elements is not in the new ElementTree, but, how >>>> do I get the info needed >>>> to call beginRemoveRows( QModelIndex parent, int row, int col). I can get >>>> the row,col no problem, >>>> but how can I get the deleted items parent QModelIndex? >>>> >>>> >>> Well, you have to have some mapping from Element back to a proper index, >>> i.e. you need a way to get the index for an Element in the tree. Then >>> you can call parent() on that index. >>> >> I remember reading something about how the indexes are temporary. I was under >> the impression >> that they would go away and be re-created as needed? >> > > Yes and no. Yes the indexes are not meant to be "stored away", but they > are cached by Qt's view classes. > > What I meant to say, if you implement a function that removes elements > from your tree and doesn't take a QModelIndex to the parent of these > indexes (like the removeRows() function does) then you need a way to > calculate the index for this parent element. I guess the > element-to-be-removed has a function to retrieve the parent, so you can > calculate the row+col for that element too, if you can do it for the > to-be-removed-element. Then to get the parent index of the parent > element do the same. > > Andreas > Ahh, Ok, I got it thanks. Working like a charm now. Thanks! --------------080101050207070207070907 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Andreas Pakulat wrote:On 20.11.06 10:51:05, Matt Chambers wrote:Andreas Pakulat wroteeI can detect if one of these elements is not in the new ElementTree, but, how do I get the info needed to call beginRemoveRows( QModelIndex parent, int row, int col). I can get the row,col no problem, but how can I get the deleted items parent QModelIndex?Well, you have to have some mapping from Element back to a proper index, i.e. you need a way to get the index for an Element in the tree. Then you can call parent() on that index.I remember reading something about how the indexes are temporary. I was under the impression that they would go away and be re-created as needed?Yes and no. Yes the indexes are not meant to be "stored away", but they are cached by Qt's view classes. What I meant to say, if you implement a function that removes elements from your tree and doesn't take a QModelIndex to the parent of these indexes (like the removeRows() function does) then you need a way to calculate the index for this parent element. I guess the element-to-be-removed has a function to retrieve the parent, so you can calculate the row+col for that element too, if you can do it for the to-be-removed-element. Then to get the parent index of the parent element do the same. Andreas