| View previous topic :: View next topic |
| Author |
Message |
stefan
Joined: 17 Apr 2006 Posts: 35 Location: Germany
|
Posted: Mon Feb 05, 2007 11:33 pm Post subject: getting sorted list from treemodelsort |
|
|
hi there,
i have set up an GtkListstore and attached this to a TreeModelSort.
After sorting the TreeModelSort within my app, i want to retrieve the sorted list to use it in another place.
So first i trying something like:
| Code: | | $list = $modelsort->get_model()->get_model(); |
BUT, since the treemodelsort does not change the underlying model, I've got back my original model. So how can i retrieve the values of the sorted model???
please help, this mmust be done till tommorrow and i've no clue what to do...
stefan |
|
| Back to top |
|
 |
kksou
Joined: 06 Sep 2006 Posts: 25
|
|
| Back to top |
|
 |
stefan
Joined: 17 Apr 2006 Posts: 35 Location: Germany
|
Posted: Tue Feb 06, 2007 4:55 pm Post subject: |
|
|
Hi, thanks for your reply, but setting up the ModelSort is not the problem. I've done that so far (with a little help of your cookbook by the way
My point is, that i have this ModelSort and it will be shown in my app. Now the user can make some changes like sort the list by some parameters and THEN i'd like to get this sorted list back and replace the original model by the sortmodel to use it in other places of my app.
So, if you've got any ideas, your more than welcome...
stefan |
|
| Back to top |
|
 |
kksou
Joined: 06 Sep 2006 Posts: 25
|
Posted: Thu Feb 08, 2007 6:54 pm Post subject: |
|
|
Have created another sample code for you:
http://www.kksou.com/php-gtk2/articles/retrieve-sorted-model-in-treeview---Part-1.php
Hope this is closer to what you have in mind.
In the example, I've only output the sorted model to the command window.
In your application, you can copy the values to another model or save the data to database, etc.
One things to note: the GtkTreeModelSort does not actually hold the data. It uses the data from the underlying GtkTreeModel. So I would suggest you do not replace the original model. If you really need to replace the original model, then you might want to store the data somewhere first (e.g. in an array), clear the model, then populates the original model with the sorted data.
Regards,
/kksou |
|
| Back to top |
|
 |
|