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 JAMENDOSERVICE_H
19
#define JAMENDOSERVICE_H
21
#include "radioservice.h"
23
#include <QXmlStreamReader>
25
#include "core/song.h"
28
class LibraryFilterWidget;
30
class NetworkAccessManager;
33
class QSortFilterProxyModel;
35
class JamendoService : public RadioService {
38
JamendoService(RadioModel* parent);
41
QStandardItem* CreateRootItem();
42
void LazyPopulate(QStandardItem* item);
44
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
46
QWidget* HeaderWidget() const;
48
LibraryBackend* library_backend() const { return library_backend_; }
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;
59
static const char* kSongsTable;
60
static const char* kFtsTable;
61
static const char* kTrackIdsTable;
62
static const char* kTrackIdsColumn;
64
static const char* kSettingsGroup;
66
static const int kBatchSize;
67
static const int kApproxDatabaseSize;
70
QModelIndex GetCurrentIndex();
73
void ParseDirectory(QIODevice* device) const;
75
typedef QList<int> TrackIdList;
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,
82
const QString& album_cover,
84
QXmlStreamReader* reader,
85
TrackIdList* track_ids) const;
86
void InsertTrackIds(const TrackIdList& ids) const;
88
void EnsureMenuCreated();
91
void DownloadDirectory();
92
void DownloadDirectoryProgress(qint64 received, qint64 total);
93
void DownloadDirectoryFinished();
94
void ParseDirectoryFinished();
95
void UpdateTotalSongCount(int count);
102
NetworkAccessManager* network_;
104
QMenu* context_menu_;
105
QModelIndex context_item_;
107
QAction* album_info_;
108
QAction* download_album_;
110
LibraryBackend* library_backend_;
111
LibraryFilterWidget* library_filter_;
112
LibraryModel* library_model_;
113
QSortFilterProxyModel* library_sort_model_;
115
int load_database_task_id_;
117
int total_song_count_;