2010-03-24 00:11:46 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 00:11:46 +01:00
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
#ifndef INTERNETSERVICE_H
|
|
|
|
#define INTERNETSERVICE_H
|
2009-12-26 16:13:38 +01:00
|
|
|
|
|
|
|
#include <QObject>
|
2009-12-26 22:35:45 +01:00
|
|
|
#include <QList>
|
|
|
|
#include <QUrl>
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "core/song.h"
|
|
|
|
#include "playlist/playlistitem.h"
|
2010-08-27 17:42:58 +02:00
|
|
|
#include "ui/settingsdialog.h"
|
2010-05-10 23:50:31 +02:00
|
|
|
#include "widgets/multiloadingindicator.h"
|
2009-12-26 23:15:57 +01:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class InternetModel;
|
2010-05-09 22:18:05 +02:00
|
|
|
class LibraryFilterWidget;
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
class InternetService : public QObject {
|
2009-12-26 16:13:38 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
public:
|
2011-07-15 15:27:50 +02:00
|
|
|
// Constructs a new internet service with the given name and model. The name
|
2011-02-14 18:00:13 +01:00
|
|
|
// should be user-friendly (like 'DigitallyImported' or 'Last.fm').
|
2011-07-15 15:27:50 +02:00
|
|
|
InternetService(const QString& name, InternetModel* model, QObject* parent = NULL);
|
|
|
|
virtual ~InternetService() {}
|
2009-12-26 16:13:38 +01:00
|
|
|
|
|
|
|
QString name() const { return name_; }
|
2011-07-15 15:27:50 +02:00
|
|
|
InternetModel* model() const { return model_; }
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2011-01-09 19:27:41 +01:00
|
|
|
virtual QStandardItem* CreateRootItem() = 0;
|
|
|
|
virtual void LazyPopulate(QStandardItem* parent) = 0;
|
2009-12-26 16:13:38 +01:00
|
|
|
|
2011-04-29 13:24:58 +02:00
|
|
|
virtual void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {}
|
|
|
|
virtual void ItemDoubleClicked(QStandardItem* item) {}
|
2011-10-30 23:59:43 +01:00
|
|
|
// Give the service a chance to do a custom action when data is dropped on it
|
|
|
|
virtual void DropMimeData(const QMimeData* data, const QModelIndex& index) {}
|
2009-12-26 23:59:11 +01:00
|
|
|
|
2010-05-18 22:43:10 +02:00
|
|
|
virtual PlaylistItem::Options playlistitem_options() const { return PlaylistItem::Default; }
|
2009-12-29 17:12:08 +01:00
|
|
|
|
2010-06-09 17:38:00 +02:00
|
|
|
virtual QWidget* HeaderWidget() const { return NULL; }
|
2010-05-09 22:18:05 +02:00
|
|
|
|
2010-02-03 19:32:48 +01:00
|
|
|
virtual void ReloadSettings() {}
|
|
|
|
|
2010-03-25 19:38:20 +01:00
|
|
|
virtual QString Icon() { return QString(); }
|
|
|
|
|
2011-10-20 15:03:47 +02:00
|
|
|
public slots:
|
|
|
|
// Show configuration panel for services which have one
|
|
|
|
virtual void ShowConfig() { }
|
|
|
|
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
signals:
|
2009-12-26 22:35:45 +01:00
|
|
|
void StreamError(const QString& message);
|
2009-12-26 23:15:57 +01:00
|
|
|
void StreamMetadataFound(const QUrl& original_url, const Song& song);
|
2010-08-27 17:42:58 +02:00
|
|
|
void OpenSettingsAtPage(SettingsDialog::Page page);
|
2009-12-26 22:35:45 +01:00
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
void AddToPlaylistSignal(QMimeData* data);
|
2009-12-30 02:41:37 +01:00
|
|
|
|
2011-02-10 23:24:17 +01:00
|
|
|
private slots:
|
|
|
|
void AppendToPlaylist();
|
|
|
|
void ReplacePlaylist();
|
|
|
|
void OpenInNewPlaylist();
|
|
|
|
|
2011-01-10 23:26:13 +01:00
|
|
|
protected:
|
2011-07-15 15:27:50 +02:00
|
|
|
// Subclass provides the currently selected QModelIndex on InternetService's
|
2011-02-10 23:24:17 +01:00
|
|
|
// request.
|
|
|
|
virtual QModelIndex GetCurrentIndex() = 0;
|
|
|
|
|
|
|
|
// Returns all the playlist insertion related QActions (see below).
|
|
|
|
QList<QAction*> GetPlaylistActions();
|
|
|
|
|
|
|
|
// Returns the 'append to playlist' QAction.
|
|
|
|
QAction* GetAppendToPlaylistAction();
|
|
|
|
// Returns the 'replace playlist' QAction.
|
|
|
|
QAction* GetReplacePlaylistAction();
|
|
|
|
// Returns the 'open in new playlist' QAction.
|
|
|
|
QAction* GetOpenInNewPlaylistAction();
|
|
|
|
|
2011-02-09 19:23:14 +01:00
|
|
|
// Describes how songs should be added to playlist.
|
|
|
|
enum AddMode {
|
|
|
|
// appends songs to the current playlist
|
|
|
|
AddMode_Append,
|
|
|
|
// clears the current playlist and then appends all songs to it
|
|
|
|
AddMode_Replace,
|
|
|
|
// creates a new, empty playlist and then adds all songs to it
|
|
|
|
AddMode_OpenInNew
|
|
|
|
};
|
|
|
|
|
|
|
|
// Adds the 'index' element to playlist using the 'add_mode' mode.
|
|
|
|
void AddItemToPlaylist(const QModelIndex& index, AddMode add_mode);
|
|
|
|
// Adds the 'indexes' elements to playlist using the 'add_mode' mode.
|
|
|
|
void AddItemsToPlaylist(const QModelIndexList& indexes, AddMode add_mode);
|
2011-01-10 23:26:13 +01:00
|
|
|
|
|
|
|
private:
|
2011-07-15 15:27:50 +02:00
|
|
|
InternetModel* model_;
|
2009-12-26 16:13:38 +01:00
|
|
|
QString name_;
|
2011-02-10 23:24:17 +01:00
|
|
|
|
|
|
|
QAction* append_to_playlist_;
|
|
|
|
QAction* replace_playlist_;
|
|
|
|
QAction* open_in_new_playlist_;
|
|
|
|
QAction* separator_;
|
2009-12-26 16:13:38 +01:00
|
|
|
};
|
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
Q_DECLARE_METATYPE(InternetService*);
|
2011-01-09 19:27:41 +01:00
|
|
|
|
2011-07-15 15:27:50 +02:00
|
|
|
#endif // INTERNETSERVICE_H
|