diff --git a/src/globalsearch/icecastsearchprovider.cpp b/src/globalsearch/icecastsearchprovider.cpp index c890d1ac6..eb2f58807 100644 --- a/src/globalsearch/icecastsearchprovider.cpp +++ b/src/globalsearch/icecastsearchprovider.cpp @@ -16,11 +16,12 @@ */ #include "icecastsearchprovider.h" + #include "internet/icecast/icecastbackend.h" #include "ui/iconloader.h" -IcecastSearchProvider::IcecastSearchProvider(IcecastBackend* backend, - Application* app, QObject* parent) +IcecastSearchProvider::IcecastSearchProvider( + std::shared_ptr backend, Application* app, QObject* parent) : BlockingSearchProvider(app, parent), backend_(backend) { Init("Icecast", "icecast", IconLoader::Load("icon_radio", IconLoader::Lastfm), DisabledByDefault); diff --git a/src/globalsearch/icecastsearchprovider.h b/src/globalsearch/icecastsearchprovider.h index f8350dbcb..6ee0c7f60 100644 --- a/src/globalsearch/icecastsearchprovider.h +++ b/src/globalsearch/icecastsearchprovider.h @@ -18,19 +18,21 @@ #ifndef ICECASTSEARCHPROVIDER_H #define ICECASTSEARCHPROVIDER_H +#include + #include "searchprovider.h" class IcecastBackend; class IcecastSearchProvider : public BlockingSearchProvider { public: - IcecastSearchProvider(IcecastBackend* backend, Application* app, - QObject* parent); + IcecastSearchProvider(std::shared_ptr backend, + Application* app, QObject* parent); ResultList Search(int id, const QString& query); private: - IcecastBackend* backend_; + std::shared_ptr backend_; }; #endif // ICECASTSEARCHPROVIDER_H diff --git a/src/internet/icecast/icecastmodel.cpp b/src/internet/icecast/icecastmodel.cpp index 3c1d4bfab..7a54c7cff 100644 --- a/src/internet/icecast/icecastmodel.cpp +++ b/src/internet/icecast/icecastmodel.cpp @@ -23,7 +23,8 @@ #include "playlist/songmimedata.h" #include "ui/iconloader.h" -IcecastModel::IcecastModel(IcecastBackend* backend, QObject* parent) +IcecastModel::IcecastModel(std::shared_ptr backend, + QObject* parent) : SimpleTreeModel(new IcecastItem(this), parent), backend_(backend), sort_mode_(SortMode_GenreByPopularity), @@ -35,7 +36,7 @@ IcecastModel::IcecastModel(IcecastBackend* backend, QObject* parent) IcecastModel::~IcecastModel() { delete root_; } void IcecastModel::Init() { - connect(backend_, SIGNAL(DatabaseReset()), SLOT(Reset())); + connect(backend_.get(), SIGNAL(DatabaseReset()), SLOT(Reset())); Reset(); } diff --git a/src/internet/icecast/icecastmodel.h b/src/internet/icecast/icecastmodel.h index ba85f7e88..891ae5ed2 100644 --- a/src/internet/icecast/icecastmodel.h +++ b/src/internet/icecast/icecastmodel.h @@ -20,11 +20,12 @@ #ifndef INTERNET_ICECAST_ICECASTMODEL_H_ #define INTERNET_ICECAST_ICECASTMODEL_H_ -#include "icecastitem.h" -#include "core/simpletreemodel.h" -#include "library/librarymodel.h" - #include +#include + +#include "core/simpletreemodel.h" +#include "icecastitem.h" +#include "library/librarymodel.h" class IcecastBackend; @@ -32,7 +33,8 @@ class IcecastModel : public SimpleTreeModel { Q_OBJECT public: - explicit IcecastModel(IcecastBackend* backend, QObject* parent = nullptr); + explicit IcecastModel(std::shared_ptr backend, + QObject* parent = nullptr); ~IcecastModel(); // These values get saved in QSettings - don't change them @@ -46,8 +48,6 @@ class IcecastModel : public SimpleTreeModel { Role_IsDivider = LibraryModel::Role_IsDivider, }; - IcecastBackend* backend() const { return backend_; } - Song GetSong(const QModelIndex& index) const; // QAbstractItemModel @@ -76,7 +76,7 @@ class IcecastModel : public SimpleTreeModel { static QString DividerDisplayText(const QChar& key); private: - IcecastBackend* backend_; + std::shared_ptr backend_; QString filter_; SortMode sort_mode_; diff --git a/src/internet/icecast/icecastservice.cpp b/src/internet/icecast/icecastservice.cpp index 84b46a03f..3dcc746e5 100644 --- a/src/internet/icecast/icecastservice.cpp +++ b/src/internet/icecast/icecastservice.cpp @@ -57,10 +57,9 @@ IcecastService::IcecastService(Application* app, InternetModel* parent) : InternetService(kServiceName, app, parent, parent), network_(new NetworkAccessManager(this)), context_menu_(nullptr), - backend_(nullptr), + backend_(new IcecastBackend), model_(nullptr), filter_(new IcecastFilterWidget(0)) { - backend_ = new IcecastBackend; backend_->moveToThread(app_->database()->thread()); backend_->Init(app_->database()); diff --git a/src/internet/icecast/icecastservice.h b/src/internet/icecast/icecastservice.h index bdf43149f..0249afa4a 100644 --- a/src/internet/icecast/icecastservice.h +++ b/src/internet/icecast/icecastservice.h @@ -23,6 +23,7 @@ #include "internet/core/internetservice.h" +#include #include #include "icecastbackend.h" @@ -75,7 +76,7 @@ class IcecastService : public InternetService { NetworkAccessManager* network_; QMenu* context_menu_; - IcecastBackend* backend_; + std::shared_ptr backend_; IcecastModel* model_; IcecastFilterWidget* filter_; };