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