Homerun sources and Plasma runners

Aurélien Gâteau agateau at kde.org
Thu Nov 22 08:21:55 UTC 2012


Le mercredi 21 novembre 2012 20:52:30 Marco Martin a écrit :
> On Wednesday 21 November 2012, Aurélien Gâteau wrote:
> > Trying to map the way sources work to runners, instead of having a runner
> > calling RunnerContext::addMatches(), a runner would have a createModel()
> > method which would be called by RunnerContext or RunnerManager to reach
> > the
> > runner data.
> > This gives runners the ability to use whatever model class is more
> > appropriate: a model inheriting QAbstractListModel, or a simple
> > QStandardItemModel, or maybe a proxy model on top of an existing model
> > provided by a library, etc.
> 
> why two runners should use a different model? their data structure is the
> same..

For very simple sources, for example the power source, it is easier to use a 
QStandardItemModel and add items to it, in the same way you can add matches to 
RunnerContext. For more complex sources, such as the Dir source, it is more 
appropriate to use a "real" model like KDirModel.

This gives you lots of flexibility while still exposing the same interface.

> aanyways, thinking about it, it probably make sense having different models
> for very different tasks (filesystem navigation should really be done by
> kdirmodel for instance, and the qml bindings for in in plasma-mobile are
> really just an handful of lines)
> 
> so basically a functionality set would be expressed by providing a different
> model component.
> search or simple results that can be expressed with a query -> krunner
> filesystem -> kdirmodel
> browsing applications-> some model based upon kservice
> 
> on all of them, an entry can be bookmarked if it provides a role with a
> valid url (to a file, a website, a folder, a desktop file, whatever)
> 
> that seems pretty expressive and just reuses existing technologies

Yes, that is what sources are doing, and what I would love runners to do. For 
example right now the "Favorite Places" source uses KFilePlacesModel, the 
"Dir" source uses KDirModel. They adapt the models to be "Homerun friendly": 
matching role names and adding a few Qt properties.

Aurélien


More information about the Plasma-devel mailing list