Refactoring
This commit is contained in:
@@ -24,24 +24,33 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "cddasongloader.h"
|
||||
#include "connecteddevice.h"
|
||||
#include "cddadevice.h"
|
||||
|
||||
class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
CddaDevice::CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, int database_id, bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
CddaDevice::CddaDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, device_manager, task_manager, database, tagreader_client, albumcover_loader, database_id, first_time, parent),
|
||||
cdda_song_loader_(url) {
|
||||
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsDurationLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(&cdda_song_loader_, &CddaSongLoader::SongsMetadataLoaded, this, &CddaDevice::SongsLoaded);
|
||||
QObject::connect(this, &CddaDevice::SongsDiscovered, model_, &CollectionModel::AddReAddOrUpdate);
|
||||
QObject::connect(this, &CddaDevice::SongsDiscovered, collection_model_, &CollectionModel::AddReAddOrUpdate);
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +73,7 @@ void CddaDevice::Refresh() {
|
||||
|
||||
void CddaDevice::SongsLoaded(const SongList &songs) {
|
||||
|
||||
model_->Reset();
|
||||
collection_model_->Reset();
|
||||
Q_EMIT SongsDiscovered(songs);
|
||||
song_count_ = songs.size();
|
||||
|
||||
|
||||
@@ -24,30 +24,42 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <gst/audio/gstaudiocdsrc.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
// These must come after Qt includes
|
||||
#include <cdio/cdio.h>
|
||||
#include <gst/audio/gstaudiocdsrc.h>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "cddasongloader.h"
|
||||
#include "connecteddevice.h"
|
||||
|
||||
class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
|
||||
class CddaDevice : public ConnectedDevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE explicit CddaDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
bool Init() override;
|
||||
void Refresh() override;
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
#include <gst/tag/tag.h>
|
||||
|
||||
#include "cddasongloader.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/networkaccessmanager.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
#include "constants/timeconstants.h"
|
||||
|
||||
using std::make_shared;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <gst/gstelement.h>
|
||||
#include <gst/audio/gstaudiocdsrc.h>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#ifdef HAVE_MUSICBRAINZ
|
||||
# include "musicbrainz/musicbrainzclient.h"
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/database.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
@@ -41,47 +41,58 @@
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
using std::make_shared;
|
||||
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
ConnectedDevice::ConnectedDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
app_(app),
|
||||
url_(url),
|
||||
first_time_(first_time),
|
||||
lister_(lister),
|
||||
unique_id_(unique_id),
|
||||
database_id_(database_id),
|
||||
manager_(manager),
|
||||
backend_(nullptr),
|
||||
model_(nullptr),
|
||||
device_manager_(device_manager),
|
||||
collection_backend_(nullptr),
|
||||
collection_model_(nullptr),
|
||||
song_count_(0) {
|
||||
|
||||
Q_UNUSED(tagreader_client)
|
||||
|
||||
qLog(Info) << "Connected" << url << unique_id << first_time;
|
||||
|
||||
// Create the backend in the database thread.
|
||||
backend_ = make_shared<CollectionBackend>();
|
||||
backend_->moveToThread(app_->database()->thread());
|
||||
qLog(Debug) << &*backend_ << "for device" << unique_id_ << "moved to thread" << app_->database()->thread();
|
||||
collection_backend_ = make_shared<CollectionBackend>();
|
||||
collection_backend_->moveToThread(database->thread());
|
||||
qLog(Debug) << &*collection_backend_ << "for device" << unique_id_ << "moved to thread" << database->thread();
|
||||
|
||||
if (url_.scheme() != "cdda"_L1) {
|
||||
QObject::connect(&*backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::TotalSongCountUpdated, this, &ConnectedDevice::BackendTotalSongCountUpdated);
|
||||
}
|
||||
|
||||
backend_->Init(app_->database(),
|
||||
app_->task_manager(),
|
||||
Song::Source::Device,
|
||||
QStringLiteral("device_%1_songs").arg(database_id),
|
||||
QStringLiteral("device_%1_directories").arg(database_id),
|
||||
QStringLiteral("device_%1_subdirectories").arg(database_id));
|
||||
collection_backend_->Init(database,
|
||||
task_manager,
|
||||
Song::Source::Device,
|
||||
QStringLiteral("device_%1_songs").arg(database_id),
|
||||
QStringLiteral("device_%1_directories").arg(database_id),
|
||||
QStringLiteral("device_%1_subdirectories").arg(database_id));
|
||||
|
||||
// Create the model
|
||||
model_ = new CollectionModel(backend_, app_, this);
|
||||
collection_model_ = new CollectionModel(collection_backend_, albumcover_loader, this);
|
||||
|
||||
}
|
||||
|
||||
void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const bool first_time, const bool rewrite_path) {
|
||||
|
||||
QList<CollectionDirectory> directories = backend_->GetAllDirectories();
|
||||
QList<CollectionDirectory> directories = collection_backend_->GetAllDirectories();
|
||||
if (first_time || directories.isEmpty()) {
|
||||
backend_->AddDirectory(mount_point);
|
||||
collection_backend_->AddDirectory(mount_point);
|
||||
}
|
||||
else {
|
||||
if (rewrite_path) {
|
||||
@@ -95,12 +106,12 @@ void ConnectedDevice::InitBackendDirectory(const QString &mount_point, const boo
|
||||
if (dir.path != mount_point) {
|
||||
// The directory is different, commence the munging.
|
||||
qLog(Info) << "Changing path from" << dir.path << "to" << mount_point;
|
||||
backend_->ChangeDirPath(dir.id, dir.path, mount_point);
|
||||
collection_backend_->ChangeDirPath(dir.id, dir.path, mount_point);
|
||||
}
|
||||
}
|
||||
|
||||
// Load the directory properly now
|
||||
backend_->LoadDirectoriesAsync();
|
||||
collection_backend_->LoadDirectoriesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,8 +120,8 @@ void ConnectedDevice::ConnectAsync() { Q_EMIT DeviceConnectFinished(unique_id_,
|
||||
|
||||
void ConnectedDevice::Close() {
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &ConnectedDevice::BackendCloseFinished);
|
||||
backend_->ExitAsync();
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::ExitFinished, this, &ConnectedDevice::BackendCloseFinished);
|
||||
collection_backend_->ExitAsync();
|
||||
|
||||
}
|
||||
|
||||
@@ -122,13 +133,13 @@ void ConnectedDevice::BackendCloseFinished() {
|
||||
|
||||
void ConnectedDevice::Eject() {
|
||||
|
||||
DeviceInfo *info = manager_->FindDeviceById(unique_id_);
|
||||
DeviceInfo *info = device_manager_->FindDeviceById(unique_id_);
|
||||
if (!info) return;
|
||||
|
||||
QModelIndex idx = manager_->ItemToIndex(info);
|
||||
QModelIndex idx = device_manager_->ItemToIndex(info);
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
manager_->UnmountAsync(idx);
|
||||
device_manager_->UnmountAsync(idx);
|
||||
|
||||
}
|
||||
|
||||
@@ -150,10 +161,10 @@ bool ConnectedDevice::FinishDelete(bool success, QString &error_text) {
|
||||
|
||||
MusicStorage::TranscodeMode ConnectedDevice::GetTranscodeMode() const {
|
||||
|
||||
DeviceInfo *info = manager_->FindDeviceById(unique_id_);
|
||||
DeviceInfo *info = device_manager_->FindDeviceById(unique_id_);
|
||||
if (!info) return MusicStorage::TranscodeMode();
|
||||
|
||||
QModelIndex idx = manager_->ItemToIndex(info);
|
||||
QModelIndex idx = device_manager_->ItemToIndex(info);
|
||||
if (!idx.isValid()) return MusicStorage::TranscodeMode();
|
||||
|
||||
return static_cast<MusicStorage::TranscodeMode>(idx.data(DeviceManager::Role_TranscodeMode).toInt());
|
||||
@@ -162,10 +173,10 @@ MusicStorage::TranscodeMode ConnectedDevice::GetTranscodeMode() const {
|
||||
|
||||
Song::FileType ConnectedDevice::GetTranscodeFormat() const {
|
||||
|
||||
DeviceInfo *info = manager_->FindDeviceById(unique_id_);
|
||||
DeviceInfo *info = device_manager_->FindDeviceById(unique_id_);
|
||||
if (!info) return Song::FileType::Unknown;
|
||||
|
||||
QModelIndex idx = manager_->ItemToIndex(info);
|
||||
QModelIndex idx = device_manager_->ItemToIndex(info);
|
||||
if (!idx.isValid()) return Song::FileType::Unknown;
|
||||
|
||||
return static_cast<Song::FileType>(idx.data(DeviceManager::Role_TranscodeFormat).toInt());
|
||||
|
||||
@@ -30,15 +30,18 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class Application;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class CollectionBackend;
|
||||
class CollectionModel;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
|
||||
using std::enable_shared_from_this;
|
||||
|
||||
@@ -46,7 +49,17 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public enab
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectedDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
explicit ConnectedDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
Song::Source source() const override { return Song::Source::Device; }
|
||||
|
||||
@@ -63,7 +76,7 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public enab
|
||||
|
||||
DeviceLister *lister() const { return lister_; }
|
||||
QString unique_id() const { return unique_id_; }
|
||||
CollectionModel *model() const { return model_; }
|
||||
CollectionModel *collection_model() const { return collection_model_; }
|
||||
QUrl url() const { return url_; }
|
||||
qint64 song_count() const { return song_count_; }
|
||||
|
||||
@@ -81,23 +94,20 @@ class ConnectedDevice : public QObject, public virtual MusicStorage, public enab
|
||||
void SongCountUpdated(const int count);
|
||||
void DeviceConnectFinished(const QString &id, const bool success);
|
||||
void DeviceCloseFinished(const QString &id);
|
||||
void Error(const QString &error);
|
||||
|
||||
protected:
|
||||
void InitBackendDirectory(const QString &mount_point, const bool first_time, const bool rewrite_path = true);
|
||||
|
||||
protected:
|
||||
Application *app_;
|
||||
|
||||
QUrl url_;
|
||||
bool first_time_;
|
||||
DeviceLister *lister_;
|
||||
QString unique_id_;
|
||||
int database_id_;
|
||||
SharedPtr<DeviceManager> manager_;
|
||||
|
||||
SharedPtr<CollectionBackend> backend_;
|
||||
CollectionModel *model_;
|
||||
|
||||
DeviceManager *device_manager_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
CollectionModel *collection_model_;
|
||||
qint64 song_count_;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <QString>
|
||||
#include <QSqlDatabase>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/database.h"
|
||||
#include "core/sqlquery.h"
|
||||
#include "core/scopedtransaction.h"
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
|
||||
|
||||
@@ -45,10 +45,9 @@
|
||||
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/database.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
@@ -88,20 +87,27 @@ using std::make_unique;
|
||||
const int DeviceManager::kDeviceIconSize = 32;
|
||||
const int DeviceManager::kDeviceIconOverlaySize = 16;
|
||||
|
||||
DeviceManager::DeviceManager(Application *app, QObject *parent)
|
||||
DeviceManager::DeviceManager(const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
QObject *parent)
|
||||
: SimpleTreeModel<DeviceInfo>(new DeviceInfo(this), parent),
|
||||
app_(app),
|
||||
task_manager_(task_manager),
|
||||
database_(database),
|
||||
tagreader_client_(tagreader_client),
|
||||
albumcover_loader_(albumcover_loader),
|
||||
not_connected_overlay_(IconLoader::Load(u"edit-delete"_s)) {
|
||||
|
||||
setObjectName(QLatin1String(metaObject()->className()));
|
||||
|
||||
thread_pool_.setMaxThreadCount(1);
|
||||
QObject::connect(&*app_->task_manager(), &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);
|
||||
QObject::connect(&*task_manager, &TaskManager::TasksChanged, this, &DeviceManager::TasksChanged);
|
||||
|
||||
// Create the backend in the database thread
|
||||
backend_ = make_unique<DeviceDatabaseBackend>();
|
||||
backend_->moveToThread(app_->database()->thread());
|
||||
backend_->Init(app_->database());
|
||||
backend_->moveToThread(database->thread());
|
||||
backend_->Init(database);
|
||||
|
||||
QObject::connect(this, &DeviceManager::DeviceCreatedFromDB, this, &DeviceManager::AddDeviceFromDB);
|
||||
|
||||
@@ -225,6 +231,7 @@ void DeviceManager::DeviceDestroyed() {
|
||||
if (wait_for_exit_.isEmpty()) CloseListers();
|
||||
|
||||
}
|
||||
|
||||
void DeviceManager::LoadAllDevices() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() != qApp->thread());
|
||||
@@ -363,7 +370,7 @@ QVariant DeviceManager::data(const QModelIndex &idx, int role) const {
|
||||
|
||||
QString ret = info->device_->url().path();
|
||||
#ifdef Q_OS_WIN32
|
||||
if (ret.startsWith('/')) ret.remove(0, 1);
|
||||
if (ret.startsWith(u'/')) ret.remove(0, 1);
|
||||
#endif
|
||||
return QDir::toNativeSeparators(ret);
|
||||
}
|
||||
@@ -627,7 +634,7 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
url_strings << url.toString();
|
||||
}
|
||||
|
||||
app_->AddError(tr("This type of device is not supported: %1").arg(url_strings.join(", "_L1)));
|
||||
Q_EMIT DeviceError(tr("This type of device is not supported: %1").arg(url_strings.join(", "_L1)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -636,8 +643,11 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
Q_ARG(QUrl, device_url),
|
||||
Q_ARG(DeviceLister*, info->BestBackend()->lister_),
|
||||
Q_ARG(QString, info->BestBackend()->unique_id_),
|
||||
Q_ARG(SharedPtr<DeviceManager>, app_->device_manager()),
|
||||
Q_ARG(Application*, app_),
|
||||
Q_ARG(DeviceManager*, this),
|
||||
Q_ARG(SharedPtr<TaskManager>, task_manager_),
|
||||
Q_ARG(SharedPtr<Database>, database_),
|
||||
Q_ARG(SharedPtr<TagReaderClient>, tagreader_client_),
|
||||
Q_ARG(SharedPtr<AlbumCoverLoader>, albumcover_loader_),
|
||||
Q_ARG(int, info->database_id_),
|
||||
Q_ARG(bool, first_time));
|
||||
|
||||
@@ -664,7 +674,10 @@ SharedPtr<ConnectedDevice> DeviceManager::Connect(DeviceInfo *info) {
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::SongCountUpdated, this, &DeviceManager::DeviceSongCountUpdated);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::DeviceConnectFinished, this, &DeviceManager::DeviceConnectFinished);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::DeviceCloseFinished, this, &DeviceManager::DeviceCloseFinished);
|
||||
QObject::connect(&*info->device_, &ConnectedDevice::Error, this, &DeviceManager::DeviceError);
|
||||
|
||||
ret->ConnectAsync();
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
@@ -842,7 +855,7 @@ void DeviceManager::DeviceTaskStarted(const int id) {
|
||||
|
||||
void DeviceManager::TasksChanged() {
|
||||
|
||||
const QList<TaskManager::Task> tasks = app_->task_manager()->GetTasks();
|
||||
const QList<TaskManager::Task> tasks = task_manager_->GetTasks();
|
||||
QList<QPersistentModelIndex> finished_tasks = active_tasks_.values();
|
||||
|
||||
for (const TaskManager::Task &task : tasks) {
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
#include <QUrl>
|
||||
#include <QIcon>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/simpletreemodel.h"
|
||||
@@ -49,7 +49,10 @@
|
||||
class QModelIndex;
|
||||
class QPersistentModelIndex;
|
||||
|
||||
class Application;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
class ConnectedDevice;
|
||||
class DeviceLister;
|
||||
class DeviceStateFilterModel;
|
||||
@@ -58,7 +61,12 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DeviceManager(Application *app, QObject *parent = nullptr);
|
||||
explicit DeviceManager(const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~DeviceManager() override;
|
||||
|
||||
enum Role {
|
||||
@@ -123,6 +131,7 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
void DeviceConnected(const QModelIndex idx);
|
||||
void DeviceDisconnected(const QModelIndex idx);
|
||||
void DeviceCreatedFromDB(DeviceInfo *info);
|
||||
void DeviceError(const QString &error);
|
||||
|
||||
private Q_SLOTS:
|
||||
void PhysicalDeviceAdded(const QString &id);
|
||||
@@ -152,7 +161,11 @@ class DeviceManager : public SimpleTreeModel<DeviceInfo> {
|
||||
void CloseBackend();
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
const SharedPtr<TaskManager> task_manager_;
|
||||
const SharedPtr<Database> database_;
|
||||
const SharedPtr<TagReaderClient> tagreader_client_;
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader_;
|
||||
|
||||
ScopedPtr<DeviceDatabaseBackend> backend_;
|
||||
|
||||
DeviceStateFilterModel *connected_devices_model_;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "widgets/freespacebar.h"
|
||||
@@ -62,7 +62,7 @@ using namespace Qt::Literals::StringLiterals;
|
||||
DeviceProperties::DeviceProperties(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_DeviceProperties),
|
||||
manager_(nullptr),
|
||||
device_manager_(nullptr),
|
||||
updating_formats_(false) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
@@ -76,12 +76,12 @@ DeviceProperties::DeviceProperties(QWidget *parent)
|
||||
|
||||
DeviceProperties::~DeviceProperties() { delete ui_; }
|
||||
|
||||
void DeviceProperties::SetDeviceManager(SharedPtr<DeviceManager> manager) {
|
||||
void DeviceProperties::Init(const SharedPtr<DeviceManager> device_manager) {
|
||||
|
||||
manager_ = manager;
|
||||
QObject::connect(&*manager_, &DeviceManager::dataChanged, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*manager_, &DeviceManager::rowsInserted, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*manager_, &DeviceManager::rowsRemoved, this, &DeviceProperties::ModelChanged);
|
||||
device_manager_ = device_manager;
|
||||
QObject::connect(&*device_manager_, &DeviceManager::dataChanged, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*device_manager_, &DeviceManager::rowsInserted, this, &DeviceProperties::ModelChanged);
|
||||
QObject::connect(&*device_manager_, &DeviceManager::rowsRemoved, this, &DeviceProperties::ModelChanged);
|
||||
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void DeviceProperties::UpdateHardwareInfo() {
|
||||
|
||||
// Hardware information
|
||||
QString id = index_.data(DeviceManager::Role_UniqueId).toString();
|
||||
if (DeviceLister *lister = manager_->GetLister(index_)) {
|
||||
if (DeviceLister *lister = device_manager_->GetLister(index_)) {
|
||||
QVariantMap info = lister->DeviceHardwareInfo(id);
|
||||
|
||||
// Remove empty items
|
||||
@@ -202,8 +202,8 @@ void DeviceProperties::UpdateHardwareInfo() {
|
||||
|
||||
void DeviceProperties::UpdateFormats() {
|
||||
|
||||
DeviceLister *lister = manager_->GetLister(index_);
|
||||
SharedPtr<ConnectedDevice> device = manager_->GetConnectedDevice(index_);
|
||||
DeviceLister *lister = device_manager_->GetLister(index_);
|
||||
SharedPtr<ConnectedDevice> device = device_manager_->GetConnectedDevice(index_);
|
||||
|
||||
// Transcode mode
|
||||
MusicStorage::TranscodeMode mode = static_cast<MusicStorage::TranscodeMode>(index_.data(DeviceManager::Role_TranscodeMode).toInt());
|
||||
@@ -274,11 +274,11 @@ void DeviceProperties::accept() {
|
||||
icon_name = ui_->icon->currentItem()->data(Qt::UserRole).toString();
|
||||
}
|
||||
|
||||
manager_->SetDeviceOptions(index_, ui_->name->text(), icon_name, mode, format);
|
||||
device_manager_->SetDeviceOptions(index_, ui_->name->text(), icon_name, mode, format);
|
||||
|
||||
}
|
||||
|
||||
void DeviceProperties::OpenDevice() { manager_->Connect(index_); }
|
||||
void DeviceProperties::OpenDevice() { device_manager_->Connect(index_); }
|
||||
|
||||
void DeviceProperties::UpdateFormatsFinished() {
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QWidget;
|
||||
@@ -48,7 +48,7 @@ class DeviceProperties : public QDialog {
|
||||
explicit DeviceProperties(QWidget *parent = nullptr);
|
||||
~DeviceProperties() override;
|
||||
|
||||
void SetDeviceManager(SharedPtr<DeviceManager> manager);
|
||||
void Init(const SharedPtr<DeviceManager> device_manager);
|
||||
void ShowDevice(const QModelIndex &idx);
|
||||
|
||||
public Q_SLOTS:
|
||||
@@ -67,7 +67,7 @@ class DeviceProperties : public QDialog {
|
||||
private:
|
||||
Ui_DeviceProperties *ui_;
|
||||
|
||||
SharedPtr<DeviceManager> manager_;
|
||||
SharedPtr<DeviceManager> device_manager_;
|
||||
QPersistentModelIndex index_;
|
||||
|
||||
bool updating_formats_;
|
||||
|
||||
@@ -43,9 +43,11 @@ bool DeviceStateFilterModel::filterAcceptsRow(const int row, const QModelIndex &
|
||||
return sourceModel()->index(row, 0).data(DeviceManager::Role_State).toInt() != state_ && sourceModel()->index(row, 0).data(DeviceManager::Role_CopyMusic).toBool();
|
||||
}
|
||||
|
||||
void DeviceStateFilterModel::ProxyRowCountChanged(const QModelIndex &idx, const int, const int) {
|
||||
void DeviceStateFilterModel::ProxyRowCountChanged(const QModelIndex &idx, const int first, const int last) {
|
||||
|
||||
Q_UNUSED(idx)
|
||||
Q_UNUSED(first);
|
||||
Q_UNUSED(last);
|
||||
|
||||
Q_EMIT IsEmptyChanged(rowCount() == 0);
|
||||
|
||||
|
||||
@@ -48,9 +48,9 @@
|
||||
#include <QMessageBox>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/application.h"
|
||||
#include "core/deletefiles.h"
|
||||
#include "core/mergedproxymodel.h"
|
||||
#include "core/mimedata.h"
|
||||
@@ -61,8 +61,8 @@
|
||||
#include "collection/collectiondirectorymodel.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectionitemdelegate.h"
|
||||
#include "connecteddevice.h"
|
||||
#include "devicelister.h"
|
||||
#include "connecteddevice.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceproperties.h"
|
||||
#include "deviceview.h"
|
||||
@@ -175,7 +175,6 @@ void DeviceItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
|
||||
DeviceView::DeviceView(QWidget *parent)
|
||||
: AutoExpandingTreeView(parent),
|
||||
app_(nullptr),
|
||||
merged_model_(nullptr),
|
||||
sort_model_(nullptr),
|
||||
properties_dialog_(new DeviceProperties),
|
||||
@@ -202,16 +201,20 @@ DeviceView::DeviceView(QWidget *parent)
|
||||
|
||||
DeviceView::~DeviceView() = default;
|
||||
|
||||
void DeviceView::SetApplication(Application *app) {
|
||||
void DeviceView::Init(const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<DeviceManager> device_manager,
|
||||
CollectionDirectoryModel *collection_directory_model) {
|
||||
|
||||
Q_ASSERT(app_ == nullptr);
|
||||
app_ = app;
|
||||
task_manager_ = task_manager;
|
||||
tagreader_client_ = tagreader_client;
|
||||
device_manager_ = device_manager;
|
||||
|
||||
QObject::connect(&*app_->device_manager(), &DeviceManager::DeviceConnected, this, &DeviceView::DeviceConnected);
|
||||
QObject::connect(&*app_->device_manager(), &DeviceManager::DeviceDisconnected, this, &DeviceView::DeviceDisconnected);
|
||||
QObject::connect(&*device_manager_, &DeviceManager::DeviceConnected, this, &DeviceView::DeviceConnected);
|
||||
QObject::connect(&*device_manager_, &DeviceManager::DeviceDisconnected, this, &DeviceView::DeviceDisconnected);
|
||||
|
||||
sort_model_ = new QSortFilterProxyModel(this);
|
||||
sort_model_->setSourceModel(&*app_->device_manager());
|
||||
sort_model_->setSourceModel(&*device_manager_);
|
||||
sort_model_->setDynamicSortFilter(true);
|
||||
sort_model_->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
sort_model_->sort(0);
|
||||
@@ -222,10 +225,10 @@ void DeviceView::SetApplication(Application *app) {
|
||||
|
||||
QObject::connect(merged_model_, &MergedProxyModel::SubModelReset, this, &AutoExpandingTreeView::RecursivelyExpandSlot);
|
||||
|
||||
properties_dialog_->SetDeviceManager(app_->device_manager());
|
||||
properties_dialog_->Init(device_manager_);
|
||||
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(app_->task_manager(), nullptr, this);
|
||||
organize_dialog_->SetDestinationModel(app_->collection_model()->directory_model());
|
||||
organize_dialog_ = make_unique<OrganizeDialog>(task_manager, tagreader_client, nullptr, this);
|
||||
organize_dialog_->SetDestinationModel(collection_directory_model);
|
||||
|
||||
}
|
||||
|
||||
@@ -257,8 +260,8 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
const QModelIndex collection_index = MapToCollection(menu_index_);
|
||||
|
||||
if (device_index.isValid()) {
|
||||
const bool is_plugged_in = app_->device_manager()->GetLister(device_index);
|
||||
const bool is_remembered = app_->device_manager()->GetDatabaseId(device_index) != -1;
|
||||
const bool is_plugged_in = device_manager_->GetLister(device_index);
|
||||
const bool is_remembered = device_manager_->GetDatabaseId(device_index) != -1;
|
||||
|
||||
forget_action_->setEnabled(is_remembered);
|
||||
eject_action_->setEnabled(is_plugged_in);
|
||||
@@ -270,7 +273,7 @@ void DeviceView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
|
||||
bool is_filesystem_device = false;
|
||||
if (parent_device_index.isValid()) {
|
||||
SharedPtr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(parent_device_index);
|
||||
SharedPtr<ConnectedDevice> device = device_manager_->GetConnectedDevice(parent_device_index);
|
||||
if (device && !device->LocalPath().isEmpty()) is_filesystem_device = true;
|
||||
}
|
||||
|
||||
@@ -309,21 +312,21 @@ QModelIndex DeviceView::MapToCollection(const QModelIndex &merged_model_index) c
|
||||
|
||||
void DeviceView::Connect() {
|
||||
QModelIndex device_idx = MapToDevice(menu_index_);
|
||||
app_->device_manager()->data(device_idx, MusicStorage::Role_StorageForceConnect);
|
||||
device_manager_->data(device_idx, MusicStorage::Role_StorageForceConnect);
|
||||
}
|
||||
|
||||
void DeviceView::DeviceConnected(const QModelIndex &idx) {
|
||||
|
||||
if (!idx.isValid()) return;
|
||||
|
||||
SharedPtr<ConnectedDevice> device = app_->device_manager()->GetConnectedDevice(idx);
|
||||
SharedPtr<ConnectedDevice> device = device_manager_->GetConnectedDevice(idx);
|
||||
if (!device) return;
|
||||
|
||||
QModelIndex sort_idx = sort_model_->mapFromSource(idx);
|
||||
if (!sort_idx.isValid()) return;
|
||||
|
||||
QSortFilterProxyModel *sort_model = new QSortFilterProxyModel(device->model());
|
||||
sort_model->setSourceModel(device->model());
|
||||
QSortFilterProxyModel *sort_model = new QSortFilterProxyModel(device->collection_model());
|
||||
sort_model->setSourceModel(device->collection_model());
|
||||
sort_model->setSortRole(CollectionModel::Role_SortText);
|
||||
sort_model->setDynamicSortFilter(true);
|
||||
sort_model->sort(0);
|
||||
@@ -341,8 +344,8 @@ void DeviceView::DeviceDisconnected(const QModelIndex &idx) {
|
||||
void DeviceView::Forget() {
|
||||
|
||||
QModelIndex device_idx = MapToDevice(menu_index_);
|
||||
QString unique_id = app_->device_manager()->data(device_idx, DeviceManager::Role_UniqueId).toString();
|
||||
if (app_->device_manager()->GetLister(device_idx) && app_->device_manager()->GetLister(device_idx)->AskForScan(unique_id)) {
|
||||
QString unique_id = device_manager_->data(device_idx, DeviceManager::Role_UniqueId).toString();
|
||||
if (device_manager_->GetLister(device_idx) && device_manager_->GetLister(device_idx)->AskForScan(unique_id)) {
|
||||
ScopedPtr<QMessageBox> dialog(new QMessageBox(
|
||||
QMessageBox::Question, tr("Forget device"),
|
||||
tr("Forgetting a device will remove it from this list and Strawberry will have to rescan all the songs again next time you connect it."),
|
||||
@@ -353,7 +356,7 @@ void DeviceView::Forget() {
|
||||
if (dialog->clickedButton() != forget) return;
|
||||
}
|
||||
|
||||
app_->device_manager()->Forget(device_idx);
|
||||
device_manager_->Forget(device_idx);
|
||||
|
||||
}
|
||||
|
||||
@@ -368,7 +371,7 @@ void DeviceView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
QModelIndex merged_index = indexAt(e->pos());
|
||||
QModelIndex device_index = MapToDevice(merged_index);
|
||||
if (device_index.isValid()) {
|
||||
if (!app_->device_manager()->GetConnectedDevice(device_index)) {
|
||||
if (!device_manager_->GetConnectedDevice(device_index)) {
|
||||
menu_index_ = merged_index;
|
||||
Connect();
|
||||
}
|
||||
@@ -433,7 +436,7 @@ void DeviceView::Delete() {
|
||||
|
||||
SharedPtr<MusicStorage> storage = device_index.data(MusicStorage::Role_Storage).value<SharedPtr<MusicStorage>>();
|
||||
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, false);
|
||||
DeleteFiles *delete_files = new DeleteFiles(task_manager_, storage, false);
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &DeviceView::DeleteFinished);
|
||||
delete_files->Start(GetSelectedSongs());
|
||||
|
||||
@@ -456,7 +459,7 @@ void DeviceView::Organize() {
|
||||
|
||||
void DeviceView::Unmount() {
|
||||
QModelIndex device_idx = MapToDevice(menu_index_);
|
||||
app_->device_manager()->Unmount(device_idx);
|
||||
device_manager_->Unmount(device_idx);
|
||||
}
|
||||
|
||||
void DeviceView::DeleteFinished(const SongList &songs_with_errors) {
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QString>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "collection/collectionitemdelegate.h"
|
||||
#include "widgets/autoexpandingtreeview.h"
|
||||
@@ -43,8 +44,11 @@ class QAction;
|
||||
class QMouseEvent;
|
||||
class QContextMenuEvent;
|
||||
|
||||
class Application;
|
||||
class TaskManager;
|
||||
class TagReaderClient;
|
||||
class DeviceManager;
|
||||
class DeviceProperties;
|
||||
class CollectionDirectoryModel;
|
||||
class MergedProxyModel;
|
||||
class OrganizeDialog;
|
||||
|
||||
@@ -67,7 +71,10 @@ class DeviceView : public AutoExpandingTreeView {
|
||||
explicit DeviceView(QWidget *parent = nullptr);
|
||||
~DeviceView() override;
|
||||
|
||||
void SetApplication(Application *app);
|
||||
void Init(const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<DeviceManager> device_manager,
|
||||
CollectionDirectoryModel *collection_directory_model);
|
||||
|
||||
// AutoExpandingTreeView
|
||||
bool CanRecursivelyExpand(const QModelIndex &idx) const override;
|
||||
@@ -102,7 +109,9 @@ class DeviceView : public AutoExpandingTreeView {
|
||||
SongList GetSelectedSongs() const;
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
SharedPtr<TagReaderClient> tagreader_client_;
|
||||
SharedPtr<DeviceManager> device_manager_;
|
||||
MergedProxyModel *merged_model_;
|
||||
QSortFilterProxyModel *sort_model_;
|
||||
|
||||
|
||||
@@ -25,53 +25,66 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/song.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/database.h"
|
||||
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectionwatcher.h"
|
||||
|
||||
#include "covermanager/albumcoverloader.h"
|
||||
|
||||
#include "connecteddevice.h"
|
||||
#include "devicemanager.h"
|
||||
#include "filesystemdevice.h"
|
||||
|
||||
class DeviceLister;
|
||||
|
||||
FilesystemDevice::FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
FilesystemDevice::FilesystemDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent)
|
||||
: FilesystemMusicStorage(Song::Source::Device, url.toLocalFile()),
|
||||
ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
watcher_(new CollectionWatcher(Song::Source::Device)),
|
||||
ConnectedDevice(url, lister, unique_id, device_manager, task_manager, database, tagreader_client, albumcover_loader, database_id, first_time, parent),
|
||||
collection_watcher_(new CollectionWatcher(Song::Source::Device, task_manager, tagreader_client, collection_backend_)),
|
||||
watcher_thread_(new QThread(this)) {
|
||||
|
||||
watcher_->moveToThread(watcher_thread_);
|
||||
collection_watcher_->moveToThread(watcher_thread_);
|
||||
watcher_thread_->start(QThread::IdlePriority);
|
||||
qLog(Debug) << watcher_ << "for device" << unique_id << "moved to thread" << watcher_thread_;
|
||||
|
||||
watcher_->set_device_name(manager->DeviceNameByID(unique_id));
|
||||
watcher_->set_backend(backend_);
|
||||
watcher_->set_task_manager(app_->task_manager());
|
||||
qLog(Debug) << collection_watcher_ << "for device" << unique_id << "moved to thread" << watcher_thread_;
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryAdded, watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*backend_, &CollectionBackend::DirectoryDeleted, watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsMTimeUpdated, &*backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsDeleted, &*backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsUnavailable, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SongsReadded, &*backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsDiscovered, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(watcher_, &CollectionWatcher::UpdateLastSeen, &*backend_, &CollectionBackend::UpdateLastSeen);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ScanStarted, this, &FilesystemDevice::TaskStarted);
|
||||
collection_watcher_->set_device_name(device_manager->DeviceNameByID(unique_id));
|
||||
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::DirectoryAdded, collection_watcher_, &CollectionWatcher::AddDirectory);
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::DirectoryDeleted, collection_watcher_, &CollectionWatcher::RemoveDirectory);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::NewOrUpdatedSongs, &*collection_backend_, &CollectionBackend::AddOrUpdateSongs);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SongsMTimeUpdated, &*collection_backend_, &CollectionBackend::UpdateMTimesOnly);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SongsDeleted, &*collection_backend_, &CollectionBackend::DeleteSongs);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SongsUnavailable, &*collection_backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SongsReadded, &*collection_backend_, &CollectionBackend::MarkSongsUnavailable);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SubdirsDiscovered, &*collection_backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::SubdirsMTimeUpdated, &*collection_backend_, &CollectionBackend::AddOrUpdateSubdirs);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::CompilationsNeedUpdating, &*collection_backend_, &CollectionBackend::CompilationsNeedUpdating);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::UpdateLastSeen, &*collection_backend_, &CollectionBackend::UpdateLastSeen);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::ScanStarted, this, &FilesystemDevice::TaskStarted);
|
||||
|
||||
}
|
||||
|
||||
FilesystemDevice::~FilesystemDevice() {
|
||||
|
||||
watcher_->Abort();
|
||||
watcher_->deleteLater();
|
||||
collection_watcher_->Abort();
|
||||
collection_watcher_->deleteLater();
|
||||
watcher_thread_->exit();
|
||||
watcher_thread_->wait();
|
||||
|
||||
@@ -80,7 +93,7 @@ FilesystemDevice::~FilesystemDevice() {
|
||||
bool FilesystemDevice::Init() {
|
||||
|
||||
InitBackendDirectory(url_.toLocalFile(), first_time_);
|
||||
model_->Init();
|
||||
collection_model_->Init();
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -93,15 +106,15 @@ void FilesystemDevice::Close() {
|
||||
|
||||
Q_ASSERT(QThread::currentThread() == thread());
|
||||
|
||||
wait_for_exit_ << &*backend_ << watcher_;
|
||||
wait_for_exit_ << &*collection_backend_ << collection_watcher_;
|
||||
|
||||
QObject::disconnect(&*backend_, nullptr, watcher_, nullptr);
|
||||
QObject::disconnect(watcher_, nullptr, &*backend_, nullptr);
|
||||
QObject::disconnect(&*collection_backend_, nullptr, collection_watcher_, nullptr);
|
||||
QObject::disconnect(collection_watcher_, nullptr, &*collection_backend_, nullptr);
|
||||
|
||||
QObject::connect(&*backend_, &CollectionBackend::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
QObject::connect(watcher_, &CollectionWatcher::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
backend_->ExitAsync();
|
||||
watcher_->ExitAsync();
|
||||
QObject::connect(&*collection_backend_, &CollectionBackend::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
QObject::connect(collection_watcher_, &CollectionWatcher::ExitFinished, this, &FilesystemDevice::ExitFinished);
|
||||
collection_backend_->ExitAsync();
|
||||
collection_watcher_->ExitAsync();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -30,21 +30,35 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/filesystemmusicstorage.h"
|
||||
#include "connecteddevice.h"
|
||||
|
||||
class QThread;
|
||||
class Application;
|
||||
class CollectionWatcher;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
class CollectionWatcher;
|
||||
|
||||
class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicStorage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE FilesystemDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE FilesystemDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~FilesystemDevice() override;
|
||||
|
||||
Song::Source source() const final { return Song::Source::Device; }
|
||||
@@ -59,7 +73,7 @@ class FilesystemDevice : public ConnectedDevice, public virtual FilesystemMusicS
|
||||
void ExitFinished();
|
||||
|
||||
private:
|
||||
CollectionWatcher *watcher_;
|
||||
CollectionWatcher *collection_watcher_;
|
||||
QThread *watcher_thread_;
|
||||
QList<QObject*> wait_for_exit_;
|
||||
};
|
||||
|
||||
@@ -572,7 +572,8 @@ QString GioLister::FindUniqueIdByVolume(GVolume *volume) const {
|
||||
|
||||
}
|
||||
|
||||
void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer) {
|
||||
void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer instance) {
|
||||
Q_UNUSED(instance)
|
||||
OperationFinished<GVolume>(std::bind(g_volume_eject_with_operation_finish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), object, result);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/scopedgobject.h"
|
||||
#include "includes/scopedgobject.h"
|
||||
#include "devicelister.h"
|
||||
|
||||
class GioLister : public DeviceLister {
|
||||
|
||||
@@ -38,12 +38,14 @@
|
||||
#include <QImage>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/temporaryfile.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/database.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "covermanager/albumcoverloader.h"
|
||||
#include "connecteddevice.h"
|
||||
#include "gpoddevice.h"
|
||||
#include "gpodloader.h"
|
||||
@@ -54,8 +56,19 @@ class DeviceManager;
|
||||
using std::make_shared;
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
GPodDevice::GPodDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, device_manager, task_manager, database, tagreader_client, albumcover_loader, database_id, first_time, parent),
|
||||
task_manager_(task_manager),
|
||||
loader_(nullptr),
|
||||
loader_thread_(nullptr),
|
||||
db_(nullptr),
|
||||
@@ -64,9 +77,9 @@ GPodDevice::GPodDevice(const QUrl &url, DeviceLister *lister, const QString &uni
|
||||
bool GPodDevice::Init() {
|
||||
|
||||
InitBackendDirectory(url_.path(), first_time_);
|
||||
model_->Init();
|
||||
collection_model_->Init();
|
||||
|
||||
loader_ = new GPodLoader(url_.path(), app_->task_manager(), backend_, shared_from_this());
|
||||
loader_ = new GPodLoader(url_.path(), task_manager_, collection_backend_, shared_from_this());
|
||||
loader_thread_ = new QThread();
|
||||
loader_->moveToThread(loader_thread_);
|
||||
|
||||
@@ -135,7 +148,9 @@ void GPodDevice::LoadFinished(Itdb_iTunesDB *db, const bool success) {
|
||||
|
||||
}
|
||||
|
||||
void GPodDevice::LoaderError(const QString &message) { app_->AddError(message); }
|
||||
void GPodDevice::LoaderError(const QString &message) {
|
||||
Q_EMIT Error(message);
|
||||
}
|
||||
|
||||
void GPodDevice::Start() {
|
||||
|
||||
@@ -240,7 +255,7 @@ bool GPodDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
error_text = tr("Could not copy %1 to %2: %3").arg(job.metadata_.url().toLocalFile(), url_.path(), QString::fromUtf8(error->message));
|
||||
g_error_free(error);
|
||||
qLog(Error) << error_text;
|
||||
app_->AddError(error_text);
|
||||
Q_EMIT Error(error_text);
|
||||
|
||||
// Need to remove the track from the db again
|
||||
itdb_track_remove(track);
|
||||
@@ -286,7 +301,7 @@ bool GPodDevice::WriteDatabase(QString &error_text) {
|
||||
else {
|
||||
error_text = tr("Writing database failed.");
|
||||
}
|
||||
app_->AddError(error_text);
|
||||
Q_EMIT Error(error_text);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -297,12 +312,12 @@ void GPodDevice::Finish(const bool success) {
|
||||
|
||||
// Update the collection model
|
||||
if (success) {
|
||||
if (!songs_to_add_.isEmpty()) backend_->AddOrUpdateSongs(songs_to_add_);
|
||||
if (!songs_to_remove_.isEmpty()) backend_->DeleteSongs(songs_to_remove_);
|
||||
if (!songs_to_add_.isEmpty()) collection_backend_->AddOrUpdateSongs(songs_to_add_);
|
||||
if (!songs_to_remove_.isEmpty()) collection_backend_->DeleteSongs(songs_to_remove_);
|
||||
}
|
||||
|
||||
// This is done in the organize thread so close the unique DB connection.
|
||||
backend_->Close();
|
||||
collection_backend_->Close();
|
||||
|
||||
songs_to_add_.clear();
|
||||
songs_to_remove_.clear();
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/temporaryfile.h"
|
||||
@@ -42,15 +42,29 @@
|
||||
#include "gpodloader.h"
|
||||
|
||||
class QThread;
|
||||
class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
|
||||
class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE GPodDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE GPodDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~GPodDevice() override;
|
||||
|
||||
bool Init() override;
|
||||
@@ -86,6 +100,7 @@ class GPodDevice : public ConnectedDevice, public virtual MusicStorage {
|
||||
bool WriteDatabase(QString &error_text);
|
||||
|
||||
protected:
|
||||
SharedPtr <TaskManager> task_manager_;
|
||||
GPodLoader *loader_;
|
||||
QThread *loader_thread_;
|
||||
|
||||
|
||||
@@ -29,14 +29,18 @@
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
#include "gpodloader.h"
|
||||
|
||||
GPodLoader::GPodLoader(const QString &mount_point, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, SharedPtr<ConnectedDevice> device, QObject *parent)
|
||||
GPodLoader::GPodLoader(const QString &mount_point,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<CollectionBackend> backend,
|
||||
const SharedPtr<ConnectedDevice> device,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
device_(device),
|
||||
mount_point_(mount_point),
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
|
||||
class QThread;
|
||||
@@ -41,7 +41,12 @@ class GPodLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GPodLoader(const QString &mount_point, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, SharedPtr<ConnectedDevice> device, QObject *parent = nullptr);
|
||||
explicit GPodLoader(const QString &mount_point,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<CollectionBackend> backend,
|
||||
const SharedPtr<ConnectedDevice> device,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~GPodLoader() override;
|
||||
|
||||
void set_music_path_prefix(const QString &prefix) { path_prefix_ = prefix; }
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <libmtp.h>
|
||||
|
||||
#include <AvailabilityMacros.h>
|
||||
@@ -38,13 +40,12 @@
|
||||
#include <QUrl>
|
||||
#include <QScopeGuard>
|
||||
|
||||
#include "config.h"
|
||||
#include "macosdevicelister.h"
|
||||
#include "mtpconnection.h"
|
||||
#include "includes/scoped_cftyperef.h"
|
||||
#include "includes/scoped_nsobject.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/scoped_cftyperef.h"
|
||||
#include "core/scoped_nsautorelease_pool.h"
|
||||
#include "core/scoped_nsobject.h"
|
||||
|
||||
#import <AppKit/NSWorkspace.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
|
||||
@@ -33,9 +33,8 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/application.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "collection/collectionmodel.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
@@ -46,13 +45,27 @@
|
||||
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class AlbumCoverLoader;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
|
||||
bool MtpDevice::sInitializedLibMTP = false;
|
||||
|
||||
MtpDevice::MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, manager, app, database_id, first_time, parent),
|
||||
MtpDevice::MtpDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent)
|
||||
: ConnectedDevice(url, lister, unique_id, device_manager, task_manager, database, tagreader_client, albumcover_loader, database_id, first_time, parent),
|
||||
task_manager_(task_manager),
|
||||
loader_(nullptr),
|
||||
loader_thread_(nullptr),
|
||||
closing_(false) {
|
||||
@@ -79,9 +92,9 @@ MtpDevice::~MtpDevice() {
|
||||
bool MtpDevice::Init() {
|
||||
|
||||
InitBackendDirectory(u"/"_s, first_time_, false);
|
||||
model_->Init();
|
||||
collection_model_->Init();
|
||||
|
||||
loader_ = new MtpLoader(url_, app_->task_manager(), backend_);
|
||||
loader_ = new MtpLoader(url_, task_manager_, collection_backend_);
|
||||
loader_thread_ = new QThread();
|
||||
loader_->moveToThread(loader_thread_);
|
||||
|
||||
@@ -132,7 +145,7 @@ void MtpDevice::LoadFinished(const bool success, MtpConnection *connection) {
|
||||
}
|
||||
|
||||
void MtpDevice::LoaderError(const QString &message) {
|
||||
app_->AddError(message);
|
||||
Q_EMIT Error(message);
|
||||
}
|
||||
|
||||
bool MtpDevice::StartCopy(QList<Song::FileType> *supported_types) {
|
||||
@@ -204,15 +217,15 @@ bool MtpDevice::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
bool MtpDevice::FinishCopy(const bool success, QString &error_text) {
|
||||
|
||||
if (success) {
|
||||
if (!songs_to_add_.isEmpty()) backend_->AddOrUpdateSongs(songs_to_add_);
|
||||
if (!songs_to_remove_.isEmpty()) backend_->DeleteSongs(songs_to_remove_);
|
||||
if (!songs_to_add_.isEmpty()) collection_backend_->AddOrUpdateSongs(songs_to_add_);
|
||||
if (!songs_to_remove_.isEmpty()) collection_backend_->DeleteSongs(songs_to_remove_);
|
||||
}
|
||||
|
||||
songs_to_add_.clear();
|
||||
songs_to_remove_.clear();
|
||||
|
||||
// This is done in the organize thread so close the unique DB connection.
|
||||
backend_->Close();
|
||||
collection_backend_->Close();
|
||||
|
||||
db_busy_.unlock();
|
||||
|
||||
|
||||
@@ -31,15 +31,18 @@
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "connecteddevice.h"
|
||||
|
||||
class QThread;
|
||||
class Application;
|
||||
class DeviceLister;
|
||||
class DeviceManager;
|
||||
class TaskManager;
|
||||
class Database;
|
||||
class TagReaderClient;
|
||||
class AlbumCoverLoader;
|
||||
class MtpLoader;
|
||||
class MtpConnection;
|
||||
struct LIBMTP_mtpdevice_struct;
|
||||
@@ -48,7 +51,18 @@ class MtpDevice : public ConnectedDevice {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Q_INVOKABLE MtpDevice(const QUrl &url, DeviceLister *lister, const QString &unique_id, SharedPtr<DeviceManager> manager, Application *app, const int database_id, const bool first_time, QObject *parent = nullptr);
|
||||
Q_INVOKABLE MtpDevice(const QUrl &url,
|
||||
DeviceLister *lister,
|
||||
const QString &unique_id,
|
||||
DeviceManager *device_manager,
|
||||
const SharedPtr<TaskManager> task_manager,
|
||||
const SharedPtr<Database> database,
|
||||
const SharedPtr<TagReaderClient> tagreader_client,
|
||||
const SharedPtr<AlbumCoverLoader> albumcover_loader,
|
||||
const int database_id,
|
||||
const bool first_time,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~MtpDevice() override;
|
||||
|
||||
static QStringList url_schemes() { return QStringList() << QStringLiteral("mtp"); }
|
||||
@@ -82,6 +96,8 @@ class MtpDevice : public ConnectedDevice {
|
||||
private:
|
||||
static bool sInitializedLibMTP;
|
||||
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
|
||||
MtpLoader *loader_;
|
||||
QThread *loader_thread_;
|
||||
bool closing_;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/song.h"
|
||||
#include "collection/collectionbackend.h"
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
MtpLoader::MtpLoader(const QUrl &url, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, QObject *parent)
|
||||
MtpLoader::MtpLoader(const QUrl &url, const SharedPtr<TaskManager> task_manager, const SharedPtr<CollectionBackend> backend, QObject *parent)
|
||||
: QObject(parent),
|
||||
url_(url),
|
||||
task_manager_(task_manager),
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include <QString>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
|
||||
class QThread;
|
||||
class TaskManager;
|
||||
@@ -40,7 +40,7 @@ class MtpLoader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MtpLoader(const QUrl &url, SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> backend, QObject *parent = nullptr);
|
||||
explicit MtpLoader(const QUrl &url, const SharedPtr<TaskManager> task_manager, const SharedPtr<CollectionBackend> backend, QObject *parent = nullptr);
|
||||
~MtpLoader() override;
|
||||
|
||||
bool Init();
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#include <QDBusArgument>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "utilities/diskutils.h"
|
||||
|
||||
#include "udisks2lister.h"
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/dbus_metatypes.h"
|
||||
#include "includes/scoped_ptr.h"
|
||||
#include "includes/shared_ptr.h"
|
||||
#include "includes/dbus_metatypes.h"
|
||||
|
||||
#include "devicelister.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user