On Mon, Sep 19, 2011 at 2:42 AM, Sebastian Trüg <[email protected]> wrote:
> On 09/18/2011 10:00 PM, Vishesh Handa wrote: > > > > On Mon, Sep 19, 2011 at 12:52 AM, Sebastian Trüg <[email protected] > > <mailto:[email protected]>> wrote: > > > > On 09/18/2011 07:36 PM, Vishesh Handa wrote: > > > Hey Sebastian > > > > > > I was working on my note taking application, and I want all the > > > resources which are notes. So, I did this - > > > > > > Nepomuk::Query::ResourceTypeTerm typeTerm( Nepomuk::Types::Class( > > > PIMO::Note() ) ); > > > Nepomuk::Query::Query query( typeTerm ); > > > > > > which was fine. Then I realized that I wanted the notes to be > sorted > > > according to the last modification date. > > > > > > Currently, I'm doing this - > > > > > > Nepomuk::Query::ResourceTypeTerm typeTerm( > Nepomuk::Types::Class( > > > PIMO::Note() ) ); > > > Nepomuk::Query::Query query( typeTerm ); > > > > > > Nepomuk::Query::Query::RequestProperty rp( > > NAO::lastModified(), false ); > > > query.addRequestProperty( rp ); > > > > > > QString sparql = query.toSparqlQuery() + " order by > > desc(?reqProp1)"; > > > > Ahhhhhh, my eyes, I think I am blind!!!!!! :P > > > > > > :D > > > > > > > > This is what you do: > > > > ComparisonTerm term(NAO::lastModified(), Term()); > > term.setSortWeight(1, Qt::DescendingOrder); > > Query query = ResourceTypeTerm(PIMO::Note()) && term; > > > > > > Now, why would anybody in their right mind think of using a > > ComparisonTerm, when one is not comparing anything? > > Yeah, ComparisionTerm started out for plain comparision but turned out > into the general purpose term for anything that includes a property.... > maybe a new name for 5.0? > Yes, please. Any ideas for a new name? While we're on the subject of 5.0, maybe we could make the term in ComparisonTerm (const Types::Property &property, const Term &term, Comparator comparator=Contains) optional. > > > It would be so much easier to have something like - > > > > Query q( term ); > > q.addSortProperty( NAO::lastModified(), Qt::DescendingOrder ); // the > > weight is optional > > You are right for this example. But think about sorting by some variable > somewhere down the graph. Artificial example: > > ComparisionTerm t1(NAO::lastModified(), Term()); > t1.setSortWeight(1); > ComparisionTerm t2(PIMO::isRelated(), t1); > Query q(t2); > > How would you express that with your API? We could of course add a > shortcut/convenience method which internally creates a ComparisionTerm > (actually that is what requestproperties are now)... > I wasn't proposing that we remove the ComparisionTerm::setSortWeight function. We need both. Your version of sorting using Comparison terms is very powerful. It just isn't convenient for simple use cases. > Cheers, > Sebastian > > > and if you want the value of the date simply add: > > term.setVariableName(QLatin1String("date")); > > > > and fetch it through Result::additionalBindings. > > > > Actually you can read it here: > > > http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/html/classNepomuk_1_1Query_1_1ComparisonTerm.html#_details > > > > Cheers, > > Sebastian > > > > > client->sparqlQuery( sparql ); > > > > > > Is it possible that you forgot to implement sorting in the query > lib? > > > Cause I can't seem to find how to do it. > > > > > > -- > > > Vishesh Handa > > > > > > > > > > -- > > Vishesh Handa > -- Vishesh Handa
_______________________________________________ Nepomuk mailing list [email protected] https://mail.kde.org/mailman/listinfo/nepomuk
