Rename class InternetModel to InternetServices
This commit is contained in:
@@ -260,7 +260,7 @@ set(SOURCES
|
|||||||
globalshortcuts/qxtglobalshortcutbackend.cpp
|
globalshortcuts/qxtglobalshortcutbackend.cpp
|
||||||
globalshortcuts/globalshortcutgrabber.cpp
|
globalshortcuts/globalshortcutgrabber.cpp
|
||||||
|
|
||||||
internet/internetmodel.cpp
|
internet/internetservices.cpp
|
||||||
internet/internetservice.cpp
|
internet/internetservice.cpp
|
||||||
internet/internetplaylistitem.cpp
|
internet/internetplaylistitem.cpp
|
||||||
internet/internetsearch.cpp
|
internet/internetsearch.cpp
|
||||||
@@ -422,9 +422,8 @@ set(HEADERS
|
|||||||
globalshortcuts/gnomeglobalshortcutbackend.h
|
globalshortcuts/gnomeglobalshortcutbackend.h
|
||||||
globalshortcuts/globalshortcutgrabber.h
|
globalshortcuts/globalshortcutgrabber.h
|
||||||
|
|
||||||
internet/internetmodel.h
|
internet/internetservices.h
|
||||||
internet/internetservice.h
|
internet/internetservice.h
|
||||||
internet/internetmimedata.h
|
|
||||||
internet/internetsongmimedata.h
|
internet/internetsongmimedata.h
|
||||||
internet/internetsearch.h
|
internet/internetsearch.h
|
||||||
internet/internetsearchview.h
|
internet/internetsearchview.h
|
||||||
|
|||||||
@@ -60,9 +60,16 @@
|
|||||||
#include "lyrics/auddlyricsprovider.h"
|
#include "lyrics/auddlyricsprovider.h"
|
||||||
#include "lyrics/apiseedslyricsprovider.h"
|
#include "lyrics/apiseedslyricsprovider.h"
|
||||||
|
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
|
# include "tidal/tidalservice.h"
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STREAM_DEEZER
|
||||||
|
# include "deezer/deezerservice.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Application::kIsPortable = false;
|
bool Application::kIsPortable = false;
|
||||||
|
|
||||||
class ApplicationImpl {
|
class ApplicationImpl {
|
||||||
@@ -116,7 +123,16 @@ class ApplicationImpl {
|
|||||||
lyrics_providers->AddProvider(new APISeedsLyricsProvider(app));
|
lyrics_providers->AddProvider(new APISeedsLyricsProvider(app));
|
||||||
return lyrics_providers;
|
return lyrics_providers;
|
||||||
}),
|
}),
|
||||||
internet_model_([=]() { return new InternetModel(app, app); }),
|
internet_services_([=]() {
|
||||||
|
InternetServices *internet_services = new InternetServices(app);
|
||||||
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
|
internet_services->AddService(new TidalService(app, internet_services));
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_STREAM_DEEZER
|
||||||
|
internet_services->AddService(new DeezerService(app, internet_services));
|
||||||
|
#endif
|
||||||
|
return internet_services;
|
||||||
|
}),
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
tidal_search_([=]() { return new InternetSearch(app, Song::Source_Tidal, app); }),
|
tidal_search_([=]() { return new InternetSearch(app, Song::Source_Tidal, app); }),
|
||||||
#endif
|
#endif
|
||||||
@@ -142,7 +158,7 @@ class ApplicationImpl {
|
|||||||
Lazy<AlbumCoverLoader> album_cover_loader_;
|
Lazy<AlbumCoverLoader> album_cover_loader_;
|
||||||
Lazy<CurrentArtLoader> current_art_loader_;
|
Lazy<CurrentArtLoader> current_art_loader_;
|
||||||
Lazy<LyricsProviders> lyrics_providers_;
|
Lazy<LyricsProviders> lyrics_providers_;
|
||||||
Lazy<InternetModel> internet_model_;
|
Lazy<InternetServices> internet_services_;
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
Lazy<InternetSearch> tidal_search_;
|
Lazy<InternetSearch> tidal_search_;
|
||||||
#endif
|
#endif
|
||||||
@@ -216,7 +232,7 @@ CurrentArtLoader *Application::current_art_loader() const { return p_->current_a
|
|||||||
LyricsProviders *Application::lyrics_providers() const { return p_->lyrics_providers_.get(); }
|
LyricsProviders *Application::lyrics_providers() const { return p_->lyrics_providers_.get(); }
|
||||||
PlaylistBackend *Application::playlist_backend() const { return p_->playlist_backend_.get(); }
|
PlaylistBackend *Application::playlist_backend() const { return p_->playlist_backend_.get(); }
|
||||||
PlaylistManager *Application::playlist_manager() const { return p_->playlist_manager_.get(); }
|
PlaylistManager *Application::playlist_manager() const { return p_->playlist_manager_.get(); }
|
||||||
InternetModel *Application::internet_model() const { return p_->internet_model_.get(); }
|
InternetServices *Application::internet_services() const { return p_->internet_services_.get(); }
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
InternetSearch *Application::tidal_search() const { return p_->tidal_search_.get(); }
|
InternetSearch *Application::tidal_search() const { return p_->tidal_search_.get(); }
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class CoverProviders;
|
|||||||
class AlbumCoverLoader;
|
class AlbumCoverLoader;
|
||||||
class CurrentArtLoader;
|
class CurrentArtLoader;
|
||||||
class LyricsProviders;
|
class LyricsProviders;
|
||||||
class InternetModel;
|
class InternetServices;
|
||||||
class InternetSearch;
|
class InternetSearch;
|
||||||
|
|
||||||
class Application : public QObject {
|
class Application : public QObject {
|
||||||
@@ -89,7 +89,7 @@ class Application : public QObject {
|
|||||||
|
|
||||||
LyricsProviders *lyrics_providers() const;
|
LyricsProviders *lyrics_providers() const;
|
||||||
|
|
||||||
InternetModel *internet_model() const;
|
InternetServices *internet_services() const;
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
#ifdef HAVE_STREAM_TIDAL
|
||||||
InternetSearch *tidal_search() const;
|
InternetSearch *tidal_search() const;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -140,7 +140,7 @@
|
|||||||
# include "settings/deezersettingspage.h"
|
# include "settings/deezersettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetservice.h"
|
#include "internet/internetservice.h"
|
||||||
#include "internet/internetsearchview.h"
|
#include "internet/internetsearchview.h"
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
#include "settings/backendsettingspage.h"
|
#include "settings/backendsettingspage.h"
|
||||||
#include "settings/behavioursettingspage.h"
|
#include "settings/behavioursettingspage.h"
|
||||||
#include "settings/playlistsettingspage.h"
|
#include "settings/playlistsettingspage.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetservice.h"
|
#include "internet/internetservice.h"
|
||||||
|
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void CoverProviders::RemoveProvider(CoverProvider *provider) {
|
|||||||
|
|
||||||
if (!provider) return;
|
if (!provider) return;
|
||||||
|
|
||||||
// It's not safe to dereference provider at this pointbecause it might have already been destroyed.
|
// It's not safe to dereference provider at this point because it might have already been destroyed.
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
#include "core/taskmanager.h"
|
#include "core/taskmanager.h"
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
#include "internet/localredirectserver.h"
|
#include "internet/localredirectserver.h"
|
||||||
#include "deezerservice.h"
|
#include "deezerservice.h"
|
||||||
@@ -71,8 +71,8 @@ const char *DeezerService::kSecretKey = "06911976010b9ddd7256769adf2b2e56";
|
|||||||
|
|
||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
|
|
||||||
DeezerService::DeezerService(Application *app, InternetModel *parent)
|
DeezerService::DeezerService(Application *app, QObject *parent)
|
||||||
: InternetService(Song::Source_Deezer, "Deezer", "dzmedia", app, parent, parent),
|
: InternetService(Song::Source_Deezer, "Deezer", "dzmedia", app, parent),
|
||||||
network_(new NetworkAccessManager(this)),
|
network_(new NetworkAccessManager(this)),
|
||||||
url_handler_(new DeezerUrlHandler(app, this)),
|
url_handler_(new DeezerUrlHandler(app, this)),
|
||||||
#ifdef HAVE_DZMEDIA
|
#ifdef HAVE_DZMEDIA
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetservice.h"
|
#include "internet/internetservice.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ class DeezerService : public InternetService {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeezerService(Application *app, InternetModel *parent);
|
DeezerService(Application *app, QObject *parent);
|
||||||
~DeezerService();
|
~DeezerService();
|
||||||
|
|
||||||
static const Song::Source kSource;
|
static const Song::Source kSource;
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Strawberry Music Player
|
|
||||||
* This file was part of Clementine.
|
|
||||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
|
||||||
*
|
|
||||||
* Strawberry 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.
|
|
||||||
*
|
|
||||||
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef INTERNETMIMEDATA_H
|
|
||||||
#define INTERNETMIMEDATA_H
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QModelIndexList>
|
|
||||||
|
|
||||||
#include "core/mimedata.h"
|
|
||||||
|
|
||||||
class InternetModel;
|
|
||||||
|
|
||||||
class InternetMimeData : public MimeData {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit InternetMimeData(const InternetModel *_model) : model(_model) {}
|
|
||||||
|
|
||||||
const InternetModel *model;
|
|
||||||
QModelIndexList indexes;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -28,8 +28,8 @@
|
|||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "internetplaylistitem.h"
|
#include "internetplaylistitem.h"
|
||||||
|
#include "internetservices.h"
|
||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
#include "internetmodel.h"
|
|
||||||
#include "core/settingsprovider.h"
|
#include "core/settingsprovider.h"
|
||||||
#include "collection/sqlrow.h"
|
#include "collection/sqlrow.h"
|
||||||
#include "playlist/playlistbackend.h"
|
#include "playlist/playlistbackend.h"
|
||||||
@@ -50,11 +50,6 @@ bool InternetPlaylistItem::InitFromQuery(const SqlRow &query) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InternetService *InternetPlaylistItem::service() const {
|
|
||||||
InternetService *ret = InternetModel::ServiceBySource(source_);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant InternetPlaylistItem::DatabaseValue(DatabaseColumn column) const {
|
QVariant InternetPlaylistItem::DatabaseValue(DatabaseColumn column) const {
|
||||||
return PlaylistItem::DatabaseValue(column);
|
return PlaylistItem::DatabaseValue(column);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ class InternetPlaylistItem : public PlaylistItem {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void InitMetadata();
|
void InitMetadata();
|
||||||
InternetService *service() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Song::Source source_;
|
Song::Source source_;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
#include "playlist/songmimedata.h"
|
#include "playlist/songmimedata.h"
|
||||||
#include "internetsearch.h"
|
#include "internetsearch.h"
|
||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
#include "internetmodel.h"
|
#include "internetservices.h"
|
||||||
|
|
||||||
using std::advance;
|
using std::advance;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ InternetSearch::InternetSearch(Application *app, Song::Source source, QObject *p
|
|||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
app_(app),
|
app_(app),
|
||||||
source_(source),
|
source_(source),
|
||||||
service_(app->internet_model()->ServiceBySource(source)),
|
service_(app->internet_services()->ServiceBySource(source)),
|
||||||
searches_next_id_(1),
|
searches_next_id_(1),
|
||||||
art_searches_next_id_(1) {
|
art_searches_next_id_(1) {
|
||||||
|
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/mimedata.h"
|
#include "core/mimedata.h"
|
||||||
#include "internetmodel.h"
|
#include "internetservices.h"
|
||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
|
|
||||||
InternetService::InternetService(Song::Source source, const QString &name, const QString &url_scheme, Application *app, InternetModel *model, QObject *parent)
|
InternetService::InternetService(Song::Source source, const QString &name, const QString &url_scheme, Application *app, QObject *parent)
|
||||||
: QObject(parent), app_(app), model_(model), source_(source), name_(name), url_scheme_(url_scheme) {
|
: QObject(parent), app_(app), source_(source), name_(name), url_scheme_(url_scheme) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,19 +36,18 @@
|
|||||||
#include "internetsearch.h"
|
#include "internetsearch.h"
|
||||||
|
|
||||||
class Application;
|
class Application;
|
||||||
class InternetModel;
|
class InternetServices;
|
||||||
class CollectionFilterWidget;
|
class CollectionFilterWidget;
|
||||||
|
|
||||||
class InternetService : public QObject {
|
class InternetService : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InternetService(Song::Source source, const QString &name, const QString &url_scheme, Application *app, InternetModel *model, QObject *parent = nullptr);
|
InternetService(Song::Source source, const QString &name, const QString &url_scheme, Application *app, QObject *parent = nullptr);
|
||||||
virtual ~InternetService() {}
|
virtual ~InternetService() {}
|
||||||
virtual Song::Source source() const { return source_; }
|
virtual Song::Source source() const { return source_; }
|
||||||
virtual QString name() const { return name_; }
|
virtual QString name() const { return name_; }
|
||||||
virtual QString url_scheme() const { return url_scheme_; }
|
virtual QString url_scheme() const { return url_scheme_; }
|
||||||
virtual InternetModel *model() const { return model_; }
|
|
||||||
virtual bool has_initial_load_settings() const { return false; }
|
virtual bool has_initial_load_settings() const { return false; }
|
||||||
virtual void InitialLoadSettings() {}
|
virtual void InitialLoadSettings() {}
|
||||||
virtual void ReloadSettings() {}
|
virtual void ReloadSettings() {}
|
||||||
@@ -62,7 +61,6 @@ class InternetService : public QObject {
|
|||||||
protected:
|
protected:
|
||||||
Application *app_;
|
Application *app_;
|
||||||
private:
|
private:
|
||||||
InternetModel *model_;
|
|
||||||
Song::Source source_;
|
Song::Source source_;
|
||||||
QString name_;
|
QString name_;
|
||||||
QString url_scheme_;
|
QString url_scheme_;
|
||||||
|
|||||||
@@ -24,70 +24,50 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStandardItemModel>
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "internetmodel.h"
|
#include "internetservices.h"
|
||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
|
||||||
# include "tidal/tidalservice.h"
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STREAM_DEEZER
|
|
||||||
# include "deezer/deezerservice.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QMap<Song::Source, InternetService*>* InternetModel::sServices = nullptr;
|
InternetServices::InternetServices(QObject *parent) : QObject(parent) {}
|
||||||
|
InternetServices::~InternetServices() {}
|
||||||
|
|
||||||
InternetModel::InternetModel(Application *app, QObject *parent)
|
void InternetServices::AddService(InternetService *service) {
|
||||||
: QStandardItemModel(parent),
|
|
||||||
app_(app) {
|
|
||||||
|
|
||||||
if (!sServices) sServices = new QMap<Song::Source, InternetService*>;
|
services_.insert(service->source(), service);
|
||||||
Q_ASSERT(sServices->isEmpty());
|
|
||||||
#ifdef HAVE_STREAM_TIDAL
|
|
||||||
AddService(new TidalService(app, this));
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_STREAM_DEEZER
|
|
||||||
AddService(new DeezerService(app, this));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void InternetModel::AddService(InternetService *service) {
|
|
||||||
|
|
||||||
qLog(Debug) << "Adding internet service:" << service->name();
|
|
||||||
sServices->insert(service->source(), service);
|
|
||||||
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));
|
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));
|
||||||
if (service->has_initial_load_settings()) service->InitialLoadSettings();
|
if (service->has_initial_load_settings()) service->InitialLoadSettings();
|
||||||
else service->ReloadSettings();
|
else service->ReloadSettings();
|
||||||
|
|
||||||
|
qLog(Debug) << "Added internet service" << service->name();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InternetModel::RemoveService(InternetService *service) {
|
void InternetServices::RemoveService(InternetService *service) {
|
||||||
|
|
||||||
if (!sServices->contains(service->source())) return;
|
if (!services_.contains(service->source())) return;
|
||||||
sServices->remove(service->source());
|
services_.remove(service->source());
|
||||||
disconnect(service, 0, this, 0);
|
disconnect(service, 0, this, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InternetModel::ServiceDeleted() {
|
void InternetServices::ServiceDeleted() {
|
||||||
|
|
||||||
InternetService *service = qobject_cast<InternetService*>(sender());
|
InternetService *service = qobject_cast<InternetService*>(sender());
|
||||||
if (service) RemoveService(service);
|
if (service) RemoveService(service);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InternetService *InternetModel::ServiceBySource(const Song::Source &source) {
|
InternetService *InternetServices::ServiceBySource(const Song::Source &source) {
|
||||||
|
|
||||||
if (sServices->contains(source)) return sServices->value(source);
|
if (services_.contains(source)) return services_.value(source);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InternetModel::ReloadSettings() {
|
void InternetServices::ReloadSettings() {
|
||||||
for (InternetService *service : sServices->values()) {
|
for (InternetService *service : services_.values()) {
|
||||||
service->ReloadSettings();
|
service->ReloadSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef INTERNETMODEL_H
|
#ifndef INTERNETSERVICES_H
|
||||||
#define INTERNETMODEL_H
|
#define INTERNETSERVICES_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
@@ -39,11 +39,12 @@
|
|||||||
class Application;
|
class Application;
|
||||||
class InternetService;
|
class InternetService;
|
||||||
|
|
||||||
class InternetModel : public QStandardItemModel {
|
class InternetServices : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InternetModel(Application* app, QObject *parent = nullptr);
|
explicit InternetServices(QObject *parent = nullptr);
|
||||||
|
~InternetServices();
|
||||||
|
|
||||||
enum Role {
|
enum Role {
|
||||||
// Services can use this role to distinguish between different types of items that they add.
|
// Services can use this role to distinguish between different types of items that they add.
|
||||||
@@ -104,12 +105,10 @@ class InternetModel : public QStandardItemModel {
|
|||||||
PlayBehaviour_DoubleClickAction,
|
PlayBehaviour_DoubleClickAction,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Needs to be static for InternetPlaylistItem::restore
|
InternetService *ServiceBySource(const Song::Source &source);
|
||||||
static InternetService *ServiceBySource(const Song::Source &source);
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T *Service() {
|
T *Service() {
|
||||||
return static_cast<T*>(ServiceBySource(T::kSource));
|
return static_cast<T*>(this->ServiceBySource(T::kSource));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add and remove services. Ownership is not transferred and the service is not reparented.
|
// Add and remove services. Ownership is not transferred and the service is not reparented.
|
||||||
@@ -118,14 +117,11 @@ class InternetModel : public QStandardItemModel {
|
|||||||
void RemoveService(InternetService *service);
|
void RemoveService(InternetService *service);
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|
||||||
Application *app() const { return app_; }
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ServiceDeleted();
|
void ServiceDeleted();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QMap<Song::Source, InternetService*> *sServices;
|
QMap<Song::Source, InternetService*> services_;
|
||||||
Application *app_;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,9 +85,8 @@
|
|||||||
#include "songplaylistitem.h"
|
#include "songplaylistitem.h"
|
||||||
#include "tagreadermessages.pb.h"
|
#include "tagreadermessages.pb.h"
|
||||||
|
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetplaylistitem.h"
|
#include "internet/internetplaylistitem.h"
|
||||||
#include "internet/internetmimedata.h"
|
|
||||||
#include "internet/internetsongmimedata.h"
|
#include "internet/internetsongmimedata.h"
|
||||||
|
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class PlaylistBackend;
|
|||||||
class PlaylistFilter;
|
class PlaylistFilter;
|
||||||
class Queue;
|
class Queue;
|
||||||
class TaskManager;
|
class TaskManager;
|
||||||
class InternetModel;
|
class InternetServices;
|
||||||
class InternetService;
|
class InternetService;
|
||||||
|
|
||||||
namespace PlaylistUndoCommands {
|
namespace PlaylistUndoCommands {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "ui_deezersettingspage.h"
|
#include "ui_deezersettingspage.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/iconloader.h"
|
#include "core/iconloader.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "deezer/deezerservice.h"
|
#include "deezer/deezerservice.h"
|
||||||
|
|
||||||
const char *DeezerSettingsPage::kSettingsGroup = "Deezer";
|
const char *DeezerSettingsPage::kSettingsGroup = "Deezer";
|
||||||
@@ -37,7 +37,7 @@ const char *DeezerSettingsPage::kSettingsGroup = "Deezer";
|
|||||||
DeezerSettingsPage::DeezerSettingsPage(SettingsDialog *parent)
|
DeezerSettingsPage::DeezerSettingsPage(SettingsDialog *parent)
|
||||||
: SettingsPage(parent),
|
: SettingsPage(parent),
|
||||||
ui_(new Ui::DeezerSettingsPage),
|
ui_(new Ui::DeezerSettingsPage),
|
||||||
service_(dialog()->app()->internet_model()->Service<DeezerService>()) {
|
service_(dialog()->app()->internet_services()->Service<DeezerService>()) {
|
||||||
|
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
setWindowIcon(IconLoader::Load("deezer"));
|
setWindowIcon(IconLoader::Load("deezer"));
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
#include "ui_tidalsettingspage.h"
|
#include "ui_tidalsettingspage.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/iconloader.h"
|
#include "core/iconloader.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "tidal/tidalservice.h"
|
#include "tidal/tidalservice.h"
|
||||||
|
|
||||||
const char *TidalSettingsPage::kSettingsGroup = "Tidal";
|
const char *TidalSettingsPage::kSettingsGroup = "Tidal";
|
||||||
@@ -37,7 +37,7 @@ const char *TidalSettingsPage::kSettingsGroup = "Tidal";
|
|||||||
TidalSettingsPage::TidalSettingsPage(SettingsDialog *parent)
|
TidalSettingsPage::TidalSettingsPage(SettingsDialog *parent)
|
||||||
: SettingsPage(parent),
|
: SettingsPage(parent),
|
||||||
ui_(new Ui::TidalSettingsPage),
|
ui_(new Ui::TidalSettingsPage),
|
||||||
service_(dialog()->app()->internet_model()->Service<TidalService>()) {
|
service_(dialog()->app()->internet_services()->Service<TidalService>()) {
|
||||||
|
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
setWindowIcon(IconLoader::Load("tidal"));
|
setWindowIcon(IconLoader::Load("tidal"));
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include "core/taskmanager.h"
|
#include "core/taskmanager.h"
|
||||||
#include "core/timeconstants.h"
|
#include "core/timeconstants.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
#include "tidalservice.h"
|
#include "tidalservice.h"
|
||||||
#include "tidalurlhandler.h"
|
#include "tidalurlhandler.h"
|
||||||
@@ -65,8 +65,8 @@ const int TidalService::kTimeResetLoginAttempts = 60000;
|
|||||||
|
|
||||||
typedef QPair<QString, QString> Param;
|
typedef QPair<QString, QString> Param;
|
||||||
|
|
||||||
TidalService::TidalService(Application *app, InternetModel *parent)
|
TidalService::TidalService(Application *app, QObject *parent)
|
||||||
: InternetService(Song::Source_Tidal, "Tidal", "tidal", app, parent, parent),
|
: InternetService(Song::Source_Tidal, "Tidal", "tidal", app, parent),
|
||||||
network_(new NetworkAccessManager(this)),
|
network_(new NetworkAccessManager(this)),
|
||||||
url_handler_(new TidalUrlHandler(app, this)),
|
url_handler_(new TidalUrlHandler(app, this)),
|
||||||
timer_searchdelay_(new QTimer(this)),
|
timer_searchdelay_(new QTimer(this)),
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include <QJsonValue>
|
#include <QJsonValue>
|
||||||
|
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
#include "internet/internetmodel.h"
|
#include "internet/internetservices.h"
|
||||||
#include "internet/internetservice.h"
|
#include "internet/internetservice.h"
|
||||||
#include "internet/internetsearch.h"
|
#include "internet/internetsearch.h"
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ class TidalService : public InternetService {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TidalService(Application *app, InternetModel *parent);
|
TidalService(Application *app, QObject *parent);
|
||||||
~TidalService();
|
~TidalService();
|
||||||
|
|
||||||
static const Song::Source kSource;
|
static const Song::Source kSource;
|
||||||
|
|||||||
Reference in New Issue
Block a user