Skip navigation.
KDE Developer's Journals

We Don't Search...

trueg's picture

Virtual Folders in KDE

You can tag files, you can annotate them, Strigi indexes your files, I showed how to create new information types and things, but you could not really use it. I suspect you want to find the things again by searching for it. Well, I don't think we should search. We should simply find!

OK, enough of the bragging. Introducing Nepomuk virtual folders.

Step 1 - Predefined Virtual Folders

There are the default predefined folders. An example (and honestly the only I defined so far) is the folder that lists all music files (actually all music files indexed by Strigi. So, yes, Strigi needs to be running for this to work best.)

[image:3421 width=400 style="position:relative; left:100px"]

Step 2 - On-the-fly Virtual Folders

We can also define our virtual folders on the fly by simply using the nepomuksearch:/ protocol in combination with the query (I personally would prefer to hide the protocol in a nice GUI but that is polishing for the future). If we for example want to list all resources related to Nepomuk:

[image:3422 width=400 style="position:relative; left:100px"]

We get files tagged with tag Nepomuk, we get folders that contain the term "Nepomuk" (indexed via Strigi again) and we also get the tags themselves. The latter is most interesting as the tags are Nepomuk resources which do not relate to any file. KIO can list them anyway and even displays the correct type. The display of the correct type which is read from the Nepomuk store was achieved by a very small patch to KFileItem which I hope will be accepted. It basically treats the "application/x-nepomuk-resource" mimetype as a special case very much like "application/x-desktop". But instead of reading the type from the desktop file it is read via Nepomuk::Resource::resourceType. Simple but effective.

Well, off to a better example, a real example. Let's say we wrote down some notes using KWrite and saved them in some folder anywhere in the home directory:

[image:3423 width=400 style="position:relative; left:100px"]

Now instead of clicking through the directory hierarchy in search for the file we simple access it using a Nepomuk virtual folder. Be aware that the word "nepomuk" is part of the text itself while the word "notes" is part of the file name.

[image:3424 width=400 style="position:relative; left:100px"]

As a last little example we reuse the information created in my last blog: my friend Tudor. He can of course also be accessed through a virtual folder:

[image:3425 width=400 style="position:relative; left:100px"]

Again the type information we created ourselves is used in the KIO slave. Well, that is it for today. I am off to work some more on the folders, making the query language more expressive (at some point we will need variables in there!), and maybe creating a virtual folder service. The latter could then be used not only for KIO virtual folders but also in KMail or some other application to list whatever resources one likes.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
paris hilton movie's picture

thanks for good tutorial

thanks for good tutorial

bibo136's picture

Findinf info in Kmail

I would like to have possibility to give flags to my messages in kmail, a bit like what is doing GTDInbox for Gmail (http://gtdinbox.com/): to every message that arrives, I can put a flag on it which I define myself ("Project ABC", "To do tomorrow", ...), or several flags it I wish.

I think this is probably related to the indexing of files as well.

Do you know how to set this? I think this would be wauite easy to implement. Maybe let me know where to adress this proposal, if not here.

Thanks!
Bibbo136

renrutal's picture

Along with the virtual

Along with the virtual folder, there could be an option to show the sub(virtual)folders inside that folder, and these folders could be linked to other tags.

>> alias nepomuksearch s

For example, inside the Virtual Folder "Music"(s:/music), there could be another one named "J-Rock", which means music && j-rock (s:/music j-rock), perhaps you could go all the way to (s:/music j-rock laruku smile)

I'd say this should be user-created because there are too many tag relationships to be done automatically, but on the other hand the user should be able to create templates, so the virtual folder could be filled using them. For example:

music/type:genre/type:artist/type:album/[sortby:tracknumber:desc]

This would create a nepomuk-based tree of virtual folders, with music at the top level, generating the genres as sub-folders, inside the genres, subdivide by artists, then album, then sort the album folder by track number, in descending order.

It's just an opinion really Eye-wink

trueg's picture

Cool idea

I also thought about that. Having sort of subfolders which do a further search on the contents of the folder. I am just not exactly sure how to implement that. ATM it would mean to combine both queries which is not always simple. Any ideas?

renrutal's picture

What is not simple about

What is not simple about doing an intersection (set theory) of the results of a two queries?

The slow way is doing two huge searches on the universe set, then check one by one what elements are the same.

The fast way is doing one huge search on the universe set, return a searchable set, and do another search on that on that last set, returning the final result set.

Of course, keeping the intermediary set in memory might not be feasible in both cases...

The third way is to send a query on the universe set with a lot of AND conditions. Slowest?

trueg's picture

Right...

You are right. Doing a subquery is simple when done on the whole set again. The problem is that the query folders are virtual in every way. As such, I would have to store sub-queries in some config. But will a sub-query once created always be available afterwards? Whenever I "open" this virtual folder again? Hm, maybe that could be the solution... creating virtual folders within other virtual folders. but that is a problem with KIO I think.

tikal26's picture

great

I like liquidat's suggestion, but only for predefine folder like if I make a virtual music folder i would like to add that folder to the Amarok colletion.It might be useful in some cases that I do not feel like typing nepomuksearch:/whatever in every application or everytime I feel like looking for something. For example if I make a virtual folder that include everything i tag for a specific school project I would like to have access to that folder in the desktop file system. This folder might include e-mails, pictures, maps, with word documents, presentations, etc.. and to be able to know that they all exits in one folder would make it easy to access it on the file folder system so i don't have to type the same search in krita, kword, etc...

fabian's picture

Great work! This looks very

Great work! This looks very very promissing!

liquidat's picture

Link virtual folders to desktop/file system?

The main question for me is now:
Can I create folders on the desktop or in the file system which are in fact no folders but are a virtual folder pointing to
nepomuksearch:/whatever

I would like these folders treated by KDE as normal folders - so they would appear in all "open" dialogs as the normal folders. In addition, I would like all files stored from save dialogs to such folders to be automatically tagged with the tags of the folder! Will that be possible in the future?

trueg's picture

Create new virtual folder

You can already use the "Create new..." -> "Link to Location" thing to create a new virtual folder:

[image:3427 size=preview]

Then you can execute the resulting desktop file lie a normal folder. But it does not look good and when creating it we have to actually insert the search URL. It would be great, however, to have a proper GUI integration to create a new virtual folder. I am not sure if this can be done with a plain template. I will have to investigate.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.