gnope php gtk gui gnope.org  

getting sorted list from treemodelsort

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
stefan



Joined: 17 Apr 2006
Posts: 35
Location: Germany

PostPosted: Mon Feb 05, 2007 11:33 pm    Post subject: getting sorted list from treemodelsort Reply with quote

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

PostPosted: Tue Feb 06, 2007 10:33 am    Post subject: Reply with quote

$model = new GtkListStore(...)
$modelsort = new GtkTreeModelSort($model);
$view = new GtkTreeView($modelsort);

The sorted list is in $modelsort.

There's a sample code at:

http://www.kksou.com/php-gtk2/articles/sort-treeview-using-GtkTreeModelSort.php

Regards,
/kksou
Back to top
stefan



Joined: 17 Apr 2006
Posts: 35
Location: Germany

PostPosted: Tue Feb 06, 2007 4:55 pm    Post subject: Reply with quote

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 Wink

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

PostPosted: Thu Feb 08, 2007 6:54 pm    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.