18
18
#include "tagwidget.h"
19
#include "internet/lastfmservice.h"
20
#include "internet/internetmimedata.h"
21
#include "internet/internetmodel.h"
19
22
#include "playlist/playlistitemmimedata.h"
20
#include "radio/lastfmservice.h"
21
#include "radio/radiomimedata.h"
22
#include "radio/radiomodel.h"
23
23
#include "smartplaylists/generator.h"
24
24
#include "smartplaylists/generatormimedata.h"
25
25
#include "smartplaylists/querygenerator.h"
133
void TagWidget::EnsureMenuCreated() {
137
menu_ = new QMenu(this);
140
menu_->addAction(QIcon(":/last.fm/as.png"), tr("Play last.fm tag radio"),
141
this, SLOT(PlayLastFmTagRadio()));
145
menu_->addAction(QIcon(":/last.fm/as.png"), tr("Play last.fm artist radio"),
146
this, SLOT(PlayLastFmArtistRadio()));
147
menu_->addAction(IconLoader::Load("folder-sound"), tr("Play from my Library"),
148
this, SLOT(PlayFromLibrary()));
153
132
void TagWidget::TagClicked() {
154
133
TagWidgetTag* tag = qobject_cast<TagWidgetTag*>(sender());
160
context_item_ = tag->text();
161
menu_->popup(tag->mapToGlobal(tag->rect().bottomLeft()));
164
void TagWidget::PlayLastFmArtistRadio() {
165
PlayLastFm("lastfm://artist/%1/similarartists");
168
void TagWidget::PlayLastFmTagRadio() {
169
PlayLastFm("lastfm://globaltags/%1");
172
void TagWidget::PlayFromLibrary() {
173
using smart_playlists::GeneratorMimeData;
174
using smart_playlists::GeneratorPtr;
175
using smart_playlists::QueryGenerator;
176
using smart_playlists::Search;
177
using smart_playlists::SearchTerm;
179
GeneratorPtr gen(new QueryGenerator(QString(), Search(
180
Search::Type_And, Search::TermList() <<
181
SearchTerm(SearchTerm::Field_Artist, SearchTerm::Op_Contains, context_item_),
182
Search::Sort_FieldAsc, SearchTerm::Field_Album, 100)));
183
emit AddToPlaylist(new GeneratorMimeData(gen));
186
void TagWidget::PlayLastFm(const QString& url_pattern) {
187
LastFMService* last_fm = RadioModel::Service<LastFMService>();
188
if (!last_fm->IsAuthenticated()) {
189
last_fm->ShowConfig();
193
QUrl url(url_pattern.arg(context_item_));
194
PlaylistItemPtr item(last_fm->PlaylistItemForUrl(url));
198
emit AddToPlaylist(new PlaylistItemMimeData(item));
137
emit DoGlobalSearch(tag->text());