~ubuntu-branches/ubuntu/saucy/clementine/saucy

« back to all changes in this revision

Viewing changes to src/radio/radioservice.h

  • Committer: Package Import Robot
  • Author(s): Thomas PIERSON
  • Date: 2012-01-01 20:43:39 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120101204339-lsb6nndwhfy05sde
Tags: 1.0.1+dfsg-1
New upstream release. (Closes: #653926, #651611, #657391)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of Clementine.
2
 
   Copyright 2010, David Sansome <me@davidsansome.com>
3
 
 
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.
8
 
 
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.
13
 
 
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/>.
16
 
*/
17
 
 
18
 
#ifndef RADIOSERVICE_H
19
 
#define RADIOSERVICE_H
20
 
 
21
 
#include <QObject>
22
 
#include <QList>
23
 
#include <QUrl>
24
 
 
25
 
#include "core/song.h"
26
 
#include "playlist/playlistitem.h"
27
 
#include "ui/settingsdialog.h"
28
 
#include "widgets/multiloadingindicator.h"
29
 
 
30
 
class RadioModel;
31
 
class LibraryFilterWidget;
32
 
 
33
 
class RadioService : public QObject {
34
 
  Q_OBJECT
35
 
 
36
 
public:
37
 
  // Constructs a new radio service with the given name and model. The name
38
 
  // should be user-friendly (like 'DigitallyImported' or 'Last.fm').
39
 
  RadioService(const QString& name, RadioModel* model);
40
 
  virtual ~RadioService() {}
41
 
 
42
 
  QString name() const { return name_; }
43
 
  RadioModel* model() const { return model_; }
44
 
 
45
 
  virtual QStandardItem* CreateRootItem() = 0;
46
 
  virtual void LazyPopulate(QStandardItem* parent) = 0;
47
 
 
48
 
  virtual void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos) {
49
 
    Q_UNUSED(index); Q_UNUSED(global_pos); }
50
 
 
51
 
  virtual PlaylistItem::SpecialLoadResult StartLoading(const QUrl& url);
52
 
  virtual PlaylistItem::SpecialLoadResult LoadNext(const QUrl& url);
53
 
 
54
 
  virtual PlaylistItem::Options playlistitem_options() const { return PlaylistItem::Default; }
55
 
 
56
 
  virtual QWidget* HeaderWidget() const { return NULL; }
57
 
 
58
 
  virtual void ReloadSettings() {}
59
 
 
60
 
  virtual QString Icon() { return QString(); }
61
 
 
62
 
signals:
63
 
  void AsyncLoadFinished(const PlaylistItem::SpecialLoadResult& result);
64
 
  void StreamError(const QString& message);
65
 
  void StreamMetadataFound(const QUrl& original_url, const Song& song);
66
 
  void OpenSettingsAtPage(SettingsDialog::Page page);
67
 
 
68
 
  void AddToPlaylistSignal(QMimeData* data);
69
 
 
70
 
private slots:
71
 
  void AppendToPlaylist();
72
 
  void ReplacePlaylist();
73
 
  void OpenInNewPlaylist();
74
 
 
75
 
protected:
76
 
  // Subclass provides the currently selected QModelIndex on RadioService's
77
 
  // request.
78
 
  virtual QModelIndex GetCurrentIndex() = 0;
79
 
 
80
 
  // Returns all the playlist insertion related QActions (see below).
81
 
  QList<QAction*> GetPlaylistActions();
82
 
 
83
 
  // Returns the 'append to playlist' QAction.
84
 
  QAction* GetAppendToPlaylistAction();
85
 
  // Returns the 'replace playlist' QAction.
86
 
  QAction* GetReplacePlaylistAction();
87
 
  // Returns the 'open in new playlist' QAction.
88
 
  QAction* GetOpenInNewPlaylistAction();
89
 
 
90
 
  // Describes how songs should be added to playlist.
91
 
  enum AddMode {
92
 
    // appends songs to the current playlist
93
 
    AddMode_Append,
94
 
    // clears the current playlist and then appends all songs to it
95
 
    AddMode_Replace,
96
 
    // creates a new, empty playlist and then adds all songs to it
97
 
    AddMode_OpenInNew
98
 
  };
99
 
 
100
 
  // Adds the 'index' element to playlist using the 'add_mode' mode.
101
 
  void AddItemToPlaylist(const QModelIndex& index, AddMode add_mode);
102
 
  // Adds the 'indexes' elements to playlist using the 'add_mode' mode.
103
 
  void AddItemsToPlaylist(const QModelIndexList& indexes, AddMode add_mode);
104
 
 
105
 
private:
106
 
  RadioModel* model_;
107
 
  QString name_;
108
 
 
109
 
  QAction* append_to_playlist_;
110
 
  QAction* replace_playlist_;
111
 
  QAction* open_in_new_playlist_;
112
 
  QAction* separator_;
113
 
};
114
 
 
115
 
Q_DECLARE_METATYPE(RadioService*);
116
 
 
117
 
#endif // RADIOSERVICE_H