Reply to topic

Duplicated entries with KDirModel + Nepomuk + QML GridView

daitheflu
Registered Member
Posts
11
Karma
0
OS
Hi,

I'm trying to create a media center piece of software for KDE. It's something I do during my spare time so it's far from being useable now.
But it makes me learn Python and some of the Qt/KDE technologies, such as QML, Nepomuk, Phonon, ...

I'm currently trying to display a list of movies in a grid. I get the movies list from Nepomuk, fill a model with it and feed the grid with this model.
It works quite well (the QML gridview is a bit disappointing, but that's another story).
The Nepomuk query is built to look for movies stored at some specific path(s), provided by the conf.
For example, I ask Nepomuk to look for files tagged as "Movie" and stored in /home/francois/Movies. This directory actually contains 19 movies.

What bothers me for months is that sometimes, for some reason, the grid will display more than the 19 expected files. I get duplicate entries.
If I run the same Nepomuk query (Sparql query) in Nepomuk Shell, I always get the expected result set. Same if I run it through sopranocmd (See http://techbase.kde.org/Development/Tutorials/Metadata/Nepomuk/TipsAndTricks#Debugging_the_created_data). So I guess the problem is not Nepomuk, but rather something going wrong between my model and my view.

The source code of the problematic part is a bit long, so you can check it here : http://gitorious.org/helmo/helmo/blobs/movies-plugin/services/localvideolibrary.py

If you're kind enough to take a look at the code, you have to know how the LocalVideoLibrary works :
  • Well, it's first initialized via the __init__ method.
  • Then, we call the _prepare method. It builds the Nepomuk query and emits a "prepared" signal when done. When the KDirLister is done fetching data, it emits a "ready" signal.
  • Eventually, the _fetch method catches the "ready" signal and fills the GridView with the previously prepared data.

I did that so I can display a loading indicator while querying the Nepomuk datastore.

You'll also see that I had to subclass a lot of thing. I guess I'm misunderstanding something related to KDirModel / KDirSortFilterProxyModel / KDirLister but I don't get what :(


If you want to try the whole application, you can download the source code here http://gitorious.org/helmo/helmo/commits/movies-plugin
Then, cd to the created directory and run python run.py.
Quit by pressing the ESC key. The Movies thing will look for files stored in ~/Movies . If you want to change that path, you can edit your ~/.kde/share/config/helmorc file and make it point to whatever directory you want.
WARNING!
Please be warn that video files stored in that directory will be tagged as "Movie" if they aren't already.
Also please remember that this is a huge WIP, and I'm a beginner, but, yeah, feel free to make any comment.


I'm taking any help, advice, criticism, or idea to sort this out. I'm stuck with this for more than 3 months :(
I'll be glad to provide further explanations, code or whatever you may need.

I'm also looking for someone who has knowledge in Python + KDE technologies and who would be interested in mentoring me (reviewing some code, giving me advices or help, ...).
Please get in touch with me if you're interested :)

Thanks a lot.
User avatar bcooksley
Administrator
Posts
18607
Karma
83
OS
You may want to ask about this on the nepomuk@kde.org mailing list, as they may know more about why this occurs.


System Settings and Device Actions KCM maintainer
Image
daitheflu
Registered Member
Posts
11
Karma
0
OS
Yes, I've already tried the mailing-list, but got no solution (see http://mail.kde.org/pipermail/nepomuk/2011-September/001921.html -- yep, this was more than a year ago). I resend a mail a few months ago but got no answer.

Anyway, thanks for your advice and for taking the time to answer me :)
daitheflu
Registered Member
Posts
11
Karma
0
OS
Hi,

I've made a quick test yesterday and connected the newItems signal of my KDirLister to some basic slot. Just to see what's happening.
The result is kinda weird (but expected) : the duplicates items are returned by the signal at this point.

So, I went back to the doc, and found out something that might be relevant : KDirLister has a clear signal. Here is the doc for it :

void KDirLister::clear() [signal]

Signal to clear all items.

Make sure to connect to this signal to avoid doubled items.

I'll be glad to "connect to this signal", but... what's the slot supposed to do ?
User avatar bcooksley
Administrator
Posts
18607
Karma
83
OS
The slot which you connect it to should clear the list of all items currently present in it. Essentially, it does the inverse of newItems - which adds items into the list.


System Settings and Device Actions KCM maintainer
Image
daitheflu
Registered Member
Posts
11
Karma
0
OS
@bcooksley : thank you for your answers :)

Well, I currently doesn't manage a list "manually". My KDirLister is the one my KDirModel provides, so everything (list management) is supposed to be automatically done, doesn't it ?

Also, Marco Martin has posted an interesting email this past week-end (see http://mail.kde.org/pipermail/nepomuk/2012-November/003449.html).
I'm now wondering if one can actually use a KDirModel with Nepomuk. Sounds like I'm wasting my time for more than a year :|
User avatar bcooksley
Administrator
Posts
18607
Karma
83
OS
I would suggest continuing this discussion on the development mailing list - I don't know too much in detail about KDirModel, etc so those in KDE who have worked with it can probably give greater insight than I can.


System Settings and Device Actions KCM maintainer
Image
daitheflu
Registered Member
Posts
11
Karma
0
OS
For those who could be interested in this thread, check out the conclusion on the kde-devel mailing-list here : http://lists.kde.org/?l=kde-devel&m=135392137923569&w=2

Thanks again for your help :)

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Exabot [Bot], Google [Bot], google01103, Hans, koriun, La Ninje, MSNbot Media, north, odysseus-art, pesto, SecretCode, Sentynel, Yahoo [Bot], z-uo