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.
Created attachment 31060 [details] scripting api for selected filenames
Comment on attachment 31060 [details] scripting api for selected filenames This patch is against amarok svn revision 922016.
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
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
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".
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.
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?