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

« back to all changes in this revision

Viewing changes to src/radio/jamendoservice.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 JAMENDOSERVICE_H
19
 
#define JAMENDOSERVICE_H
20
 
 
21
 
#include "radioservice.h"
22
 
 
23
 
#include <QXmlStreamReader>
24
 
 
25
 
#include "core/song.h"
26
 
 
27
 
class LibraryBackend;
28
 
class LibraryFilterWidget;
29
 
class LibraryModel;
30
 
class NetworkAccessManager;
31
 
class QIODevice;
32
 
class QMenu;
33
 
class QSortFilterProxyModel;
34
 
 
35
 
class JamendoService : public RadioService {
36
 
  Q_OBJECT
37
 
 public:
38
 
  JamendoService(RadioModel* parent);
39
 
  ~JamendoService();
40
 
 
41
 
  QStandardItem* CreateRootItem();
42
 
  void LazyPopulate(QStandardItem* item);
43
 
 
44
 
  void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
45
 
 
46
 
  QWidget* HeaderWidget() const;
47
 
 
48
 
  LibraryBackend* library_backend() const { return library_backend_; }
49
 
 
50
 
  static const char* kServiceName;
51
 
  static const char* kDirectoryUrl;
52
 
  static const char* kMp3StreamUrl;
53
 
  static const char* kOggStreamUrl;
54
 
  static const char* kAlbumCoverUrl;
55
 
  static const char* kAlbumInfoUrl;
56
 
  static const char* kDownloadAlbumUrl;
57
 
  static const char* kHomepage;
58
 
 
59
 
  static const char* kSongsTable;
60
 
  static const char* kFtsTable;
61
 
  static const char* kTrackIdsTable;
62
 
  static const char* kTrackIdsColumn;
63
 
 
64
 
  static const char* kSettingsGroup;
65
 
 
66
 
  static const int kBatchSize;
67
 
  static const int kApproxDatabaseSize;
68
 
 
69
 
 protected:
70
 
  QModelIndex GetCurrentIndex();
71
 
 
72
 
 private:
73
 
  void ParseDirectory(QIODevice* device) const;
74
 
 
75
 
  typedef QList<int> TrackIdList;
76
 
 
77
 
  SongList ReadArtist(QXmlStreamReader* reader, TrackIdList* track_ids) const;
78
 
  SongList ReadAlbum(const QString& artist, QXmlStreamReader* reader,
79
 
                     TrackIdList* track_ids) const;
80
 
  Song ReadTrack(const QString& artist,
81
 
                 const QString& album,
82
 
                 const QString& album_cover,
83
 
                 int album_id,
84
 
                 QXmlStreamReader* reader,
85
 
                 TrackIdList* track_ids) const;
86
 
  void InsertTrackIds(const TrackIdList& ids) const;
87
 
 
88
 
  void EnsureMenuCreated();
89
 
 
90
 
 private slots:
91
 
  void DownloadDirectory();
92
 
  void DownloadDirectoryProgress(qint64 received, qint64 total);
93
 
  void DownloadDirectoryFinished();
94
 
  void ParseDirectoryFinished();
95
 
  void UpdateTotalSongCount(int count);
96
 
 
97
 
  void AlbumInfo();
98
 
  void DownloadAlbum();
99
 
  void Homepage();
100
 
 
101
 
 private:
102
 
  NetworkAccessManager* network_;
103
 
 
104
 
  QMenu* context_menu_;
105
 
  QModelIndex context_item_;
106
 
 
107
 
  QAction* album_info_;
108
 
  QAction* download_album_;
109
 
 
110
 
  LibraryBackend* library_backend_;
111
 
  LibraryFilterWidget* library_filter_;
112
 
  LibraryModel* library_model_;
113
 
  QSortFilterProxyModel* library_sort_model_;
114
 
 
115
 
  int load_database_task_id_;
116
 
 
117
 
  int total_song_count_;
118
 
};
119
 
 
120
 
#endif