KDirModel with Node for top level URL

Sebastian TrĂ¼g strueg at mandriva.com
Sat Mar 8 20:10:31 GMT 2008

If I understand correctly I have the IMHO perfect solution for you: For K3b I 
write the K3bMetaItemModel which wraps an arbitrary number of models in one 
tree. I use it to have multiple root nodes like "home dir", "/", or the 
mounted drives.
Have a look here:


and here:


I hope this helps. I also think that the MetaModel would fit well into 


On Saturday 08 March 2008 15:55:26 Christian Loose wrote:
> Hello everybody,
> I'm trying to use KDirModel for the file view in Cervisia. It worked pretty
> well so far but there is one thing I need and I can't get it to work. I
> need a tree node for the top level URL like
> "/home/cloose/cvs-src/kde-head/kdepim/kmail" in the following screenshot:
> http://cervisia.kde.org/images/screenshots/HEAD/mainview.png.
> David suggested a few solutions on kfm-devel:
> > * a "show root node" mode in KDirModel itself, but I'm afraid of the code
> > complexity if it has to follow one of two logics... Sounds like ugly
> > mixed code in the end. * a proxy that "adds" the toplevel node.
> >   Note that it still needs to do the usual proxy stuff (converting
> > indexes), on top of which it needs to present a model with one additional
> > node at the toplevel. Has to be done with QAbstractProxyModel, but note
> > that you need to implement many methods from the base class, not just
> > those that appear in the QAbstractProxyModel docu. * I also thought of a
> > filter proxy model that would remove "all but the wanted root node" but
> > this requires listing the parent url of the one we wanted to list in the
> > first place (can lead to strange code in the application) and this would
> > prevent having "/" as the root node.
> We wonder now who else could have similar needs? What approach would you
> prefer?
> From Bug #153878 it seems that at least Dolphin could use a similar feature
> for its folder panel.
> Bye,
> Christian

More information about the kde-core-devel mailing list