Bug 183493 - [PATCH] Access selected playlist entries from a script
Summary: [PATCH] Access selected playlist entries from a script
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Tools/Script Manager (show other bugs)
Version: 2.0.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-07 00:18 UTC by Mathias Panzenböck
Modified: 2009-02-07 18:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
scripting api for selected filenames (2.98 KB, patch)
2009-02-07 00:19 UTC, Mathias Panzenböck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Panzenböck 2009-02-07 00:18:41 UTC
Version:           2.0.1.1 (using KDE 4.2.0)
OS:                Linux
Installed from:    Fedora RPMs

The appended patch adds two methods with which you can access the currently selected playlist entries:

Amarok.Playlist.selectedFilenames()
Amarok.Playlist.selectedIndizes()

The corresponding C++ Methods (public slots):
QList<int> AmarokScript::AmarokPlaylistScript::selectedIndizes()
QStringList AmarokScript::AmarokPlaylistScript::selectedFilenames()

I'm new to amaroks source and therefore I changed as few as possible. This has the effect that I violate the MVC pattern a bit. Which entries are selected is maintained by the Playlist::PrettyListView class. This class is at some point only stored as a QWidget and so I have to cast to Playlist::PrettyListView in order to retrieve the selected entries. This is ugly but it should make no problems.

I use this API in a little script of mine which adds basic filemanagement functionality.

I'd also like an API with which you would be able to add a rightclick menu to files. I mean to everywhere where there are files. E.g. playlist entries, the entries of podcast feeds, songs in your collection, songs in magnatunes etc. The callback of such an menu should get some kind of handle to the rightclicked song (e.g. url as a string). I'll write another feature request for this.
Comment 1 Mathias Panzenböck 2009-02-07 00:19:34 UTC
Created attachment 31060 [details]
scripting api for selected filenames
Comment 2 Mathias Panzenböck 2009-02-07 00:21:33 UTC
Comment on attachment 31060 [details]
scripting api for selected filenames

This patch is against amarok svn revision 922016.
Comment 3 Mark Kretschmann 2009-02-07 08:50:43 UTC
SVN commit 922466 by markey:

Add two new scripting methods for accessing playlist entries:

Amarok.Playlist.selectedFilenames()
Amarok.Playlist.selectedIndizes()

Many thanks for the patch go to Mathias Panzenböck
<grosser.meister.morti@gmx.net>.

Matthias: Could you please add these new methods to our scripting API
document, which is located here:

http://amarok.kde.org/wiki/Development/Scripting_HowTo_2.0

Also, the patch needs code review and formatting cleanup.

BUG: 183493
CCMAIL: ian.monroe@gmail.com

 M  +1 -0      MainWindow.h  
 M  +3 -2      playlist/view/listview/PrettyListView.h  
 M  +22 -0     scriptengine/AmarokPlaylistScript.cpp  
 M  +2 -0      scriptengine/AmarokPlaylistScript.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=922466
Comment 4 Mark Kretschmann 2009-02-07 08:58:57 UTC
SVN commit 922472 by markey:

Some formatting and code cleanup of Matthias's patch.

@Matthias: Could you please read this document too:

http://kollide.net:8060/browse/~raw,r=20999/Amarok/HACKING/intro_and_style.txt

CCBUG: 183493

 M  +10 -8     AmarokPlaylistScript.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=922472
Comment 5 Mathias Panzenböck 2009-02-07 14:05:09 UTC
Woot, a patch of mine was committed to svn! :)
However, I just mentioned that the english word for Indizes is indices. Indizes is german (I'm from Austria). Sorry.

I saw in intro_and_style.txt something about git. Is there a git mirror of the amarok svn repository? This would be handy for local hacking, so I can actually commit local changes (so I have a local history). Searching for 

Btw. my name is "Mathias" with only one "t".
Comment 6 Mark Kretschmann 2009-02-07 14:39:37 UTC
Sorry about writing your name wrong.

About git: We're currently in the middle of transitioning from SVN to git (many devs are using git locally already with git-svn). So it doesn't exist yet, but if all goes well, it should surface in 2 or 3 months or so.
Comment 7 Mathias Panzenböck 2009-02-07 18:35:12 UTC
I added the two methods to the API documentation:
http://amarok.kde.org/wiki/Development/Script_API#Amarok.Playlist

However, the amarok wiki seem not to support footnotes?