Re: 'reloading' gtktreeview when model changes drastically



On Thu, 2007-06-14 at 21:54 +0200, gtk zevv nl wrote:

> Hello all,
> 
> I have implemented my own GtkTreeModel to query a custom database over
> the network.

Me too :) If you're interested in some nice Gtk2-Perl objects that
automate this sort of thing, check out my projects: Gtk2::Ex::DBI,
Gtk2::Ex::Datasheet::DBI ( and PDF::ReportWriter for reports ). They're
available on my website, http://entropy.homelinux.org/axis ... but
unfortunately there's no power to our apartment at the moment ( damned
thing caught on fire ), so you'll have to wait about 12 hours until the
power comes back up and I boot up the server.

>  The data model often changes drastically, a lot of rows and
> subtrees are modified, deleted, created, etc.

If you change the model significantly, you want to do one of 2 things. 

Option 1 ) Create a new model, populate it, and then use
gtk_tree_view_set_model to tell the treeview about the new model, and
dump the old one.

Option 2 ) use gtk_tree_view_set_model to point the treeview at another
( empty ) model ( or maybe NO model ... I'm not sure if you can do this,
I've never tried it ). Then do your changes to the real model. Then use
gtk_tree_view_set_model once more to point the treeview back at the real
model.

The idea with both of these approaches is that when you do lots of
changes to the model, it forces the treeview to keep updating, and this
is slow. It's best to do all your changes with the treeview
*disconnected* from the model, and then connect it back. Works for me
anyway.

--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au




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