Re: How to build a GtkTree?



Am Samstag 26 Mai 2007 schrieb David NeÄas:
You know it.  In the example it's either the same parent
iter as you used in the last insertion or it is the iter you
*obtained* in the last insertion.  If you want to go up
a level, use gtk_tree_model_iter_parent().

sure, I know the iter of the last insertion.
but what I really
Wwhat I need  is the iter to a given entry; to say it in sql-style:

  SELECT iter FROM tree WHERE content="someparententry";

How would you express content="someparententry"?

This is the data that's stored in one of the rows, and it can tell me where 
this entry belongs.
For example, if I have the data "album4.song2", then I know that this entry 
has to be stored as a child of the entry "album4".
But to insert this into the tree, I have to know the iter of the parent 
entry "album4", which I don't know.
The only way I could imagine to get this, is to walk the whole tree and check 
for the wanted parent entry, and that every time when I want to insert 
soemthing. But there must be a more efficient way to do this...

If you want to search the whole tree using some custom
condition, use gtk_tree_model_foreach().  That's not exactly
efficient to do repeatedly though.  If you can tell on each
tree level what to look for (i.e. you don't have to search
all leafs), you can easily walk through the tree and always
descend one level when you find what you are looking for on
that level -- AFAIK there's no function for that, it would
be probably equally complicated to use as walking though the
tree manually...

Ok, thanks. So I have it to do this way.
As this is done only one time at the start of the program, I hope it will not 
take to much time...







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]