Add a refresh action to Grooveshark

This commit is contained in:
Arnaud Bienner 2011-12-22 20:45:44 +01:00
parent cb1b4483ea
commit 6f7e507b30
2 changed files with 14 additions and 0 deletions

View File

@ -416,6 +416,10 @@ void GroovesharkService::Authenticated() {
void GroovesharkService::Logout() {
ResetSessionId();
RemoveItems();
}
void GroovesharkService::RemoveItems() {
root_->removeRows(0, root_->rowCount());
// 'search', 'favorites', 'popular', ... items were root's children, and have
// been deleted: we should update these now invalid pointers
@ -501,6 +505,8 @@ void GroovesharkService::EnsureMenuCreated() {
context_menu_->addAction(IconLoader::Load("edit-find"), tr("Search Grooveshark (opens a new tab)") + "...", this, SLOT(OpenSearchTab()));
context_menu_->addSeparator();
context_menu_->addAction(IconLoader::Load("download"), tr("Open %1 in browser").arg("grooveshark.com"), this, SLOT(Homepage()));
context_menu_->addAction(IconLoader::Load("view-refresh"), tr("Refresh"), this, SLOT(RefreshItems()));
context_menu_->addSeparator();
context_menu_->addAction(IconLoader::Load("configure"), tr("Configure Grooveshark..."), this, SLOT(ShowConfig()));
}
}
@ -509,6 +515,11 @@ void GroovesharkService::Homepage() {
QDesktopServices::openUrl(QUrl(kHomepage));
}
void GroovesharkService::RefreshItems() {
RemoveItems();
EnsureItemsCreated();
}
void GroovesharkService::EnsureItemsCreated() {
if (IsLoggedIn() && !search_) {
search_ = new QStandardItem(IconLoader::Load("edit-find"),

View File

@ -175,10 +175,13 @@ class GroovesharkService : public InternetService {
void SongMarkedAsComplete();
void Homepage();
// Refresh all Grooveshark's items, and re-fill them
void RefreshItems();
private:
void EnsureMenuCreated();
void EnsureItemsCreated();
void RemoveItems();
void EnsureConnected();
// Create a playlist item, with data set as excepted. Doesn't fill the item