Dev query : To get the path of the current track playing from ratingValueChanged()

Bart Cerneels bart.cerneels at kde.org
Mon Mar 5 07:57:38 UTC 2012


On Sun, Mar 4, 2012 at 17:44, Matěj Laitl <matej at laitl.cz> wrote:
> On 4. 3. 2012 Phalgun Guduthur wrote:
>> Hello
>>
>> I'm trying to write a patch along my GSoC proposal ( I have already mailed
>> in the first rough draft, please review it if possible, any feedback is
>> welcome! ).
>>
>> What I'm trying to do is, when a user changes the rating of a song, the song
>> resource's nao:rating should be updated along with the normal id3 tag
>> updation carried out by Amarok.
>>
>> The slot for this is in src/playlist/view/listview/InlineEditorWidget.cpp
>> which calls the function ratingValueChanged. (line 159 and 270)
>>
>> But I'm stuck on getting the path of the current track whose rating is being
>> modified.  I tried using Playlist::Item::track()
>> But it didn't work. The ratingWidget disappeared after this.
>
> I suggest you hook in a completely different place. Tracks from what collection
> do you want to watch? If it is SqlCollection, I suggest you hook in
> SqlTrack::setRating(). For tracks not in any collection there is
> MetaFile::Track.
>
> If you need to watch tracks from various collections, you could become their
> observer by implementing Meta::Observer, but that would be inefficient to watch
> entire collections etc. Also, some tracks are not file-based (MTP collection),
> some could be remote..
>
> Regards,
>                        Matěj

Since this is for the nepomuk collection I would suggest only doing
rating updates for tracks that originated from the nepomuk collection.
This way you can simply implement it in the actual Track
implementation (NepomukTrack::setRating()) without any overhead.
If you really want to set nepomuk ratings for SqlTracks I agree with
Matěj, hook it into SqlTrack, possibly providing a singleton for
access to nepomuk/tracker/other semantic db's. This might be a way for
you to keep the actual Collection generic between KDE's and tracker's
nepomuk "dialects".

Bart


More information about the Amarok-devel mailing list