<br><div class="gmail_quote">On Mon, Sep 19, 2011 at 12:52 AM, Sebastian Trüg <span dir="ltr"><<a href="mailto:trueg@kde.org">trueg@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 09/18/2011 07:36 PM, Vishesh Handa wrote:<br>
> Hey Sebastian<br>
><br>
> I was working on my note taking application, and I want all the<br>
> resources which are notes. So, I did this -<br>
><br>
> Nepomuk::Query::ResourceTypeTerm typeTerm( Nepomuk::Types::Class(<br>
> PIMO::Note() ) );<br>
> Nepomuk::Query::Query query( typeTerm );<br>
><br>
> which was fine. Then I realized that I wanted the notes to be sorted<br>
> according to the last modification date.<br>
><br>
> Currently, I'm doing this -<br>
><br>
> Nepomuk::Query::ResourceTypeTerm typeTerm( Nepomuk::Types::Class(<br>
> PIMO::Note() ) );<br>
> Nepomuk::Query::Query query( typeTerm );<br>
><br>
> Nepomuk::Query::Query::RequestProperty rp( NAO::lastModified(), false );<br>
> query.addRequestProperty( rp );<br>
><br>
> QString sparql = query.toSparqlQuery() + " order by desc(?reqProp1)";<br>
<br>
</div>Ahhhhhh, my eyes, I think I am blind!!!!!! :P<br></blockquote><div><br>:D<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
This is what you do:<br>
<br>
ComparisonTerm term(NAO::lastModified(), Term());<br>
term.setSortWeight(1, Qt::DescendingOrder);<br>
Query query = ResourceTypeTerm(PIMO::Note()) && term;<br>
<br></blockquote><div><br>Now, why would anybody in their right mind think of using a ComparisonTerm, when one is not comparing anything?<br><br>It would be so much easier to have something like -<br><br>Query q( term );<br>
q.addSortProperty( NAO::lastModified(), Qt::DescendingOrder ); // the weight is optional<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
and if you want the value of the date simply add:<br>
term.setVariableName(QLatin1String("date"));<br>
<br>
and fetch it through Result::additionalBindings.<br>
<br>
Actually you can read it here:<br>
<a href="http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/html/classNepomuk_1_1Query_1_1ComparisonTerm.html#_details" target="_blank">http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/html/classNepomuk_1_1Query_1_1ComparisonTerm.html#_details</a><br>
<br>
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div><div></div><div class="h5"><br>
> client->sparqlQuery( sparql );<br>
><br>
> Is it possible that you forgot to implement sorting in the query lib?<br>
> Cause I can't seem to find how to do it.<br>
><br>
> --<br>
> Vishesh Handa<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font color="#999999">Vishesh Handa</font><br>