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 MAGNATUNESERVICE_H
19
#define MAGNATUNESERVICE_H
21
#include <QXmlStreamReader>
23
#include "radioservice.h"
25
class QNetworkAccessManager;
26
class QSortFilterProxyModel;
32
class MagnatuneService : public RadioService {
36
MagnatuneService(RadioModel* parent);
39
// Values are saved in QSettings and are indices into the combo box in
43
Membership_Streaming = 1,
44
Membership_Download = 2,
47
// Values are saved in QSettings and are indices into the combo box in
49
enum PreferredFormat {
57
static const char* kServiceName;
58
static const char* kSettingsGroup;
59
static const char* kDatabaseUrl;
60
static const char* kSongsTable;
61
static const char* kFtsTable;
62
static const char* kHomepage;
63
static const char* kStreamingHostname;
64
static const char* kDownloadHostname;
65
static const char* kPartnerId;
66
static const char* kDownloadUrl;
68
static QString ReadElementText(QXmlStreamReader& reader);
70
QStandardItem* CreateRootItem();
71
void LazyPopulate(QStandardItem* item);
73
void ShowContextMenu(const QModelIndex& index, const QPoint& global_pos);
75
QWidget* HeaderWidget() const;
77
void ReloadSettings();
79
// Magnatune specific stuff
80
MembershipType membership_type() const { return membership_; }
81
PreferredFormat preferred_format() const { return format_; }
82
QString username() const { return username_; }
83
QString password() const { return password_; }
84
LibraryBackend* library_backend() const { return library_backend_; }
86
QUrl ModifyUrl(const QUrl& url) const;
89
void DownloadFinished(const QStringList& albums);
92
QModelIndex GetCurrentIndex();
95
void UpdateTotalSongCount(int count);
96
void ReloadDatabase();
97
void ReloadDatabaseFinished();
104
void EnsureMenuCreated();
106
Song ReadTrack(QXmlStreamReader& reader);
109
QMenu* context_menu_;
110
QModelIndex context_item_;
111
QStandardItem* root_;
115
LibraryBackend* library_backend_;
116
LibraryModel* library_model_;
117
LibraryFilterWidget* library_filter_;
118
QSortFilterProxyModel* library_sort_model_;
119
int load_database_task_id_;
121
MembershipType membership_;
124
PreferredFormat format_;
126
int total_song_count_;
128
QNetworkAccessManager* network_;
131
#endif // MAGNATUNESERVICE_H