Re: 'reloading' gtktreeview when model changes drastically

> > 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, ... 

That's a nice concept, but my database is not SQL based however. It's a
custom build thing with some SNMP/LDAP similarities, but very
lightweight for embedded devices.

> 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.

Yes, this of course makes much more sense then my current solution:
throwing away the treeview and creating a new one. For now your solution
is just what I'm looking for, thanks!



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