From 107e6210b71441713a6daecaa27d6b67fc70b313 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 30 Dec 2009 02:23:09 +0000 Subject: [PATCH] Add a menu item to remove tags and artists --- data/data.qrc | 1 + data/list-remove.png | Bin 0 -> 498 bytes src/lastfmservice.cpp | 24 ++++++++++++++++++++++++ src/lastfmservice.h | 1 + 4 files changed, 26 insertions(+) create mode 100644 data/list-remove.png diff --git a/data/data.qrc b/data/data.qrc index 1f2db687b..38ff67edb 100644 --- a/data/data.qrc +++ b/data/data.qrc @@ -47,5 +47,6 @@ last.fm/my_friends.png last.fm/my_neighbours.png last.fm/user_purple.png + list-remove.png diff --git a/data/list-remove.png b/data/list-remove.png new file mode 100644 index 0000000000000000000000000000000000000000..2bb1a59831d42e01df138bbe76861b3c573cd71a GIT binary patch literal 498 zcmVRHg64C~ZChUS5vpoL5VA5tAr}#SR$T{WGVm-b<<#qEEI#tZ50{s_ zoB2GJ{XUkK6-*-`DOY$(N^&m*v}_h{o(H?v!{cy>!(tJ_w)cZ57K;U5Ivqr2GuZ@_ zl0vXVk4B*}a!Qvcbf!~0H5wR?MtB84xg6Zd1lnrG9&lqfo5vfRQ#76C(+C7#7A*2u zQ7DK8~KoZ=ls6?v;mtBy1Il+Yx+d6O^HH;mDg~3Pp&X;F85rUpy ot~*YL`;#rAZuoZ##s5M40Ta=R=mj`S^8f$<07*qoM6N<$f>l$>!vFvP literal 0 HcmV?d00001 diff --git a/src/lastfmservice.cpp b/src/lastfmservice.cpp index fe5dd91f6..35058a96c 100644 --- a/src/lastfmservice.cpp +++ b/src/lastfmservice.cpp @@ -47,12 +47,14 @@ LastFMService::LastFMService(QObject* parent) config_->ui_.scrobble->setEnabled(scrobbling_enabled_); play_action_ = context_menu_->addAction(QIcon(":media-playback-start.png"), "Add to playlist", this, SLOT(AddToPlaylist())); + remove_action_ = context_menu_->addAction(QIcon(":list-remove.png"), "Remove", this, SLOT(Remove())); context_menu_->addSeparator(); add_artist_action_ = context_menu_->addAction(QIcon(":last.fm/icon_radio.png"), "Play artist radio...", this, SLOT(AddArtistRadio())); add_tag_action_ = context_menu_->addAction(QIcon(":last.fm/icon_tag.png"), "Play tag radio...", this, SLOT(AddTagRadio())); context_menu_->addAction(QIcon(":configure.png"), "Configure Last.fm...", config_, SLOT(show())); + remove_action_->setEnabled(false); add_artist_action_->setEnabled(false); add_tag_action_->setEnabled(false); } @@ -391,6 +393,17 @@ void LastFMService::Ban() { void LastFMService::ShowContextMenu(RadioItem* item, const QPoint &global_pos) { context_item_ = item; + switch (item->type) { + case Type_Artist: + case Type_Tag: + remove_action_->setEnabled(true); + break; + + default: + remove_action_->setEnabled(false); + break; + } + play_action_->setEnabled(item->playable); context_menu_->popup(global_pos); } @@ -523,3 +536,14 @@ void LastFMService::RestoreList(const QString &name, ItemType item_type, } settings.endArray(); } + +void LastFMService::Remove() { + int type = context_item_->type; + + context_item_->parent->DeleteNotify(context_item_->row); + + if (type == Type_Artist) + SaveList("artists", artist_list_); + else if (type == Type_Tag) + SaveList("tags", tag_list_); +} diff --git a/src/lastfmservice.h b/src/lastfmservice.h index 4a8097726..36f1b4282 100644 --- a/src/lastfmservice.h +++ b/src/lastfmservice.h @@ -85,6 +85,7 @@ class LastFMService : public RadioService { void AddToPlaylist(); void AddArtistRadio(); void AddTagRadio(); + void Remove(); private: RadioItem* CreateStationItem(ItemType type, const QString& name,