Application: Use shared pointers

Fixes #1239
This commit is contained in:
Jonas Kvinge
2023-07-21 05:55:24 +02:00
parent d6b53f78ab
commit 2e61235403
316 changed files with 2170 additions and 1643 deletions

View File

@@ -36,6 +36,7 @@
#include <QMenu>
#include <QtEvents>
#include "core/shared_ptr.h"
#include "core/application.h"
#include "core/iconloader.h"
#include "core/mimedata.h"
@@ -79,11 +80,11 @@ InternetCollectionView::InternetCollectionView(QWidget *parent)
}
void InternetCollectionView::Init(Application *app, CollectionBackend *backend, CollectionModel *model, const bool favorite) {
void InternetCollectionView::Init(Application *app, SharedPtr<CollectionBackend> collection_backend, CollectionModel *collection_model, const bool favorite) {
app_ = app;
collection_backend_ = backend;
collection_model_ = model;
collection_backend_ = collection_backend;
collection_model_ = collection_model;
favorite_ = favorite;
collection_model_->set_pretty_covers(true);

View File

@@ -32,6 +32,7 @@
#include <QString>
#include <QPixmap>
#include "core/shared_ptr.h"
#include "core/song.h"
#include "widgets/autoexpandingtreeview.h"
@@ -54,7 +55,7 @@ class InternetCollectionView : public AutoExpandingTreeView {
public:
explicit InternetCollectionView(QWidget *parent = nullptr);
void Init(Application *app, CollectionBackend *backend, CollectionModel *model, const bool favorite = false);
void Init(Application *app, SharedPtr<CollectionBackend> collection_backend, CollectionModel *collection_model, const bool favorite = false);
// Returns Songs currently selected in the collection view.
// Please note that the selection is recursive meaning that if for example an album is selected this will return all of it's songs.
@@ -111,7 +112,7 @@ class InternetCollectionView : public AutoExpandingTreeView {
private:
Application *app_;
CollectionBackend *collection_backend_;
SharedPtr<CollectionBackend> collection_backend_;
CollectionModel *collection_model_;
CollectionFilterWidget *filter_;
bool favorite_;

View File

@@ -39,7 +39,7 @@ InternetPlaylistItem::InternetPlaylistItem(const Song &metadata)
InitMetadata();
}
InternetPlaylistItem::InternetPlaylistItem(InternetService *service, const Song &metadata)
InternetPlaylistItem::InternetPlaylistItem(InternetServicePtr service, const Song &metadata)
: PlaylistItem(metadata.source()),
source_(service->source()),
metadata_(metadata) {

View File

@@ -27,6 +27,7 @@
#include <QVariant>
#include <QUrl>
#include "core/shared_ptr.h"
#include "core/song.h"
#include "core/sqlrow.h"
#include "playlist/playlistitem.h"
@@ -38,7 +39,7 @@ class InternetPlaylistItem : public PlaylistItem {
public:
explicit InternetPlaylistItem(const Song::Source source);
explicit InternetPlaylistItem(const Song &metadata);
explicit InternetPlaylistItem(InternetService *service, const Song &metadata);
explicit InternetPlaylistItem(SharedPtr<InternetService> service, const Song &metadata);
bool InitFromQuery(const SqlRow &query) override;
Song Metadata() const override;

View File

@@ -37,7 +37,7 @@
#include "internetsearchmodel.h"
#include "internetsearchview.h"
InternetSearchModel::InternetSearchModel(InternetService *service, QObject *parent)
InternetSearchModel::InternetSearchModel(InternetServicePtr service, QObject *parent)
: QStandardItemModel(parent),
service_(service),
proxy_(nullptr),

View File

@@ -36,6 +36,7 @@
#include <QIcon>
#include <QPixmap>
#include "core/shared_ptr.h"
#include "core/song.h"
#include "collection/collectionmodel.h"
#include "internetsearchview.h"
@@ -50,7 +51,7 @@ class InternetSearchModel : public QStandardItemModel {
Q_OBJECT
public:
explicit InternetSearchModel(InternetService *service, QObject *parent = nullptr);
explicit InternetSearchModel(SharedPtr<InternetService> service, QObject *parent = nullptr);
enum Role {
Role_Result = CollectionModel::LastRole,
@@ -85,7 +86,7 @@ class InternetSearchModel : public QStandardItemModel {
void GetChildResults(const QStandardItem *item, InternetSearchView::ResultList *results, QSet<const QStandardItem*> *visited) const;
private:
InternetService *service_;
SharedPtr<InternetService> service_;
QSortFilterProxyModel *proxy_;
bool use_pretty_covers_;
QIcon artist_icon_;

View File

@@ -83,6 +83,8 @@
#include "ui_internetsearchview.h"
#include "settings/appearancesettingspage.h"
using std::make_unique;
const int InternetSearchView::kSwapModelsTimeoutMsec = 250;
const int InternetSearchView::kDelayedSearchTimeoutMs = 200;
const int InternetSearchView::kArtHeight = 32;
@@ -143,7 +145,7 @@ InternetSearchView::InternetSearchView(QWidget *parent)
InternetSearchView::~InternetSearchView() { delete ui_; }
void InternetSearchView::Init(Application *app, InternetService *service) {
void InternetSearchView::Init(Application *app, InternetServicePtr service) {
app_ = app;
service_ = service;
@@ -191,13 +193,13 @@ void InternetSearchView::Init(Application *app, InternetService *service) {
QObject::connect(ui_->results, &AutoExpandingTreeView::AddToPlaylistSignal, this, &InternetSearchView::AddToPlaylist);
QObject::connect(ui_->results, &AutoExpandingTreeView::FocusOnFilterSignal, this, &InternetSearchView::FocusOnFilter);
QObject::connect(service_, &InternetService::SearchUpdateStatus, this, &InternetSearchView::UpdateStatus);
QObject::connect(service_, &InternetService::SearchProgressSetMaximum, this, &InternetSearchView::ProgressSetMaximum);
QObject::connect(service_, &InternetService::SearchUpdateProgress, this, &InternetSearchView::UpdateProgress);
QObject::connect(service_, &InternetService::SearchResults, this, &InternetSearchView::SearchDone);
QObject::connect(&*service_, &InternetService::SearchUpdateStatus, this, &InternetSearchView::UpdateStatus);
QObject::connect(&*service_, &InternetService::SearchProgressSetMaximum, this, &InternetSearchView::ProgressSetMaximum);
QObject::connect(&*service_, &InternetService::SearchUpdateProgress, this, &InternetSearchView::UpdateProgress);
QObject::connect(&*service_, &InternetService::SearchResults, this, &InternetSearchView::SearchDone);
QObject::connect(app_, &Application::SettingsChanged, this, &InternetSearchView::ReloadSettings);
QObject::connect(app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &InternetSearchView::AlbumCoverLoaded);
QObject::connect(&*app_->album_cover_loader(), &AlbumCoverLoader::AlbumCoverLoaded, this, &InternetSearchView::AlbumCoverLoaded);
QObject::connect(ui_->settings, &QToolButton::clicked, ui_->settings, &QToolButton::showMenu);
@@ -679,8 +681,8 @@ void InternetSearchView::GroupByClicked(QAction *action) {
if (action->property("group_by").isNull()) {
if (!group_by_dialog_) {
group_by_dialog_ = std::make_unique<GroupByDialog>();
QObject::connect(group_by_dialog_.get(), &GroupByDialog::Accepted, this, &InternetSearchView::SetGroupBy);
group_by_dialog_ = make_unique<GroupByDialog>();
QObject::connect(&*group_by_dialog_, &GroupByDialog::Accepted, this, &InternetSearchView::SetGroupBy);
}
group_by_dialog_->show();

View File

@@ -24,8 +24,6 @@
#include "config.h"
#include <memory>
#include <QtGlobal>
#include <QObject>
#include <QWidget>
@@ -40,6 +38,8 @@
#include <QPixmap>
#include <QMetaType>
#include "core/scoped_ptr.h"
#include "core/shared_ptr.h"
#include "core/song.h"
#include "collection/collectionmodel.h"
#include "covermanager/albumcoverloaderresult.h"
@@ -81,7 +81,7 @@ class InternetSearchView : public QWidget {
};
using ResultList = QList<Result>;
void Init(Application *app, InternetService *service);
void Init(Application *app, SharedPtr<InternetService> service);
bool SearchFieldHasFocus() const;
void FocusSearchField();
@@ -183,9 +183,9 @@ class InternetSearchView : public QWidget {
private:
Application *app_;
InternetService *service_;
SharedPtr<InternetService> service_;
Ui_InternetSearchView *ui_;
std::unique_ptr<GroupByDialog> group_by_dialog_;
ScopedPtr<GroupByDialog> group_by_dialog_;
QMenu *context_menu_;
QList<QAction*> context_actions_;

View File

@@ -28,6 +28,7 @@
#include <QUrl>
#include <QIcon>
#include "core/shared_ptr.h"
#include "core/song.h"
#include "settings/settingsdialog.h"
#include "internetsearchview.h"
@@ -60,9 +61,9 @@ class InternetService : public QObject {
virtual int Search(const QString &query, InternetSearchView::SearchType type) { Q_UNUSED(query); Q_UNUSED(type); return 0; }
virtual void CancelSearch() {}
virtual CollectionBackend *artists_collection_backend() { return nullptr; }
virtual CollectionBackend *albums_collection_backend() { return nullptr; }
virtual CollectionBackend *songs_collection_backend() { return nullptr; }
virtual SharedPtr<CollectionBackend> artists_collection_backend() { return nullptr; }
virtual SharedPtr<CollectionBackend> albums_collection_backend() { return nullptr; }
virtual SharedPtr<CollectionBackend> songs_collection_backend() { return nullptr; }
virtual CollectionModel *artists_collection_model() { return nullptr; }
virtual CollectionModel *albums_collection_model() { return nullptr; }
@@ -142,6 +143,10 @@ class InternetService : public QObject {
QString settings_group_;
SettingsDialog::Page settings_page_;
};
using InternetServicePtr = SharedPtr<InternetService>;
Q_DECLARE_METATYPE(InternetService*)
Q_DECLARE_METATYPE(InternetServicePtr)
#endif // INTERNETSERVICE_H

View File

@@ -34,12 +34,13 @@ InternetServices::InternetServices(QObject *parent) : QObject(parent) {}
InternetServices::~InternetServices() {
while (!services_.isEmpty()) {
delete services_.take(services_.firstKey());
InternetServicePtr service = services_.first();
RemoveService(service);
}
}
void InternetServices::AddService(InternetService *service) {
void InternetServices::AddService(InternetServicePtr service) {
services_.insert(service->source(), service);
if (service->has_initial_load_settings()) service->InitialLoadSettings();
@@ -49,17 +50,17 @@ void InternetServices::AddService(InternetService *service) {
}
void InternetServices::RemoveService(InternetService *service) {
void InternetServices::RemoveService(InternetServicePtr service) {
if (!services_.contains(service->source())) return;
services_.remove(service->source());
QObject::disconnect(service, nullptr, this, nullptr);
QObject::disconnect(&*service, nullptr, this, nullptr);
qLog(Debug) << "Removed internet service" << service->name();
}
InternetService *InternetServices::ServiceBySource(const Song::Source source) const {
InternetServicePtr InternetServices::ServiceBySource(const Song::Source source) const {
if (services_.contains(source)) return services_.value(source);
return nullptr;
@@ -68,8 +69,8 @@ InternetService *InternetServices::ServiceBySource(const Song::Source source) co
void InternetServices::ReloadSettings() {
QList<InternetService*> services = services_.values();
for (InternetService *service : services) {
QList<InternetServicePtr> services = services_.values();
for (InternetServicePtr service : services) {
service->ReloadSettings();
}
@@ -77,10 +78,10 @@ void InternetServices::ReloadSettings() {
void InternetServices::Exit() {
QList<InternetService*> services = services_.values();
for (InternetService *service : services) {
wait_for_exit_ << service;
QObject::connect(service, &InternetService::ExitFinished, this, &InternetServices::ExitReceived);
QList<InternetServicePtr> services = services_.values();
for (InternetServicePtr service : services) {
wait_for_exit_ << &*service;
QObject::connect(&*service, &InternetService::ExitFinished, this, &InternetServices::ExitReceived);
service->Exit();
}
if (wait_for_exit_.isEmpty()) emit ExitFinished();

View File

@@ -24,11 +24,14 @@
#include "config.h"
#include <memory>
#include <QObject>
#include <QList>
#include <QMap>
#include <QString>
#include <core/shared_ptr.h>
#include "core/song.h"
class InternetService;
@@ -40,14 +43,15 @@ class InternetServices : public QObject {
explicit InternetServices(QObject *parent = nullptr);
~InternetServices() override;
InternetService *ServiceBySource(const Song::Source source) const;
SharedPtr<InternetService> ServiceBySource(const Song::Source source) const;
template <typename T>
T *Service() {
return static_cast<T*>(ServiceBySource(T::kSource));
SharedPtr<T> Service() {
return std::static_pointer_cast<T>(ServiceBySource(T::kSource));
}
void AddService(InternetService *service);
void RemoveService(InternetService *service);
void AddService(SharedPtr<InternetService> service);
void RemoveService(SharedPtr<InternetService> service);
void ReloadSettings();
void Exit();
@@ -58,7 +62,7 @@ class InternetServices : public QObject {
void ExitReceived();
private:
QMap<Song::Source, InternetService*> services_;
QMap<Song::Source, SharedPtr<InternetService>> services_;
QList<InternetService*> wait_for_exit_;
};

View File

@@ -21,6 +21,7 @@
#ifndef INTERNETSONGMIMEDATA_H
#define INTERNETSONGMIMEDATA_H
#include "core/shared_ptr.h"
#include "core/mimedata.h"
#include "core/song.h"
@@ -30,9 +31,9 @@ class InternetSongMimeData : public MimeData {
Q_OBJECT
public:
explicit InternetSongMimeData(InternetService *_service, QObject* = nullptr) : service(_service) {}
explicit InternetSongMimeData(SharedPtr<InternetService> _service, QObject* = nullptr) : service(_service) {}
InternetService *service;
SharedPtr<InternetService> service;
SongList songs;
};

View File

@@ -39,7 +39,7 @@
#include "internetcollectionview.h"
#include "ui_internetcollectionviewcontainer.h"
InternetSongsView::InternetSongsView(Application *app, InternetService *service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent)
InternetSongsView::InternetSongsView(Application *app, InternetServicePtr service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent)
: QWidget(parent),
app_(app),
service_(service),
@@ -61,15 +61,15 @@ InternetSongsView::InternetSongsView(Application *app, InternetService *service,
ui_->filter_widget->AddMenuAction(action_configure);
QObject::connect(ui_->view, &InternetCollectionView::GetSongs, this, &InternetSongsView::GetSongs);
QObject::connect(ui_->view, &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveSongsByList);
QObject::connect(ui_->view, &InternetCollectionView::RemoveSongs, &*service_, &InternetService::RemoveSongsByList);
QObject::connect(ui_->refresh, &QPushButton::clicked, this, &InternetSongsView::GetSongs);
QObject::connect(ui_->close, &QPushButton::clicked, this, &InternetSongsView::AbortGetSongs);
QObject::connect(ui_->abort, &QPushButton::clicked, this, &InternetSongsView::AbortGetSongs);
QObject::connect(service_, &InternetService::SongsResults, this, &InternetSongsView::SongsFinished);
QObject::connect(service_, &InternetService::SongsUpdateStatus, ui_->status, &QLabel::setText);
QObject::connect(service_, &InternetService::SongsProgressSetMaximum, ui_->progressbar, &QProgressBar::setMaximum);
QObject::connect(service_, &InternetService::SongsUpdateProgress, ui_->progressbar, &QProgressBar::setValue);
QObject::connect(&*service_, &InternetService::SongsResults, this, &InternetSongsView::SongsFinished);
QObject::connect(&*service_, &InternetService::SongsUpdateStatus, ui_->status, &QLabel::setText);
QObject::connect(&*service_, &InternetService::SongsProgressSetMaximum, ui_->progressbar, &QProgressBar::setMaximum);
QObject::connect(&*service_, &InternetService::SongsUpdateProgress, ui_->progressbar, &QProgressBar::setValue);
QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->view, &InternetCollectionView::TotalArtistCountUpdated);
QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->view, &InternetCollectionView::TotalAlbumCountUpdated);

View File

@@ -27,6 +27,7 @@
#include <QMap>
#include <QString>
#include "core/shared_ptr.h"
#include "core/song.h"
#include "settings/settingsdialog.h"
#include "ui_internetcollectionviewcontainer.h"
@@ -41,7 +42,7 @@ class InternetSongsView : public QWidget {
Q_OBJECT
public:
explicit InternetSongsView(Application *app, InternetService *service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent = nullptr);
explicit InternetSongsView(Application *app, SharedPtr<InternetService> service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent = nullptr);
~InternetSongsView() override;
void ReloadSettings();
@@ -59,7 +60,7 @@ class InternetSongsView : public QWidget {
private:
Application *app_;
InternetService *service_;
SharedPtr<InternetService> service_;
QString settings_group_;
SettingsDialog::Page settings_page_;
Ui_InternetCollectionViewContainer *ui_;

View File

@@ -44,7 +44,7 @@
#include "internetcollectionviewcontainer.h"
#include "ui_internettabsview.h"
InternetTabsView::InternetTabsView(Application *app, InternetService *service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent)
InternetTabsView::InternetTabsView(Application *app, InternetServicePtr service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent)
: QWidget(parent),
app_(app),
service_(service),
@@ -55,9 +55,9 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c
ui_->setupUi(this);
ui_->search_view->Init(app, service);
QObject::connect(ui_->search_view, &InternetSearchView::AddArtistsSignal, service_, &InternetService::AddArtists);
QObject::connect(ui_->search_view, &InternetSearchView::AddAlbumsSignal, service_, &InternetService::AddAlbums);
QObject::connect(ui_->search_view, &InternetSearchView::AddSongsSignal, service_, &InternetService::AddSongs);
QObject::connect(ui_->search_view, &InternetSearchView::AddArtistsSignal, &*service_, &InternetService::AddArtists);
QObject::connect(ui_->search_view, &InternetSearchView::AddAlbumsSignal, &*service_, &InternetService::AddAlbums);
QObject::connect(ui_->search_view, &InternetSearchView::AddSongsSignal, &*service_, &InternetService::AddSongs);
QAction *action_configure = new QAction(IconLoader::Load("configure"), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this);
QObject::connect(action_configure, &QAction::triggered, this, &InternetTabsView::OpenSettingsDialog);
@@ -73,15 +73,15 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c
ui_->artists_collection->filter_widget()->AddMenuAction(action_configure);
QObject::connect(ui_->artists_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetArtists);
QObject::connect(ui_->artists_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveArtists);
QObject::connect(ui_->artists_collection->view(), &InternetCollectionView::RemoveSongs, &*service_, &InternetService::RemoveArtists);
QObject::connect(ui_->artists_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetArtists);
QObject::connect(ui_->artists_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetArtists);
QObject::connect(ui_->artists_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetArtists);
QObject::connect(service_, &InternetService::ArtistsResults, this, &InternetTabsView::ArtistsFinished);
QObject::connect(service_, &InternetService::ArtistsUpdateStatus, ui_->artists_collection->status(), &QLabel::setText);
QObject::connect(service_, &InternetService::ArtistsProgressSetMaximum, ui_->artists_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(service_, &InternetService::ArtistsUpdateProgress, ui_->artists_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(&*service_, &InternetService::ArtistsResults, this, &InternetTabsView::ArtistsFinished);
QObject::connect(&*service_, &InternetService::ArtistsUpdateStatus, ui_->artists_collection->status(), &QLabel::setText);
QObject::connect(&*service_, &InternetService::ArtistsProgressSetMaximum, ui_->artists_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(&*service_, &InternetService::ArtistsUpdateProgress, ui_->artists_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(service_->artists_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->artists_collection->view(), &InternetCollectionView::TotalArtistCountUpdated);
QObject::connect(service_->artists_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->artists_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated);
@@ -105,15 +105,15 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c
ui_->albums_collection->filter_widget()->AddMenuAction(action_configure);
QObject::connect(ui_->albums_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetAlbums);
QObject::connect(ui_->albums_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveAlbums);
QObject::connect(ui_->albums_collection->view(), &InternetCollectionView::RemoveSongs, &*service_, &InternetService::RemoveAlbums);
QObject::connect(ui_->albums_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetAlbums);
QObject::connect(ui_->albums_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetAlbums);
QObject::connect(ui_->albums_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetAlbums);
QObject::connect(service_, &InternetService::AlbumsResults, this, &InternetTabsView::AlbumsFinished);
QObject::connect(service_, &InternetService::AlbumsUpdateStatus, ui_->albums_collection->status(), &QLabel::setText);
QObject::connect(service_, &InternetService::AlbumsProgressSetMaximum, ui_->albums_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(service_, &InternetService::AlbumsUpdateProgress, ui_->albums_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(&*service_, &InternetService::AlbumsResults, this, &InternetTabsView::AlbumsFinished);
QObject::connect(&*service_, &InternetService::AlbumsUpdateStatus, ui_->albums_collection->status(), &QLabel::setText);
QObject::connect(&*service_, &InternetService::AlbumsProgressSetMaximum, ui_->albums_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(&*service_, &InternetService::AlbumsUpdateProgress, ui_->albums_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(service_->albums_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->albums_collection->view(), &InternetCollectionView::TotalArtistCountUpdated);
QObject::connect(service_->albums_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->albums_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated);
@@ -137,15 +137,15 @@ InternetTabsView::InternetTabsView(Application *app, InternetService *service, c
ui_->songs_collection->filter_widget()->AddMenuAction(action_configure);
QObject::connect(ui_->songs_collection->view(), &InternetCollectionView::GetSongs, this, &InternetTabsView::GetSongs);
QObject::connect(ui_->songs_collection->view(), &InternetCollectionView::RemoveSongs, service_, &InternetService::RemoveSongsByList);
QObject::connect(ui_->songs_collection->view(), &InternetCollectionView::RemoveSongs, &*service_, &InternetService::RemoveSongsByList);
QObject::connect(ui_->songs_collection->button_refresh(), &QPushButton::clicked, this, &InternetTabsView::GetSongs);
QObject::connect(ui_->songs_collection->button_close(), &QPushButton::clicked, this, &InternetTabsView::AbortGetSongs);
QObject::connect(ui_->songs_collection->button_abort(), &QPushButton::clicked, this, &InternetTabsView::AbortGetSongs);
QObject::connect(service_, &InternetService::SongsResults, this, &InternetTabsView::SongsFinished);
QObject::connect(service_, &InternetService::SongsUpdateStatus, ui_->songs_collection->status(), &QLabel::setText);
QObject::connect(service_, &InternetService::SongsProgressSetMaximum, ui_->songs_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(service_, &InternetService::SongsUpdateProgress, ui_->songs_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(&*service_, &InternetService::SongsResults, this, &InternetTabsView::SongsFinished);
QObject::connect(&*service_, &InternetService::SongsUpdateStatus, ui_->songs_collection->status(), &QLabel::setText);
QObject::connect(&*service_, &InternetService::SongsProgressSetMaximum, ui_->songs_collection->progressbar(), &QProgressBar::setMaximum);
QObject::connect(&*service_, &InternetService::SongsUpdateProgress, ui_->songs_collection->progressbar(), &QProgressBar::setValue);
QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalArtistCountUpdated, ui_->songs_collection->view(), &InternetCollectionView::TotalArtistCountUpdated);
QObject::connect(service_->songs_collection_model(), &CollectionModel::TotalAlbumCountUpdated, ui_->songs_collection->view(), &InternetCollectionView::TotalAlbumCountUpdated);

View File

@@ -27,6 +27,7 @@
#include <QMap>
#include <QString>
#include "core/shared_ptr.h"
#include "settings/settingsdialog.h"
#include "internetcollectionviewcontainer.h"
#include "ui_internettabsview.h"
@@ -43,7 +44,7 @@ class InternetTabsView : public QWidget {
Q_OBJECT
public:
explicit InternetTabsView(Application *app, InternetService *service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent = nullptr);
explicit InternetTabsView(Application *app, SharedPtr<InternetService> service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent = nullptr);
~InternetTabsView() override;
void ReloadSettings();
@@ -70,7 +71,7 @@ class InternetTabsView : public QWidget {
private:
Application *app_;
InternetService *service_;
SharedPtr <InternetService> service_;
QString settings_group_;
SettingsDialog::Page settings_page_;
Ui_InternetTabsView *ui_;