<br><br><div class="gmail_quote">On Thu, Sep 22, 2011 at 5:42 PM, 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;">
Hi Francois,<br>
<br>
Here is the C++ code which would do it:<br>
<br>
OrTerm mimeTypeTerm;<br>
foreach(QString mimeType, mimeTypes)<br>
   mimeTypeTerm.addSubTerm(ComparisonTerm(NIE::mimeType(), mimeType,<br>
         ComparisonTerm::Equal);<br>
<br>
FileQuery query(AndTerm(mimeTypeTerm, ResourceTypeTerm(NFO::Video());<br>
foreach(QString folder, myFolders)<br>
  query.addIncludeFolder(folder);<br></blockquote><div><br>You could also do a -<br><br>FileQuery query( mimeTypeTerm && ResourceTypeTerm(NFO::Video()) );<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>
That's it. If you want you can remove the ResourceTypeTerm just for testing.<br>
If this query does not work maybe your file indexer is disabled?<br>
<br>
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div><div></div><div class="h5"><br>
On 09/22/2011 11:13 AM, François K. wrote:<br>
> Hi !<br>
><br>
> I'm trying to understand how to build a simple query, using the query API.<br>
> My goal is pretty simple : I want to list all video files stored in some given directories that Phonon can play.<br>
><br>
> I tried several "things" without success which leads me to the asumption that I might have misunderstood something, hence my call for help :)<br>
><br>
> This is what I did in my last try :<br>
><br>
> STEP 1 :<br>
> * Create a new Nepomuk.Query.FileQuery<br>
> * Ask to look for files only via setFileMode(Nepomuk.Query.FileQuery.QueryFiles)<br>
> * Loop through my 'sources' and add them as sources via addIncludeFolder(source, True)<br>
><br>
> STEP 2 :<br>
> * Create a ResourceTypeTerm to get only Video files (NFO::Video())<br>
><br>
> STEP 3 :<br>
> * Get the list of video mimetypes that Phonon can play.<br>
> * Loop through this list, and build a ComparisonTerm for each playable mimetype :<br>
>     - The ComparisonTerm is made of the mimetype Property (NIE::mimeType()) and a LiteralTerm containing the current mimetype.<br>
> * Add all these ComparisonTerms in a OrTerm.<br>
><br>
> STEP 4 :<br>
> * Build a new AndTerm.<br>
> * Add the ResourceTypeTerm built in STEP 2 to it.<br>
> * Add the OrTerm built in STEP 3 to it.<br>
><br>
> STEP 5 :<br>
> * Add the AndTerm built in STEP 4 to my Query.<br>
> * Run the query : zero result :( (and there are some).<br>
><br>
><br>
> I can provide (Python) code if you want.<br>
><br>
> What am I missing/doing wrong ? I really need to understand the logic behind the query system since I'm looking forward to use Nepomuk almost everywhere in my app.<br>
> So my question isn't really about that precise case, but rather "how do you guys build your query ?"<br>
><br>
><br>
> Oh, also, my strigi didn't index those files yet because of crashes (but nepomuk is running). Does it matter ?<br>
><br>
><br>
> Thanks a lot,<br>
><br>
</div></div><div><div></div><div class="h5">_______________________________________________<br>
Nepomuk mailing list<br>
<a href="mailto:Nepomuk@kde.org">Nepomuk@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/nepomuk" target="_blank">https://mail.kde.org/mailman/listinfo/nepomuk</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font color="#999999">Vishesh Handa</font><br>