Add Grooveshark songs as internet items, when adding them from global search, so user can use all GS custom actions

This commit is contained in:
Arnaud Bienner 2011-11-24 00:30:11 +01:00
parent c234afb776
commit ceab3bd6f0
4 changed files with 45 additions and 3 deletions

View File

@ -398,6 +398,7 @@ set(HEADERS
internet/internetmimedata.h
internet/internetmodel.h
internet/internetservice.h
internet/internetsongmimedata.h
internet/internetview.h
internet/internetviewcontainer.h
internet/jamendodynamicplaylist.h

View File

@ -22,7 +22,7 @@
#include "core/logging.h"
#include "covers/albumcoverloader.h"
#include "internet/groovesharkservice.h"
#include "playlist/songmimedata.h"
#include "internet/internetsongmimedata.h"
GroovesharkSearchProvider::GroovesharkSearchProvider(QObject* parent)
: service_(NULL) {
@ -131,7 +131,7 @@ void GroovesharkSearchProvider::LoadTracksAsync(int id, const Result& result) {
ret << result.metadata_;
SortSongs(&ret);
SongMimeData* mime_data = new SongMimeData;
InternetSongMimeData* mime_data = new InternetSongMimeData(service_);
mime_data->songs = ret;
emit TracksLoaded(id, mime_data);
@ -161,7 +161,7 @@ void GroovesharkSearchProvider::FetchAlbum(int id, const Result& result) {
}
void GroovesharkSearchProvider::AlbumSongsLoaded(int id, const SongList& songs) {
SongMimeData* mime_data = new SongMimeData;
InternetSongMimeData* mime_data = new InternetSongMimeData(service_);
mime_data->songs = songs;
SortSongs(&mime_data->songs);

View File

@ -0,0 +1,37 @@
/* This file is part of Clementine.
Copyright 2011, David Sansome <me@davidsansome.com>
Clementine is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Clementine is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INTERNETSONGMIMEDATA_H
#define INTERNETSONGMIMEDATA_H
#include "core/mimedata.h"
#include "core/song.h"
class InternetService;
class InternetSongMimeData : public MimeData {
Q_OBJECT
public:
InternetSongMimeData(InternetService* _service)
: service(_service) {}
InternetService* service;
SongList songs;
};
#endif // INTERNETSONGMIMEDATA_H

View File

@ -34,6 +34,7 @@
#include "internet/internetmimedata.h"
#include "internet/internetmodel.h"
#include "internet/internetplaylistitem.h"
#include "internet/internetsongmimedata.h"
#include "internet/savedradio.h"
#include "library/library.h"
#include "library/librarybackend.h"
@ -639,6 +640,9 @@ bool Playlist::dropMimeData(const QMimeData* data, Qt::DropAction action, int ro
// Dragged from the Internet pane
InsertInternetItems(internet_data->model, internet_data->indexes,
row, play_now, enqueue_now);
} else if (const InternetSongMimeData* internet_song_data = qobject_cast<const InternetSongMimeData*>(data)) {
InsertInternetItems(internet_song_data->service, internet_song_data->songs,
row, play_now, enqueue_now);
} else if (const GeneratorMimeData* generator_data = qobject_cast<const GeneratorMimeData*>(data)) {
InsertSmartPlaylist(generator_data->generator_, row, play_now, enqueue_now);
} else if (const PlaylistItemMimeData* item_data = qobject_cast<const PlaylistItemMimeData*>(data)) {