Hi,<br><br><div class="gmail_quote">On Fri, Nov 16, 2012 at 8:11 PM, Marco Martin <span dir="ltr"><<a href="mailto:notmart@gmail.com" target="_blank">notmart@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I am doing a big refactor for the metadata models in plasma active, used to do<br>
nepomuk queries.<br>
<br>
this made me think about some things:<br>
* we all agree we want to use nepomuk more </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* we also want to use more qml to write user interfaces<br>
* to display nepomuk data in qml, basically means: to have a model that shows<br>
results from a query<br>
* i would really like to avoid both exposing sparql to qml and doing some<br>
weird javascript binding of the nepomuk query api, this is really stuff that<br>
who writes QML should *not* see<br>
<br>
now, both writing qabstractitemmodels and nepomuk query and result display are<br>
two things that besides requiring quite some boilerplate are quite easy to<br>
screw up.<br>
<br>
We already had a model, but since its query generation capabilities were quite<br>
basic, i already seen it forked somewhere else, duplicating all the bugs it<br>
had (hello mediacenter :p)<br></blockquote><div><br>wrong, its not a fork, its just a small and media specific model (nothing when compared to PA's metadatamodel) that does nepomuk queries and stores the results in a list. Its only called metadatamodel as the name is pretty nice ;)<br>
<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
in the end what a model do, is basically map from the list of<br>
Nepomuk2::Query::Result that arrived to rows of the model, and format the data<br>
in a particular way depending from the role asked.<br>
<br>
right now the MetadataModel, in the branch mart/newMetadataModel of plasma-<br>
mobile is done this way:<br>
<br>
The model manages the query in a thread, splitting it in chunks (with limit)<br>
to be able to have lazy loading<br>
<br>
Everything specific is delegated to another class, QueryProviders, which base<br>
api is inplasma-<br>
mobile/components/metadatamodel/queryproviders/abstractqueryprovider.h<br>
it does the following things:<br>
<br>
* it sets a query, either Nepomuk2::Query::Query or sparql<br>
<br>
* it sets the mapping between role  indexes and role names<br>
<br>
* given a Query::Result and a role it formats it to the data to display<br>
<br>
<br>
this class is abstract, doesn't do anything, but is intended to be in a public<br>
library, to be subclassed, so in qml one can do, after registering from the<br>
c++ part the MyQueryProvider implementation:<br></blockquote><div><br>This is a nice idea, flexibility++ <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
MetadataModel {<br>
        queryProvider: MyQueryProvider {<br>
                //setting of custom properties that control the query<br>
        }<br>
        delegate: ...<br>
}<br></blockquote><div><br>I hope one can also say this-<br><br>MetadataModel *model = new MetadataModel();<br>model->setQueryProvider(new MyQueryProvider());<br> <br>i.e. to be able to use it from C++.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
it provides some default subclasses that have the functionality of the old<br>
multiple models in plasma active,<br>
simple query for resources (ie i want all resources that are images linked to<br>
a certain activity, with a certain mimetype)<br>
tagcloud type of model (either cloud of tags or any other property like file<br>
types, basically a simple group by, very useful for visualizations<br>
timeline: how many resources satisfy a criteria separed by year, month or day<br>
<br>
right now the work in that branch is around at 90% complete i think, still<br>
some things to decide like wether export in the library all the current<br>
queryprovider subclasses or how to nicely map to qml things like resource<br>
types (now there are some heuristics that go from/to things like nfo:Audio and<br>
the full uri)<br>
<br>
<br>
i would really love to have this in a place public for everyone, to be clear<br>
that for 99% of the needs of nepomuk in qml, use that. There still can be use<br>
cases for different reimplemented bindings, but if is just a simple listing of<br>
stuff, no need to duplicate bugs ;)<br>
<br>
It may be nepomuk-core? (since it has a library, so unsuited for kde-runtime)<br></blockquote><div><br>Yes please, if this can go into nepomuk-core (however that will mean no dependencies on Qt Declarative, not sure how thats gonna be handled), it will be very easy for standalone applications like Plasma Media Center to use it. <br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
anyways, as general concept.. opinions/comments?<br></blockquote><div><br>The design, esp the QueryProvider bit is pretty nice, good job :)<br><br>From PMC's PoV, all we need is a metadatamodel which can be used and extended from pure C++ code[1]. From the design you discussed above, if metadatamodel lives in neopomuk-core and can be instantiated from C++, thumbs up!<br>
<br>[1] When this was not possible, we had to do stuff like this <a href="http://quickgit.kde.org/?p=plasma-mediacenter.git&a=blob&h=740d2423a8ff5b8a4b65b1dc371161e81f99e964&hb=fbac7a7a1a147deac287709ee0cb002e7f1053fb&f=browsingbackends%2Fmetadatabackends%2Fabstractmetadatabackend.cpp">http://quickgit.kde.org/?p=plasma-mediacenter.git&a=blob&h=740d2423a8ff5b8a4b65b1dc371161e81f99e964&hb=fbac7a7a1a147deac287709ee0cb002e7f1053fb&f=browsingbackends%2Fmetadatabackends%2Fabstractmetadatabackend.cpp</a> (line 36)<br>
If metadatamodel can be instantiated directly from C++, we won't need all this :)<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Marco Martin<br>
_______________________________________________<br>
Active mailing list<br>
<a href="mailto:Active@kde.org">Active@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/active" target="_blank">https://mail.kde.org/mailman/listinfo/active</a><br>
</blockquote></div><br>Cheers,<br clear="all"><br>-- <br>Shantanu Tushar    (UTC +0530)<br><a href="http://www.shantanutushar.com" target="_blank">http://www.shantanutushar.com</a><br>