@@ -58,6 +58,7 @@
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/mimedata.h"
|
||||
@@ -92,6 +93,7 @@
|
||||
#include "radios/radiomimedata.h"
|
||||
#include "radios/radioplaylistitem.h"
|
||||
|
||||
using std::make_shared;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
const char *Playlist::kCddaMimeType = "x-content/audio-cdda";
|
||||
@@ -112,7 +114,7 @@ const int Playlist::kUndoItemLimit = 500;
|
||||
const qint64 Playlist::kMinScrobblePointNsecs = 31LL * kNsecPerSec;
|
||||
const qint64 Playlist::kMaxScrobblePointNsecs = 240LL * kNsecPerSec;
|
||||
|
||||
Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type, const bool favorite, QObject *parent)
|
||||
Playlist::Playlist(SharedPtr<PlaylistBackend> backend, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> collection_backend, const int id, const QString &special_type, const bool favorite, QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
is_loading_(false),
|
||||
filter_(new PlaylistFilter(this)),
|
||||
@@ -120,7 +122,7 @@ Playlist::Playlist(PlaylistBackend *backend, TaskManager *task_manager, Collecti
|
||||
timer_save_(new QTimer(this)),
|
||||
backend_(backend),
|
||||
task_manager_(task_manager),
|
||||
collection_(collection),
|
||||
collection_backend_(collection_backend),
|
||||
id_(id),
|
||||
favorite_(favorite),
|
||||
current_is_paused_(false),
|
||||
@@ -175,7 +177,7 @@ void Playlist::InsertSongItems(const SongList &songs, const int pos, const bool
|
||||
PlaylistItemPtrList items;
|
||||
items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
items << std::make_shared<T>(song);
|
||||
items << make_shared<T>(song);
|
||||
}
|
||||
|
||||
InsertItems(items, pos, play_now, enqueue, enqueue_next);
|
||||
@@ -730,7 +732,7 @@ void Playlist::set_current_row(const int i, const AutoScroll autoscroll, const b
|
||||
|
||||
void Playlist::InsertDynamicItems(const int count) {
|
||||
|
||||
PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this);
|
||||
PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_backend_, this);
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error);
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::PlayRequested, this, &Playlist::PlayRequested);
|
||||
|
||||
@@ -850,7 +852,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
}
|
||||
}
|
||||
else if (data->hasFormat(kCddaMimeType)) {
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player());
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_backend_, backend_->app()->player());
|
||||
QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error);
|
||||
inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now);
|
||||
}
|
||||
@@ -865,7 +867,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
|
||||
|
||||
void Playlist::InsertUrls(const QList<QUrl> &urls, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_, backend_->app()->player());
|
||||
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_backend_, backend_->app()->player());
|
||||
QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error);
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, urls);
|
||||
@@ -876,10 +878,10 @@ void Playlist::InsertSmartPlaylist(PlaylistGeneratorPtr generator, const int pos
|
||||
|
||||
// Hack: If the generator hasn't got a collection set then use the main one
|
||||
if (!generator->collection()) {
|
||||
generator->set_collection(collection_);
|
||||
generator->set_collection_backend(collection_backend_);
|
||||
}
|
||||
|
||||
PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_, this);
|
||||
PlaylistGeneratorInserter *inserter = new PlaylistGeneratorInserter(task_manager_, collection_backend_, this);
|
||||
QObject::connect(inserter, &PlaylistGeneratorInserter::Error, this, &Playlist::Error);
|
||||
|
||||
inserter->Load(this, pos, play_now, enqueue, enqueue_next, generator);
|
||||
@@ -1142,18 +1144,18 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, const int pos
|
||||
for (const Song &song : songs) {
|
||||
if (song.url().isLocalFile()) {
|
||||
if (song.is_collection_song()) {
|
||||
items << std::make_shared<CollectionPlaylistItem>(song);
|
||||
items << make_shared<CollectionPlaylistItem>(song);
|
||||
}
|
||||
else {
|
||||
items << std::make_shared<SongPlaylistItem>(song);
|
||||
items << make_shared<SongPlaylistItem>(song);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (song.is_radio()) {
|
||||
items << std::make_shared<RadioPlaylistItem>(song);
|
||||
items << make_shared<RadioPlaylistItem>(song);
|
||||
}
|
||||
else {
|
||||
items << std::make_shared<InternetPlaylistItem>(song);
|
||||
items << make_shared<InternetPlaylistItem>(song);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1161,12 +1163,12 @@ void Playlist::InsertSongsOrCollectionItems(const SongList &songs, const int pos
|
||||
|
||||
}
|
||||
|
||||
void Playlist::InsertInternetItems(InternetService *service, const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
void Playlist::InsertInternetItems(InternetServicePtr service, const SongList &songs, const int pos, const bool play_now, const bool enqueue, const bool enqueue_next) {
|
||||
|
||||
PlaylistItemPtrList playlist_items;
|
||||
playlist_items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
playlist_items << std::make_shared<InternetPlaylistItem>(service, song);
|
||||
playlist_items << make_shared<InternetPlaylistItem>(service, song);
|
||||
}
|
||||
|
||||
InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
|
||||
@@ -1178,7 +1180,7 @@ void Playlist::InsertRadioItems(const SongList &songs, const int pos, const bool
|
||||
PlaylistItemPtrList playlist_items;
|
||||
playlist_items.reserve(songs.count());
|
||||
for (const Song &song : songs) {
|
||||
playlist_items << std::make_shared<RadioPlaylistItem>(song);
|
||||
playlist_items << make_shared<RadioPlaylistItem>(song);
|
||||
}
|
||||
|
||||
InsertItems(playlist_items, pos, play_now, enqueue, enqueue_next);
|
||||
@@ -1205,20 +1207,20 @@ void Playlist::UpdateItems(SongList songs) {
|
||||
PlaylistItemPtr new_item;
|
||||
if (song.url().isLocalFile()) {
|
||||
if (song.is_collection_song()) {
|
||||
new_item = std::make_shared<CollectionPlaylistItem>(song);
|
||||
new_item = make_shared<CollectionPlaylistItem>(song);
|
||||
if (collection_items_by_id_.contains(song.id(), item)) collection_items_by_id_.remove(song.id(), item);
|
||||
collection_items_by_id_.insert(song.id(), new_item);
|
||||
}
|
||||
else {
|
||||
new_item = std::make_shared<SongPlaylistItem>(song);
|
||||
new_item = make_shared<SongPlaylistItem>(song);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (song.is_radio()) {
|
||||
new_item = std::make_shared<RadioPlaylistItem>(song);
|
||||
new_item = make_shared<RadioPlaylistItem>(song);
|
||||
}
|
||||
else {
|
||||
new_item = std::make_shared<InternetPlaylistItem>(song);
|
||||
new_item = make_shared<InternetPlaylistItem>(song);
|
||||
}
|
||||
}
|
||||
items_[i] = new_item;
|
||||
@@ -1284,10 +1286,10 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
|
||||
|
||||
}
|
||||
|
||||
bool Playlist::CompareItems(const int column, const Qt::SortOrder order, std::shared_ptr<PlaylistItem> _a, std::shared_ptr<PlaylistItem> _b) {
|
||||
bool Playlist::CompareItems(const int column, const Qt::SortOrder order, SharedPtr<PlaylistItem> _a, SharedPtr<PlaylistItem> _b) {
|
||||
|
||||
std::shared_ptr<PlaylistItem> a = order == Qt::AscendingOrder ? _a : _b;
|
||||
std::shared_ptr<PlaylistItem> b = order == Qt::AscendingOrder ? _b : _a;
|
||||
SharedPtr<PlaylistItem> a = order == Qt::AscendingOrder ? _a : _b;
|
||||
SharedPtr<PlaylistItem> b = order == Qt::AscendingOrder ? _b : _a;
|
||||
|
||||
#define cmp(field) return a->Metadata().field() < b->Metadata().field()
|
||||
#define strcmp(field) return QString::localeAwareCompare(a->Metadata().field().toLower(), b->Metadata().field().toLower()) < 0;
|
||||
@@ -1343,10 +1345,10 @@ bool Playlist::CompareItems(const int column, const Qt::SortOrder order, std::sh
|
||||
|
||||
}
|
||||
|
||||
bool Playlist::ComparePathDepths(const Qt::SortOrder order, std::shared_ptr<PlaylistItem> _a, std::shared_ptr<PlaylistItem> _b) {
|
||||
bool Playlist::ComparePathDepths(const Qt::SortOrder order, SharedPtr<PlaylistItem> _a, SharedPtr<PlaylistItem> _b) {
|
||||
|
||||
std::shared_ptr<PlaylistItem> a = order == Qt::AscendingOrder ? _a : _b;
|
||||
std::shared_ptr<PlaylistItem> b = order == Qt::AscendingOrder ? _b : _a;
|
||||
SharedPtr<PlaylistItem> a = order == Qt::AscendingOrder ? _a : _b;
|
||||
SharedPtr<PlaylistItem> b = order == Qt::AscendingOrder ? _b : _a;
|
||||
|
||||
qint64 a_dir_level = a->Url().path().count('/');
|
||||
qint64 b_dir_level = b->Url().path().count('/');
|
||||
@@ -1462,11 +1464,11 @@ void Playlist::ReOrderWithoutUndo(const PlaylistItemPtrList &new_items) {
|
||||
|
||||
QHash<const PlaylistItem*, int> new_rows;
|
||||
for (int i = 0; i < new_items.length(); ++i) {
|
||||
new_rows[new_items[i].get()] = i;
|
||||
new_rows[&*new_items[i]] = i;
|
||||
}
|
||||
|
||||
for (const QModelIndex &idx : persistentIndexList()) {
|
||||
const PlaylistItem *item = old_items[idx.row()].get();
|
||||
const PlaylistItem *item = &*old_items[idx.row()];
|
||||
changePersistentIndex(idx, index(new_rows[item], idx.column(), idx.parent()));
|
||||
}
|
||||
|
||||
@@ -1574,11 +1576,11 @@ void Playlist::ItemsLoaded() {
|
||||
PlaylistGeneratorPtr gen = PlaylistGenerator::Create(p.dynamic_type);
|
||||
if (gen) {
|
||||
|
||||
CollectionBackend *backend = nullptr;
|
||||
if (p.dynamic_backend == collection_->songs_table()) backend = collection_;
|
||||
SharedPtr<CollectionBackend> backend = nullptr;
|
||||
if (p.dynamic_backend == collection_backend_->songs_table()) backend = collection_backend_;
|
||||
|
||||
if (backend) {
|
||||
gen->set_collection(backend);
|
||||
gen->set_collection_backend(collection_backend_);
|
||||
gen->Load(p.dynamic_data);
|
||||
TurnOnDynamicPlaylist(gen);
|
||||
}
|
||||
@@ -2365,7 +2367,7 @@ void Playlist::RateSong(const QModelIndex &idx, const float rating) {
|
||||
if (has_item_at(idx.row())) {
|
||||
PlaylistItemPtr item = item_at(idx.row());
|
||||
if (item && item->IsLocalCollectionItem() && item->Metadata().id() != -1) {
|
||||
collection_->UpdateSongRatingAsync(item->Metadata().id(), rating);
|
||||
collection_backend_->UpdateSongRatingAsync(item->Metadata().id(), rating);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2383,6 +2385,6 @@ void Playlist::RateSongs(const QModelIndexList &index_list, const float rating)
|
||||
}
|
||||
}
|
||||
}
|
||||
collection_->UpdateSongsRatingAsync(id_list, rating);
|
||||
collection_backend_->UpdateSongsRatingAsync(id_list, rating);
|
||||
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <QColor>
|
||||
#include <QRgb>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
#include "covermanager/albumcoverloaderresult.h"
|
||||
@@ -94,7 +95,7 @@ class Playlist : public QAbstractListModel {
|
||||
friend class PlaylistUndoCommands::ReOrderItems;
|
||||
|
||||
public:
|
||||
explicit Playlist(PlaylistBackend *backend, TaskManager *task_manager, CollectionBackend *collection, const int id, const QString &special_type = QString(), const bool favorite = false, QObject *parent = nullptr);
|
||||
explicit Playlist(SharedPtr<PlaylistBackend> playlist_backend, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> collection_backend, const int id, const QString &special_type = QString(), const bool favorite = false, QObject *parent = nullptr);
|
||||
~Playlist() override;
|
||||
|
||||
void SkipTracks(const QModelIndexList &source_indexes);
|
||||
@@ -236,7 +237,7 @@ class Playlist : public QAbstractListModel {
|
||||
void InsertSongs(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertSongsOrCollectionItems(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertSmartPlaylist(PlaylistGeneratorPtr gen, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertInternetItems(InternetService *service, const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertInternetItems(SharedPtr<InternetService> service, const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
void InsertRadioItems(const SongList &songs, const int pos = -1, const bool play_now = false, const bool enqueue = false, const bool enqueue_next = false);
|
||||
|
||||
void ReshuffleIndices();
|
||||
@@ -387,9 +388,9 @@ class Playlist : public QAbstractListModel {
|
||||
|
||||
QList<QModelIndex> temp_dequeue_change_indexes_;
|
||||
|
||||
PlaylistBackend *backend_;
|
||||
TaskManager *task_manager_;
|
||||
CollectionBackend *collection_;
|
||||
SharedPtr<PlaylistBackend> backend_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
int id_;
|
||||
QString ui_path_;
|
||||
bool favorite_;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QUrl>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "core/logging.h"
|
||||
@@ -51,6 +52,8 @@
|
||||
#include "playlistparsers/cueparser.h"
|
||||
#include "smartplaylists/playlistgenerator.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
const int PlaylistBackend::kSongTableJoins = 2;
|
||||
|
||||
PlaylistBackend::PlaylistBackend(Application *app, QObject *parent)
|
||||
@@ -193,7 +196,7 @@ PlaylistItemPtrList PlaylistBackend::GetPlaylistItems(const int playlist) {
|
||||
}
|
||||
|
||||
// it's probable that we'll have a few songs associated with the same CUE, so we're caching results of parsing CUEs
|
||||
std::shared_ptr<NewSongFromQueryState> state_ptr = std::make_shared<NewSongFromQueryState>();
|
||||
SharedPtr<NewSongFromQueryState> state_ptr = make_shared<NewSongFromQueryState>();
|
||||
while (q.next()) {
|
||||
playlistitems << NewPlaylistItemFromQuery(SqlRow(q), state_ptr);
|
||||
}
|
||||
@@ -228,7 +231,7 @@ SongList PlaylistBackend::GetPlaylistSongs(const int playlist) {
|
||||
}
|
||||
|
||||
// it's probable that we'll have a few songs associated with the same CUE, so we're caching results of parsing CUEs
|
||||
std::shared_ptr<NewSongFromQueryState> state_ptr = std::make_shared<NewSongFromQueryState>();
|
||||
SharedPtr<NewSongFromQueryState> state_ptr = make_shared<NewSongFromQueryState>();
|
||||
while (q.next()) {
|
||||
songs << NewSongFromQuery(SqlRow(q), state_ptr);
|
||||
}
|
||||
@@ -243,7 +246,7 @@ SongList PlaylistBackend::GetPlaylistSongs(const int playlist) {
|
||||
|
||||
}
|
||||
|
||||
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
||||
PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, SharedPtr<NewSongFromQueryState> state) {
|
||||
|
||||
// The song tables get joined first, plus one each for the song ROWIDs
|
||||
const int playlist_row = static_cast<int>(Song::kColumns.count() + 1) * kSongTableJoins;
|
||||
@@ -259,7 +262,7 @@ PlaylistItemPtr PlaylistBackend::NewPlaylistItemFromQuery(const SqlRow &row, std
|
||||
|
||||
}
|
||||
|
||||
Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state) {
|
||||
Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, SharedPtr<NewSongFromQueryState> state) {
|
||||
|
||||
return NewPlaylistItemFromQuery(row, state)->Metadata();
|
||||
|
||||
@@ -267,7 +270,7 @@ Song PlaylistBackend::NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSon
|
||||
|
||||
// If song had a CUE and the CUE still exists, the metadata from it will be applied here.
|
||||
|
||||
PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::shared_ptr<NewSongFromQueryState> state) {
|
||||
PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, SharedPtr<NewSongFromQueryState> state) {
|
||||
|
||||
// We need collection to run a CueParser; also, this method applies only to file-type PlaylistItems
|
||||
if (item->source() != Song::Source::LocalFile) return item;
|
||||
@@ -305,7 +308,7 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, std::share
|
||||
for (const Song &from_list : song_list) {
|
||||
if (from_list.url().toEncoded() == song.url().toEncoded() && from_list.beginning_nanosec() == song.beginning_nanosec()) {
|
||||
// We found a matching section; replace the input item with a new one containing CUE metadata
|
||||
return std::make_shared<SongPlaylistItem>(from_list);
|
||||
return make_shared<SongPlaylistItem>(from_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QMutex>
|
||||
#include <QHash>
|
||||
@@ -34,6 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QSqlQuery>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/sqlquery.h"
|
||||
#include "core/sqlrow.h"
|
||||
@@ -102,9 +101,9 @@ class PlaylistBackend : public QObject {
|
||||
QMutex mutex_;
|
||||
};
|
||||
|
||||
Song NewSongFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state);
|
||||
PlaylistItemPtr NewPlaylistItemFromQuery(const SqlRow &row, std::shared_ptr<NewSongFromQueryState> state);
|
||||
PlaylistItemPtr RestoreCueData(PlaylistItemPtr item, std::shared_ptr<NewSongFromQueryState> state);
|
||||
Song NewSongFromQuery(const SqlRow &row, SharedPtr<NewSongFromQueryState> state);
|
||||
PlaylistItemPtr NewPlaylistItemFromQuery(const SqlRow &row, SharedPtr<NewSongFromQueryState> state);
|
||||
PlaylistItemPtr RestoreCueData(PlaylistItemPtr item, SharedPtr<NewSongFromQueryState> state);
|
||||
|
||||
enum GetPlaylistsFlags {
|
||||
GetPlaylists_OpenInUi = 1,
|
||||
@@ -114,7 +113,7 @@ class PlaylistBackend : public QObject {
|
||||
PlaylistList GetPlaylists(const GetPlaylistsFlags flags);
|
||||
|
||||
Application *app_;
|
||||
Database *db_;
|
||||
SharedPtr<Database> db_;
|
||||
QThread *original_thread_;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <QtEvents>
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "playlist.h"
|
||||
#include "playlisttabbar.h"
|
||||
@@ -146,27 +147,27 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist
|
||||
QObject::connect(next_playlist, &QAction::triggered, this, &PlaylistContainer::GoToNextPlaylistTab);
|
||||
QObject::connect(previous_playlist, &QAction::triggered, this, &PlaylistContainer::GoToPreviousPlaylistTab);
|
||||
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
|
||||
QObject::connect(save_all_playlists, &QAction::triggered, manager_, &PlaylistManager::SaveAllPlaylists);
|
||||
QObject::connect(save_all_playlists, &QAction::triggered, &*manager_, &PlaylistManager::SaveAllPlaylists);
|
||||
|
||||
}
|
||||
|
||||
void PlaylistContainer::SetManager(PlaylistManager *manager) {
|
||||
void PlaylistContainer::SetManager(SharedPtr<PlaylistManager> manager) {
|
||||
|
||||
manager_ = manager;
|
||||
ui_->tab_bar->SetManager(manager);
|
||||
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::CurrentIdChanged, manager, &PlaylistManager::SetCurrentPlaylist);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Rename, manager, &PlaylistManager::Rename);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Close, manager, &PlaylistManager::Close);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistFavorited, manager, &PlaylistManager::Favorite);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::CurrentIdChanged, &*manager, &PlaylistManager::SetCurrentPlaylist);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Rename, &*manager, &PlaylistManager::Rename);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::Close, &*manager, &PlaylistManager::Close);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistFavorited, &*manager, &PlaylistManager::Favorite);
|
||||
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistOrderChanged, manager, &PlaylistManager::ChangePlaylistOrder);
|
||||
QObject::connect(ui_->tab_bar, &PlaylistTabBar::PlaylistOrderChanged, &*manager, &PlaylistManager::ChangePlaylistOrder);
|
||||
|
||||
QObject::connect(manager, &PlaylistManager::CurrentChanged, this, &PlaylistContainer::SetViewModel);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistContainer::PlaylistAdded);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistContainer::Started);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistClosed, this, &PlaylistContainer::PlaylistClosed);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistContainer::PlaylistRenamed);
|
||||
QObject::connect(&*manager, &PlaylistManager::CurrentChanged, this, &PlaylistContainer::SetViewModel);
|
||||
QObject::connect(&*manager, &PlaylistManager::PlaylistAdded, this, &PlaylistContainer::PlaylistAdded);
|
||||
QObject::connect(&*manager, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistContainer::Started);
|
||||
QObject::connect(&*manager, &PlaylistManager::PlaylistClosed, this, &PlaylistContainer::PlaylistClosed);
|
||||
QObject::connect(&*manager, &PlaylistManager::PlaylistRenamed, this, &PlaylistContainer::PlaylistRenamed);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ class PlaylistView;
|
||||
|
||||
class Ui_PlaylistContainer;
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class PlaylistContainer : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -54,7 +56,7 @@ class PlaylistContainer : public QWidget {
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists);
|
||||
void SetManager(PlaylistManager *manager);
|
||||
void SetManager(SharedPtr<PlaylistManager> manager);
|
||||
void ReloadSettings();
|
||||
|
||||
bool SearchFieldHasFocus() const;
|
||||
@@ -118,7 +120,7 @@ class PlaylistContainer : public QWidget {
|
||||
|
||||
Ui_PlaylistContainer *ui_;
|
||||
|
||||
PlaylistManager *manager_;
|
||||
SharedPtr<PlaylistManager> manager_;
|
||||
QAction *undo_;
|
||||
QAction *redo_;
|
||||
Playlist *playlist_;
|
||||
|
||||
@@ -365,7 +365,7 @@ QWidget *TextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
|
||||
return new QLineEdit(parent);
|
||||
}
|
||||
|
||||
TagCompletionModel::TagCompletionModel(CollectionBackend *backend, const Playlist::Column column, QObject *parent) : QStringListModel(parent) {
|
||||
TagCompletionModel::TagCompletionModel(SharedPtr<CollectionBackend> backend, const Playlist::Column column, QObject *parent) : QStringListModel(parent) {
|
||||
|
||||
QString col = database_column(column);
|
||||
if (!col.isEmpty()) {
|
||||
@@ -395,13 +395,13 @@ QString TagCompletionModel::database_column(Playlist::Column column) {
|
||||
|
||||
}
|
||||
|
||||
static TagCompletionModel *InitCompletionModel(CollectionBackend *backend, Playlist::Column column) {
|
||||
static TagCompletionModel *InitCompletionModel(SharedPtr<CollectionBackend> backend, Playlist::Column column) {
|
||||
|
||||
return new TagCompletionModel(backend, column);
|
||||
|
||||
}
|
||||
|
||||
TagCompleter::TagCompleter(CollectionBackend *backend, Playlist::Column column, QLineEdit *editor) : QCompleter(editor), editor_(editor) {
|
||||
TagCompleter::TagCompleter(SharedPtr<CollectionBackend> backend, Playlist::Column column, QLineEdit *editor) : QCompleter(editor), editor_(editor) {
|
||||
|
||||
QFuture<TagCompletionModel*> future = QtConcurrent::run(&InitCompletionModel, backend, column);
|
||||
QFutureWatcher<TagCompletionModel*> *watcher = new QFutureWatcher<TagCompletionModel*>();
|
||||
|
||||
@@ -151,7 +151,7 @@ class TagCompletionModel : public QStringListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagCompletionModel(CollectionBackend *backend, const Playlist::Column column, QObject *parent = nullptr);
|
||||
explicit TagCompletionModel(SharedPtr<CollectionBackend> backend, const Playlist::Column column, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
static QString database_column(Playlist::Column column);
|
||||
@@ -161,7 +161,7 @@ class TagCompleter : public QCompleter {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagCompleter(CollectionBackend *backend, Playlist::Column column, QLineEdit *editor);
|
||||
explicit TagCompleter(SharedPtr<CollectionBackend> backend, Playlist::Column column, QLineEdit *editor);
|
||||
~TagCompleter() override;
|
||||
|
||||
private slots:
|
||||
@@ -175,12 +175,12 @@ class TagCompletionItemDelegate : public PlaylistDelegateBase {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TagCompletionItemDelegate(QObject *parent, CollectionBackend *backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {};
|
||||
explicit TagCompletionItemDelegate(QObject *parent, SharedPtr<CollectionBackend> backend, Playlist::Column column) : PlaylistDelegateBase(parent), backend_(backend), column_(column) {};
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &idx) const override;
|
||||
|
||||
private:
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
Playlist::Column column_;
|
||||
};
|
||||
|
||||
|
||||
@@ -37,19 +37,21 @@
|
||||
#include "internet/internetplaylistitem.h"
|
||||
#include "radios/radioplaylistitem.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
PlaylistItemPtr PlaylistItem::NewFromSource(const Song::Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Song::Source::Collection:
|
||||
return std::make_shared<CollectionPlaylistItem>();
|
||||
return make_shared<CollectionPlaylistItem>();
|
||||
case Song::Source::Subsonic:
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
return std::make_shared<InternetPlaylistItem>(source);
|
||||
return make_shared<InternetPlaylistItem>(source);
|
||||
case Song::Source::Stream:
|
||||
case Song::Source::RadioParadise:
|
||||
case Song::Source::SomaFM:
|
||||
return std::make_shared<RadioPlaylistItem>(source);
|
||||
return make_shared<RadioPlaylistItem>(source);
|
||||
case Song::Source::LocalFile:
|
||||
case Song::Source::CDDA:
|
||||
case Song::Source::Device:
|
||||
@@ -57,7 +59,7 @@ PlaylistItemPtr PlaylistItem::NewFromSource(const Song::Source source) {
|
||||
break;
|
||||
}
|
||||
|
||||
return std::make_shared<SongPlaylistItem>(source);
|
||||
return make_shared<SongPlaylistItem>(source);
|
||||
|
||||
}
|
||||
|
||||
@@ -65,15 +67,15 @@ PlaylistItemPtr PlaylistItem::NewFromSong(const Song &song) {
|
||||
|
||||
switch (song.source()) {
|
||||
case Song::Source::Collection:
|
||||
return std::make_shared<CollectionPlaylistItem>(song);
|
||||
return make_shared<CollectionPlaylistItem>(song);
|
||||
case Song::Source::Subsonic:
|
||||
case Song::Source::Tidal:
|
||||
case Song::Source::Qobuz:
|
||||
return std::make_shared<InternetPlaylistItem>(song);
|
||||
return make_shared<InternetPlaylistItem>(song);
|
||||
case Song::Source::Stream:
|
||||
case Song::Source::RadioParadise:
|
||||
case Song::Source::SomaFM:
|
||||
return std::make_shared<RadioPlaylistItem>(song);
|
||||
return make_shared<RadioPlaylistItem>(song);
|
||||
case Song::Source::LocalFile:
|
||||
case Song::Source::CDDA:
|
||||
case Song::Source::Device:
|
||||
@@ -81,7 +83,7 @@ PlaylistItemPtr PlaylistItem::NewFromSong(const Song &song) {
|
||||
break;
|
||||
}
|
||||
|
||||
return std::make_shared<SongPlaylistItem>(song);
|
||||
return make_shared<SongPlaylistItem>(song);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QUrl>
|
||||
#include <QColor>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QAction;
|
||||
@@ -43,13 +44,15 @@ class QAction;
|
||||
class SqlQuery;
|
||||
class SqlRow;
|
||||
|
||||
class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
using std::enable_shared_from_this;
|
||||
|
||||
class PlaylistItem : public enable_shared_from_this<PlaylistItem> {
|
||||
public:
|
||||
explicit PlaylistItem(const Song::Source source) : should_skip_(false), source_(source) {}
|
||||
virtual ~PlaylistItem();
|
||||
|
||||
static std::shared_ptr<PlaylistItem> NewFromSource(const Song::Source source);
|
||||
static std::shared_ptr<PlaylistItem> NewFromSong(const Song &song);
|
||||
static SharedPtr<PlaylistItem> NewFromSource(const Song::Source source);
|
||||
static SharedPtr<PlaylistItem> NewFromSong(const Song &song);
|
||||
|
||||
enum class Option {
|
||||
Default = 0x00,
|
||||
@@ -133,7 +136,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
|
||||
Q_DISABLE_COPY(PlaylistItem)
|
||||
};
|
||||
using PlaylistItemPtr = std::shared_ptr<PlaylistItem>;
|
||||
using PlaylistItemPtr = SharedPtr<PlaylistItem>;
|
||||
using PlaylistItemPtrList = QList<PlaylistItemPtr>;
|
||||
|
||||
Q_DECLARE_METATYPE(PlaylistItemPtr)
|
||||
|
||||
@@ -63,6 +63,8 @@
|
||||
# include "device/devicestatefiltermodel.h"
|
||||
#endif
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
PlaylistListContainer::PlaylistListContainer(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
app_(nullptr),
|
||||
@@ -120,8 +122,8 @@ PlaylistListContainer::~PlaylistListContainer() { delete ui_; }
|
||||
void PlaylistListContainer::SetApplication(Application *app) {
|
||||
|
||||
app_ = app;
|
||||
PlaylistManager *manager = app_->playlist_manager();
|
||||
Player *player = app_->player();
|
||||
PlaylistManager *manager = &*app_->playlist_manager();
|
||||
Player *player = &*app_->player();
|
||||
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistAdded, this, &PlaylistListContainer::AddPlaylist);
|
||||
QObject::connect(manager, &PlaylistManager::PlaylistFavorited, this, &PlaylistListContainer::PlaylistFavoriteStateChanged);
|
||||
@@ -370,7 +372,7 @@ void PlaylistListContainer::CopyToDevice() {
|
||||
|
||||
// Reuse the organize dialog, but set the detail about the playlist name
|
||||
if (!organize_dialog_) {
|
||||
organize_dialog_ = std::make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
}
|
||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||
organize_dialog_->SetCopy(true);
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QModelIndex>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
|
||||
class QStandardItem;
|
||||
class QSortFilterProxyModel;
|
||||
class QMenu;
|
||||
@@ -115,7 +115,7 @@ class PlaylistListContainer : public QWidget {
|
||||
|
||||
int active_playlist_id_;
|
||||
|
||||
std::unique_ptr<OrganizeDialog> organize_dialog_;
|
||||
ScopedPtr<OrganizeDialog> organize_dialog_;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTLISTCONTAINER_H
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <QSettings>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/player.h"
|
||||
#include "utilities/filenameconstants.h"
|
||||
@@ -73,9 +74,9 @@ PlaylistManager::PlaylistManager(Application *app, QObject *parent)
|
||||
active_(-1),
|
||||
playlists_loading_(0) {
|
||||
|
||||
QObject::connect(app_->player(), &Player::Paused, this, &PlaylistManager::SetActivePaused);
|
||||
QObject::connect(app_->player(), &Player::Playing, this, &PlaylistManager::SetActivePlaying);
|
||||
QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistManager::SetActiveStopped);
|
||||
QObject::connect(&*app_->player(), &Player::Paused, this, &PlaylistManager::SetActivePaused);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, this, &PlaylistManager::SetActivePlaying);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, this, &PlaylistManager::SetActiveStopped);
|
||||
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ PlaylistManager::~PlaylistManager() {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBackend *playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container) {
|
||||
void PlaylistManager::Init(SharedPtr<CollectionBackend> collection_backend, SharedPtr<PlaylistBackend> playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container) {
|
||||
|
||||
collection_backend_ = collection_backend;
|
||||
playlist_backend_ = playlist_backend;
|
||||
@@ -94,9 +95,9 @@ void PlaylistManager::Init(CollectionBackend *collection_backend, PlaylistBacken
|
||||
parser_ = new PlaylistParser(collection_backend, this);
|
||||
playlist_container_ = playlist_container;
|
||||
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsDiscovered, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsStatisticsChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(collection_backend_, &CollectionBackend::SongsRatingChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::SongsDiscovered, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::SongsStatisticsChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::SongsRatingChanged, this, &PlaylistManager::SongsDiscovered);
|
||||
|
||||
for (const PlaylistBackend::Playlist &p : playlist_backend->GetAllOpenPlaylists()) {
|
||||
++playlists_loading_;
|
||||
@@ -156,7 +157,7 @@ Playlist *PlaylistManager::AddPlaylist(const int id, const QString &name, const
|
||||
QObject::connect(ret, &Playlist::Error, this, &PlaylistManager::Error);
|
||||
QObject::connect(ret, &Playlist::PlayRequested, this, &PlaylistManager::PlayRequested);
|
||||
QObject::connect(playlist_container_->view(), &PlaylistView::ColumnAlignmentChanged, ret, &Playlist::SetColumnAlignment);
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, ret, &Playlist::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, ret, &Playlist::AlbumCoverLoaded);
|
||||
|
||||
playlists_[id] = Data(ret, name);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "settings/playlistsettingspage.h"
|
||||
#include "playlist.h"
|
||||
@@ -73,8 +74,8 @@ class PlaylistManagerInterface : public QObject {
|
||||
|
||||
virtual QString GetPlaylistName(const int index) const = 0;
|
||||
|
||||
virtual CollectionBackend *collection_backend() const = 0;
|
||||
virtual PlaylistBackend *playlist_backend() const = 0;
|
||||
virtual SharedPtr<CollectionBackend> collection_backend() const = 0;
|
||||
virtual SharedPtr<PlaylistBackend> playlist_backend() const = 0;
|
||||
virtual PlaylistSequence *sequence() const = 0;
|
||||
virtual PlaylistParser *parser() const = 0;
|
||||
virtual PlaylistContainer *playlist_container() const = 0;
|
||||
@@ -171,10 +172,10 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
QString GetPlaylistName(const int index) const override { return playlists_[index].name; }
|
||||
bool IsPlaylistFavorite(const int index) const { return playlists_[index].p->is_favorite(); }
|
||||
|
||||
void Init(CollectionBackend *collection_backend, PlaylistBackend *playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container);
|
||||
void Init(SharedPtr<CollectionBackend> collection_backend, SharedPtr<PlaylistBackend> playlist_backend, PlaylistSequence *sequence, PlaylistContainer *playlist_container);
|
||||
|
||||
CollectionBackend *collection_backend() const override { return collection_backend_; }
|
||||
PlaylistBackend *playlist_backend() const override { return playlist_backend_; }
|
||||
SharedPtr<CollectionBackend> collection_backend() const override { return collection_backend_; }
|
||||
SharedPtr<PlaylistBackend> playlist_backend() const override { return playlist_backend_; }
|
||||
PlaylistSequence *sequence() const override { return sequence_; }
|
||||
PlaylistParser *parser() const override { return parser_; }
|
||||
PlaylistContainer *playlist_container() const override { return playlist_container_; }
|
||||
@@ -249,8 +250,8 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
};
|
||||
|
||||
Application *app_;
|
||||
PlaylistBackend *playlist_backend_;
|
||||
CollectionBackend *collection_backend_;
|
||||
SharedPtr<PlaylistBackend> playlist_backend_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
PlaylistSequence *sequence_;
|
||||
PlaylistParser *parser_;
|
||||
PlaylistContainer *playlist_container_;
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
|
||||
class QMenu;
|
||||
class QAction;
|
||||
|
||||
@@ -92,7 +92,7 @@ class PlaylistSequence : public QWidget {
|
||||
|
||||
private:
|
||||
Ui_PlaylistSequence *ui_;
|
||||
std::unique_ptr<SettingsProvider> settings_;
|
||||
ScopedPtr<SettingsProvider> settings_;
|
||||
|
||||
QMenu *repeat_menu_;
|
||||
QMenu *shuffle_menu_;
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "widgets/favoritewidget.h"
|
||||
@@ -100,11 +101,11 @@ void PlaylistTabBar::SetActions(QAction *new_playlist, QAction *load_playlist) {
|
||||
|
||||
}
|
||||
|
||||
void PlaylistTabBar::SetManager(PlaylistManager *manager) {
|
||||
void PlaylistTabBar::SetManager(SharedPtr<PlaylistManager> manager) {
|
||||
|
||||
manager_ = manager;
|
||||
QObject::connect(manager_, &PlaylistManager::PlaylistFavorited, this, &PlaylistTabBar::PlaylistFavoritedSlot);
|
||||
QObject::connect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
QObject::connect(&*manager_, &PlaylistManager::PlaylistFavorited, this, &PlaylistTabBar::PlaylistFavoritedSlot);
|
||||
QObject::connect(&*manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
|
||||
}
|
||||
|
||||
@@ -112,7 +113,7 @@ void PlaylistTabBar::PlaylistManagerInitialized() {
|
||||
|
||||
// Signal that we are done loading and thus further changes should be committed to the db.
|
||||
initialized_ = true;
|
||||
QObject::disconnect(manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
QObject::disconnect(&*manager_, &PlaylistManager::PlaylistManagerInitialized, this, &PlaylistTabBar::PlaylistManagerInitialized);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ class QTimerEvent;
|
||||
class PlaylistManager;
|
||||
class RenameTabLineEdit;
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
|
||||
class PlaylistTabBar : public QTabBar {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -56,7 +58,7 @@ class PlaylistTabBar : public QTabBar {
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void SetActions(QAction *new_playlist, QAction *load_playlist);
|
||||
void SetManager(PlaylistManager *manager);
|
||||
void SetManager(SharedPtr<PlaylistManager> manager);
|
||||
|
||||
// We use IDs to refer to tabs so the tabs can be moved around (and their indexes change).
|
||||
int index_of(const int id) const;
|
||||
@@ -106,7 +108,7 @@ class PlaylistTabBar : public QTabBar {
|
||||
void SaveSlot();
|
||||
|
||||
private:
|
||||
PlaylistManager *manager_;
|
||||
SharedPtr<PlaylistManager> manager_;
|
||||
|
||||
QMenu *menu_;
|
||||
int menu_index_;
|
||||
|
||||
@@ -232,11 +232,11 @@ void PlaylistView::Init(Application *app) {
|
||||
|
||||
SetItemDelegates();
|
||||
|
||||
QObject::connect(app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &PlaylistView::SongChanged);
|
||||
QObject::connect(app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &PlaylistView::AlbumCoverLoaded);
|
||||
QObject::connect(app_->player(), &Player::Playing, this, &PlaylistView::StartGlowing);
|
||||
QObject::connect(app_->player(), &Player::Paused, this, &PlaylistView::StopGlowing);
|
||||
QObject::connect(app_->player(), &Player::Stopped, this, &PlaylistView::Stopped);
|
||||
QObject::connect(&*app_->playlist_manager(), &PlaylistManager::CurrentSongChanged, this, &PlaylistView::SongChanged);
|
||||
QObject::connect(&*app_->current_albumcover_loader(), &CurrentAlbumCoverLoader::AlbumCoverLoaded, this, &PlaylistView::AlbumCoverLoaded);
|
||||
QObject::connect(&*app_->player(), &Player::Playing, this, &PlaylistView::StartGlowing);
|
||||
QObject::connect(&*app_->player(), &Player::Paused, this, &PlaylistView::StopGlowing);
|
||||
QObject::connect(&*app_->player(), &Player::Stopped, this, &PlaylistView::Stopped);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QAbstractItemDelegate>
|
||||
@@ -47,6 +45,7 @@
|
||||
#include <QBasicTimer>
|
||||
#include <QCommonStyle>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "covermanager/albumcoverloaderresult.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
@@ -91,7 +90,7 @@ class PlaylistProxyStyle : public QProxyStyle {
|
||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<QCommonStyle> common_style_;
|
||||
ScopedPtr<QCommonStyle> common_style_;
|
||||
};
|
||||
|
||||
class PlaylistView : public QTreeView {
|
||||
|
||||
@@ -27,12 +27,13 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/songloader.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "playlist.h"
|
||||
#include "songloaderinserter.h"
|
||||
|
||||
SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player, QObject *parent)
|
||||
SongLoaderInserter::SongLoaderInserter(SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent)
|
||||
: QObject(parent),
|
||||
task_manager_(task_manager),
|
||||
destination_(nullptr),
|
||||
@@ -40,7 +41,7 @@ SongLoaderInserter::SongLoaderInserter(TaskManager *task_manager, CollectionBack
|
||||
play_now_(true),
|
||||
enqueue_(false),
|
||||
enqueue_next_(false),
|
||||
collection_(collection),
|
||||
collection_backend_(collection_backend),
|
||||
player_(player) {}
|
||||
|
||||
SongLoaderInserter::~SongLoaderInserter() { qDeleteAll(pending_); }
|
||||
@@ -58,7 +59,7 @@ void SongLoaderInserter::Load(Playlist *destination, int row, bool play_now, boo
|
||||
QObject::connect(this, &SongLoaderInserter::EffectiveLoadFinished, destination, &Playlist::UpdateItems);
|
||||
|
||||
for (const QUrl &url : urls) {
|
||||
SongLoader *loader = new SongLoader(collection_, player_, this);
|
||||
SongLoader *loader = new SongLoader(collection_backend_, player_, this);
|
||||
|
||||
SongLoader::Result ret = loader->Load(url);
|
||||
|
||||
@@ -103,7 +104,7 @@ void SongLoaderInserter::LoadAudioCD(Playlist *destination, int row, bool play_n
|
||||
enqueue_ = enqueue;
|
||||
enqueue_next_ = enqueue_next;
|
||||
|
||||
SongLoader *loader = new SongLoader(collection_, player_, this);
|
||||
SongLoader *loader = new SongLoader(collection_backend_, player_, this);
|
||||
QObject::connect(loader, &SongLoader::AudioCDTracksLoadFinished, this, [this, loader]() { AudioCDTracksLoadFinished(loader); });
|
||||
QObject::connect(loader, &SongLoader::LoadAudioCDFinished, this, &SongLoaderInserter::AudioCDTagsLoaded);
|
||||
qLog(Info) << "Loading audio CD...";
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class Player;
|
||||
@@ -41,7 +42,7 @@ class SongLoaderInserter : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SongLoaderInserter(TaskManager *task_manager, CollectionBackendInterface *collection, const Player *player, QObject *parent = nullptr);
|
||||
explicit SongLoaderInserter(SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackendInterface> collection_backend, const SharedPtr<Player> player, QObject *parent = nullptr);
|
||||
~SongLoaderInserter() override;
|
||||
|
||||
void Load(Playlist *destination, int row, bool play_now, bool enqueue, bool enqueue_next, const QList<QUrl> &urls);
|
||||
@@ -62,7 +63,7 @@ class SongLoaderInserter : public QObject {
|
||||
void AsyncLoad();
|
||||
|
||||
private:
|
||||
TaskManager *task_manager_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
|
||||
Playlist *destination_;
|
||||
int row_;
|
||||
@@ -73,8 +74,8 @@ class SongLoaderInserter : public QObject {
|
||||
SongList songs_;
|
||||
|
||||
QList<SongLoader*> pending_;
|
||||
CollectionBackendInterface *collection_;
|
||||
const Player *player_;
|
||||
SharedPtr<CollectionBackendInterface> collection_backend_;
|
||||
const SharedPtr<Player> player_;
|
||||
};
|
||||
|
||||
#endif // SONGLOADERINSERTER_H
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <QObject>
|
||||
#include <QMimeData>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/mimedata.h"
|
||||
#include "core/song.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ class SongMimeData : public MimeData {
|
||||
public:
|
||||
explicit SongMimeData(QObject* = nullptr) : MimeData(), backend(nullptr) {}
|
||||
|
||||
CollectionBackendInterface *backend;
|
||||
SharedPtr<CollectionBackendInterface> backend;
|
||||
SongList songs;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user