@@ -35,6 +35,7 @@
|
||||
#include <QImage>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
@@ -54,7 +55,7 @@ const int Organize::kBatchSize = 10;
|
||||
const int Organize::kTranscodeProgressInterval = 500;
|
||||
#endif
|
||||
|
||||
Organize::Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs_info, const bool eject_after, const QString &playlist, QObject *parent)
|
||||
Organize::Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs_info, const bool eject_after, const QString &playlist, QObject *parent)
|
||||
: QObject(parent),
|
||||
thread_(nullptr),
|
||||
task_manager_(task_manager),
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include <QObject>
|
||||
@@ -37,6 +36,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "organizeformat.h"
|
||||
|
||||
@@ -63,7 +63,7 @@ class Organize : public QObject {
|
||||
};
|
||||
using NewSongInfoList = QList<NewSongInfo>;
|
||||
|
||||
explicit Organize(TaskManager *task_manager, std::shared_ptr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs, const bool eject_after, const QString &playlist = QString(), QObject *parent = nullptr);
|
||||
explicit Organize(SharedPtr<TaskManager> task_manager, SharedPtr<MusicStorage> destination, const OrganizeFormat &format, const bool copy, const bool overwrite, const bool albumcover, const NewSongInfoList &songs, const bool eject_after, const QString &playlist = QString(), QObject *parent = nullptr);
|
||||
~Organize() override;
|
||||
|
||||
static const int kBatchSize;
|
||||
@@ -108,12 +108,12 @@ class Organize : public QObject {
|
||||
|
||||
QThread *thread_;
|
||||
QThread *original_thread_;
|
||||
TaskManager *task_manager_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
#ifdef HAVE_GSTREAMER
|
||||
Transcoder *transcoder_;
|
||||
#endif
|
||||
QTimer *process_files_timer_;
|
||||
std::shared_ptr<MusicStorage> destination_;
|
||||
SharedPtr<MusicStorage> destination_;
|
||||
QList<Song::FileType> supported_filetypes_;
|
||||
|
||||
const OrganizeFormat format_;
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QGuiApplication>
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/iconloader.h"
|
||||
#include "core/musicstorage.h"
|
||||
#include "core/tagreaderclient.h"
|
||||
@@ -72,15 +73,17 @@
|
||||
# include "transcoder/transcoder.h"
|
||||
#endif
|
||||
|
||||
using std::make_unique;
|
||||
|
||||
constexpr char OrganizeDialog::kSettingsGroup[] = "OrganizeDialog";
|
||||
constexpr char OrganizeDialog::kDefaultFormat[] = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension";
|
||||
|
||||
OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend, QWidget *parentwindow, QWidget *parent)
|
||||
OrganizeDialog::OrganizeDialog(SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> collection_backend, QWidget *parentwindow, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
parentwindow_(parentwindow),
|
||||
ui_(new Ui_OrganizeDialog),
|
||||
task_manager_(task_manager),
|
||||
backend_(backend),
|
||||
collection_backend_(collection_backend),
|
||||
total_size_(0),
|
||||
devices_(false) {
|
||||
|
||||
@@ -179,7 +182,7 @@ void OrganizeDialog::accept() {
|
||||
SaveSettings();
|
||||
|
||||
const QModelIndex destination = ui_->destination->model()->index(ui_->destination->currentIndex(), 0);
|
||||
std::shared_ptr<MusicStorage> storage = destination.data(MusicStorage::Role_StorageForceConnect).value<std::shared_ptr<MusicStorage>>();
|
||||
SharedPtr<MusicStorage> storage = destination.data(MusicStorage::Role_StorageForceConnect).value<SharedPtr<MusicStorage>>();
|
||||
|
||||
if (!storage) return;
|
||||
|
||||
@@ -188,8 +191,8 @@ void OrganizeDialog::accept() {
|
||||
Organize *organize = new Organize(task_manager_, storage, format_, copy, ui_->overwrite->isChecked(), ui_->albumcover->isChecked(), new_songs_info_, ui_->eject_after->isChecked(), playlist_);
|
||||
QObject::connect(organize, &Organize::Finished, this, &OrganizeDialog::OrganizeFinished);
|
||||
QObject::connect(organize, &Organize::FileCopied, this, &OrganizeDialog::FileCopied);
|
||||
if (backend_) {
|
||||
QObject::connect(organize, &Organize::SongPathChanged, backend_, &CollectionBackend::SongPathChanged);
|
||||
if (collection_backend_) {
|
||||
QObject::connect(organize, &Organize::SongPathChanged, &*collection_backend_, &CollectionBackend::SongPathChanged);
|
||||
}
|
||||
|
||||
organize->Start();
|
||||
@@ -468,11 +471,11 @@ void OrganizeDialog::UpdatePreviews() {
|
||||
}
|
||||
|
||||
const QModelIndex destination = ui_->destination->model()->index(ui_->destination->currentIndex(), 0);
|
||||
std::shared_ptr<MusicStorage> storage;
|
||||
SharedPtr<MusicStorage> storage;
|
||||
bool has_local_destination = false;
|
||||
|
||||
if (destination.isValid()) {
|
||||
storage = destination.data(MusicStorage::Role_Storage).value<std::shared_ptr<MusicStorage>>();
|
||||
storage = destination.data(MusicStorage::Role_Storage).value<SharedPtr<MusicStorage>>();
|
||||
if (storage) {
|
||||
has_local_destination = !storage->LocalPath().isEmpty();
|
||||
}
|
||||
@@ -550,7 +553,7 @@ void OrganizeDialog::OrganizeFinished(const QStringList &files_with_errors, cons
|
||||
|
||||
if (files_with_errors.isEmpty()) return;
|
||||
|
||||
error_dialog_ = std::make_unique<OrganizeErrorDialog>();
|
||||
error_dialog_ = make_unique<OrganizeErrorDialog>();
|
||||
error_dialog_->Show(OrganizeErrorDialog::OperationType::Copy, files_with_errors, log);
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
@@ -37,6 +35,8 @@
|
||||
#include <QUrl>
|
||||
#include <QtEvents>
|
||||
|
||||
#include "core/scoped_ptr.h"
|
||||
#include "core/shared_ptr.h"
|
||||
#include "core/song.h"
|
||||
#include "organize.h"
|
||||
#include "organizeformat.h"
|
||||
@@ -56,7 +56,7 @@ class OrganizeDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend = nullptr, QWidget *parentwindow = nullptr, QWidget *parent = nullptr);
|
||||
explicit OrganizeDialog(SharedPtr<TaskManager> task_manager, SharedPtr<CollectionBackend> collection_backend = nullptr, QWidget *parentwindow = nullptr, QWidget *parent = nullptr);
|
||||
~OrganizeDialog() override;
|
||||
|
||||
void SetDestinationModel(QAbstractItemModel *model, const bool devices = false);
|
||||
@@ -110,8 +110,8 @@ class OrganizeDialog : public QDialog {
|
||||
|
||||
QWidget *parentwindow_;
|
||||
Ui_OrganizeDialog *ui_;
|
||||
TaskManager *task_manager_;
|
||||
CollectionBackend *backend_;
|
||||
SharedPtr<TaskManager> task_manager_;
|
||||
SharedPtr<CollectionBackend> collection_backend_;
|
||||
|
||||
OrganizeFormat format_;
|
||||
|
||||
@@ -121,7 +121,7 @@ class OrganizeDialog : public QDialog {
|
||||
quint64 total_size_;
|
||||
QString playlist_;
|
||||
|
||||
std::unique_ptr<OrganizeErrorDialog> error_dialog_;
|
||||
ScopedPtr<OrganizeErrorDialog> error_dialog_;
|
||||
|
||||
bool devices_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user