1
/* This file is part of Clementine.
2
Copyright 2010, David Sansome <me@davidsansome.com>
4
Clementine is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
Clementine is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef INTERNETSERVICE_H
19
#define INTERNETSERVICE_H
25
#include "core/song.h"
26
#include "playlist/playlistitem.h"
27
#include "smartplaylists/generator.h"
28
#include "ui/settingsdialog.h"
29
#include "widgets/multiloadingindicator.h"
32
class LibraryFilterWidget;
34
class InternetService : public QObject {
38
// Constructs a new internet service with the given name and model. The name
39
// should be user-friendly (like 'DigitallyImported' or 'Last.fm').
40
InternetService(const QString& name, InternetModel* model, QObject* parent = NULL);
41
virtual ~InternetService() {}
43
QString name() const { return name_; }
44
InternetModel* model() const { return model_; }
46
virtual QStandardItem* CreateRootItem() = 0;
47
virtual void LazyPopulate(QStandardItem* parent) = 0;
49
virtual void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {}
50
virtual void ItemDoubleClicked(QStandardItem* item) {}
51
// Create a generator for smart playlists
52
virtual smart_playlists::GeneratorPtr CreateGenerator(QStandardItem* item) { return smart_playlists::GeneratorPtr(); }
53
// Give the service a chance to do a custom action when data is dropped on it
54
virtual void DropMimeData(const QMimeData* data, const QModelIndex& index) {}
56
virtual PlaylistItem::Options playlistitem_options() const { return PlaylistItem::Default; }
57
// Redefine this function to add service' specific actions to the playlist item
58
virtual QList<QAction*> playlistitem_actions(const Song& song) { return QList<QAction*>(); }
60
virtual QWidget* HeaderWidget() const { return NULL; }
62
virtual void ReloadSettings() {}
64
virtual QString Icon() { return QString(); }
67
void StreamError(const QString& message);
68
void StreamMetadataFound(const QUrl& original_url, const Song& song);
69
void OpenSettingsAtPage(SettingsDialog::Page page);
71
void AddToPlaylistSignal(QMimeData* data);
74
void AppendToPlaylist();
75
void ReplacePlaylist();
76
void OpenInNewPlaylist();
79
// Subclass provides the currently selected QModelIndex on InternetService's
81
virtual QModelIndex GetCurrentIndex() = 0;
83
// Returns all the playlist insertion related QActions (see below).
84
QList<QAction*> GetPlaylistActions();
86
// Returns the 'append to playlist' QAction.
87
QAction* GetAppendToPlaylistAction();
88
// Returns the 'replace playlist' QAction.
89
QAction* GetReplacePlaylistAction();
90
// Returns the 'open in new playlist' QAction.
91
QAction* GetOpenInNewPlaylistAction();
93
// Describes how songs should be added to playlist.
95
// appends songs to the current playlist
97
// clears the current playlist and then appends all songs to it
99
// creates a new, empty playlist and then adds all songs to it
103
// Adds the 'index' element to playlist using the 'add_mode' mode.
104
void AddItemToPlaylist(const QModelIndex& index, AddMode add_mode);
105
// Adds the 'indexes' elements to playlist using the 'add_mode' mode.
106
void AddItemsToPlaylist(const QModelIndexList& indexes, AddMode add_mode);
109
InternetModel* model_;
112
QAction* append_to_playlist_;
113
QAction* replace_playlist_;
114
QAction* open_in_new_playlist_;
118
Q_DECLARE_METATYPE(InternetService*);
120
#endif // INTERNETSERVICE_H