1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 19:31:02 +01:00

Add a context menu item to remove a podcast

This commit is contained in:
David Sansome 2012-03-09 20:02:12 +00:00
parent 3cafaf52ae
commit 87a9e41cd5
2 changed files with 15 additions and 1 deletions

View File

@ -192,12 +192,16 @@ void PodcastService::ShowContextMenu(const QModelIndex& index,
context_menu_ = new QMenu;
context_menu_->addAction(IconLoader::Load("list-add"), tr("Add podcast..."),
this, SLOT(AddPodcast()));
context_menu_->addSeparator();
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Update all podcasts"),
app_->podcast_updater(), SLOT(UpdateAllPodcastsNow()));
context_menu_->addSeparator();
update_selected_action_ = context_menu_->addAction(IconLoader::Load("view-refresh"),
tr("Update this podcast"),
this, SLOT(UpdateSelectedPodcast()));
remove_selected_action_ = context_menu_->addAction(IconLoader::Load("list-remove"),
tr("Unsubscribe"),
this, SLOT(RemoveSelectedPodcast()));
}
current_index_ = index;
@ -217,6 +221,7 @@ void PodcastService::ShowContextMenu(const QModelIndex& index,
}
update_selected_action_->setVisible(current_podcast_index_.isValid());
remove_selected_action_->setVisible(current_podcast_index_.isValid());
context_menu_->popup(global_pos);
}
@ -228,6 +233,13 @@ void PodcastService::UpdateSelectedPodcast() {
current_podcast_index_.data(Role_Podcast).value<Podcast>());
}
void PodcastService::RemoveSelectedPodcast() {
if (!current_podcast_index_.isValid())
return;
backend_->Unsubscribe(current_podcast_index_.data(Role_Podcast).value<Podcast>());
}
void PodcastService::ReloadSettings() {
QSettings s;
s.beginGroup(LibraryView::kSettingsGroup);

View File

@ -64,6 +64,7 @@ protected:
private slots:
void AddPodcast();
void UpdateSelectedPodcast();
void RemoveSelectedPodcast();
void SubscriptionAdded(const Podcast& podcast);
void SubscriptionRemoved(const Podcast& podcast);
@ -87,6 +88,7 @@ private:
QMenu* context_menu_;
QAction* update_selected_action_;
QAction* remove_selected_action_;
QStandardItem* root_;
QModelIndex current_index_;