Add simple context menu to soundcloud items

This commit is contained in:
Arnaud Bienner 2012-08-09 00:16:16 +02:00
parent f13e7d1e69
commit 26908ed718
2 changed files with 23 additions and 2 deletions

View File

@ -149,7 +149,8 @@ void SoundCloudService::DoSearch() {
}
void SoundCloudService::SearchFinished(QNetworkReply* reply, int task_id) {
qLog(Debug) << task_id;
reply->deleteLater();
SongList songs = ExtractSongs(ExtractResult(reply));
// Fill results list
foreach (const Song& song, songs) {
@ -178,10 +179,29 @@ int SoundCloudService::SimpleSearch(const QString& text) {
}
void SoundCloudService::SimpleSearchFinished(QNetworkReply* reply, int id) {
reply->deleteLater();
SongList songs = ExtractSongs(ExtractResult(reply));
emit SimpleSearchResults(id, songs);
}
void SoundCloudService::EnsureMenuCreated() {
if(!context_menu_) {
context_menu_ = new QMenu;
context_menu_->addActions(GetPlaylistActions());
context_menu_->addSeparator();
context_menu_->addAction(IconLoader::Load("download"),
tr("Open %1 in browser").arg("soundcloud.com"),
this, SLOT(Homepage()));
}
}
void SoundCloudService::ShowContextMenu(const QPoint& global_pos) {
EnsureMenuCreated();
context_menu_->popup(global_pos);
}
QNetworkReply* SoundCloudService::CreateRequest(
const QString& ressource_name,
const QList<Param>& params) {

View File

@ -39,7 +39,7 @@ class SoundCloudService : public InternetService {
// TODO
//QList<QAction*> playlistitem_actions(const Song& song);
//void ShowContextMenu(const QPoint& global_pos);
void ShowContextMenu(const QPoint& global_pos);
QWidget* HeaderWidget() const;
int SimpleSearch(const QString& query);
@ -61,6 +61,7 @@ class SoundCloudService : public InternetService {
private:
void ClearSearchResults();
void EnsureItemsCreated();
void EnsureMenuCreated();
QNetworkReply* CreateRequest(const QString& ressource_name,
const QList<QPair<QString, QString> >& params);
// Convenient function for extracting result from reply