Move OrganiseFormat to core/ and add an Organise class that actually does the work.
This commit is contained in:
parent
e680c441c1
commit
0848f62c3d
|
@ -40,6 +40,8 @@ set(SOURCES
|
||||||
core/gnomeglobalshortcutbackend.cpp
|
core/gnomeglobalshortcutbackend.cpp
|
||||||
core/mergedproxymodel.cpp
|
core/mergedproxymodel.cpp
|
||||||
core/networkaccessmanager.cpp
|
core/networkaccessmanager.cpp
|
||||||
|
core/organise.cpp
|
||||||
|
core/organiseformat.cpp
|
||||||
core/player.cpp
|
core/player.cpp
|
||||||
core/qxtglobalshortcutbackend.cpp
|
core/qxtglobalshortcutbackend.cpp
|
||||||
core/scopedtransaction.cpp
|
core/scopedtransaction.cpp
|
||||||
|
@ -120,7 +122,6 @@ set(SOURCES
|
||||||
ui/iconloader.cpp
|
ui/iconloader.cpp
|
||||||
ui/mainwindow.cpp
|
ui/mainwindow.cpp
|
||||||
ui/organisedialog.cpp
|
ui/organisedialog.cpp
|
||||||
ui/organiseformat.cpp
|
|
||||||
ui/qtsystemtrayicon.cpp
|
ui/qtsystemtrayicon.cpp
|
||||||
ui/settingsdialog.cpp
|
ui/settingsdialog.cpp
|
||||||
ui/systemtrayicon.cpp
|
ui/systemtrayicon.cpp
|
||||||
|
@ -162,6 +163,7 @@ set(HEADERS
|
||||||
core/gnomeglobalshortcutbackend.h
|
core/gnomeglobalshortcutbackend.h
|
||||||
core/mergedproxymodel.h
|
core/mergedproxymodel.h
|
||||||
core/networkaccessmanager.h
|
core/networkaccessmanager.h
|
||||||
|
core/organise.h
|
||||||
core/player.h
|
core/player.h
|
||||||
core/songloader.h
|
core/songloader.h
|
||||||
core/taskmanager.h
|
core/taskmanager.h
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
/* This file is part of Clementine.
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "organise.h"
|
||||||
|
#include "taskmanager.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
|
const int Organise::kBatchSize = 10;
|
||||||
|
|
||||||
|
Organise::Organise(TaskManager* task_manager, const QString &destination,
|
||||||
|
const OrganiseFormat &format, bool copy, bool overwrite,
|
||||||
|
const QStringList &files)
|
||||||
|
: thread_(NULL),
|
||||||
|
task_manager_(task_manager),
|
||||||
|
destination_(destination),
|
||||||
|
format_(format),
|
||||||
|
copy_(copy),
|
||||||
|
overwrite_(overwrite),
|
||||||
|
files_(files),
|
||||||
|
task_id_(0),
|
||||||
|
progress_(0)
|
||||||
|
{
|
||||||
|
original_thread_ = thread();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Organise::Start() {
|
||||||
|
if (thread_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
task_id_ = task_manager_->StartTask(tr("Organising files"));
|
||||||
|
task_manager_->SetTaskProgress(task_id_, progress_, files_.count());
|
||||||
|
|
||||||
|
thread_ = new QThread;
|
||||||
|
connect(thread_, SIGNAL(started()), SLOT(ProcessSomeFiles()));
|
||||||
|
connect(thread_, SIGNAL(destroyed()), SLOT(deleteLater()));
|
||||||
|
|
||||||
|
moveToThread(thread_);
|
||||||
|
thread_->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Organise::ProcessSomeFiles() {
|
||||||
|
// None left?
|
||||||
|
if (progress_ >= files_.count()) {
|
||||||
|
task_manager_->SetTaskFinished(task_id_);
|
||||||
|
|
||||||
|
// Move back to the original thread so deleteLater() can get called in
|
||||||
|
// the main thread's event loop
|
||||||
|
moveToThread(original_thread_);
|
||||||
|
deleteLater();
|
||||||
|
|
||||||
|
// Stop this thread
|
||||||
|
thread_->quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
|
||||||
|
// We process files in batches so we can be cancelled part-way through.
|
||||||
|
|
||||||
|
const int n = qMin(files_.count(), progress_ + kBatchSize);
|
||||||
|
for ( ; progress_<n ; ++progress_) {
|
||||||
|
task_manager_->SetTaskProgress(task_id_, progress_ + 1);
|
||||||
|
|
||||||
|
// Read metadata from the file
|
||||||
|
QString filename = files_[progress_];
|
||||||
|
Song song;
|
||||||
|
song.InitFromFile(filename, -1);
|
||||||
|
if (!song.is_valid())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Get the destination filename
|
||||||
|
QString dest_filename = destination_ + "/" + format_.GetFilenameForSong(song);
|
||||||
|
|
||||||
|
// Don't do anything if it's the destination is the same as the source
|
||||||
|
if (filename == dest_filename)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Create directories as required
|
||||||
|
dir.mkpath(dest_filename.section('/', 0, -2));
|
||||||
|
|
||||||
|
// Remove the destination file if it exists and we want to overwrite
|
||||||
|
if (overwrite_ && QFile::exists(dest_filename))
|
||||||
|
QFile::remove(dest_filename);
|
||||||
|
|
||||||
|
// Copy or move
|
||||||
|
if (copy_)
|
||||||
|
QFile::copy(filename, dest_filename);
|
||||||
|
else
|
||||||
|
QFile::rename(filename, dest_filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTimer::singleShot(0, this, SLOT(ProcessSomeFiles()));
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/* This file is part of Clementine.
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ORGANISE_H
|
||||||
|
#define ORGANISE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "organiseformat.h"
|
||||||
|
|
||||||
|
class TaskManager;
|
||||||
|
|
||||||
|
class Organise : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Organise(TaskManager* task_manager, const QString& destination,
|
||||||
|
const OrganiseFormat& format, bool copy, bool overwrite,
|
||||||
|
const QStringList& files);
|
||||||
|
|
||||||
|
static const int kBatchSize;
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ProcessSomeFiles();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QThread* thread_;
|
||||||
|
QThread* original_thread_;
|
||||||
|
TaskManager* task_manager_;
|
||||||
|
|
||||||
|
QString destination_;
|
||||||
|
OrganiseFormat format_;
|
||||||
|
bool copy_;
|
||||||
|
bool overwrite_;
|
||||||
|
QStringList files_;
|
||||||
|
|
||||||
|
int task_id_;
|
||||||
|
int progress_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ORGANISE_H
|
|
@ -35,6 +35,11 @@ OrganiseFormat::OrganiseFormat(const QString &format)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OrganiseFormat::set_format(const QString &v) {
|
||||||
|
format_ = v;
|
||||||
|
format_.replace('\\', '/');
|
||||||
|
}
|
||||||
|
|
||||||
bool OrganiseFormat::IsValid() const {
|
bool OrganiseFormat::IsValid() const {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
QString format_copy(format_);
|
QString format_copy(format_);
|
||||||
|
@ -211,5 +216,3 @@ void OrganiseFormat::SyntaxHighlighter::highlightBlock(const QString& text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public:
|
||||||
bool replace_spaces() const { return replace_spaces_; }
|
bool replace_spaces() const { return replace_spaces_; }
|
||||||
bool replace_the() const { return replace_the_; }
|
bool replace_the() const { return replace_the_; }
|
||||||
|
|
||||||
void set_format(const QString& v) { format_ = v; }
|
void set_format(const QString& v);
|
||||||
void set_replace_non_ascii(bool v) { replace_non_ascii_ = v; }
|
void set_replace_non_ascii(bool v) { replace_non_ascii_ = v; }
|
||||||
void set_replace_spaces(bool v) { replace_spaces_ = v; }
|
void set_replace_spaces(bool v) { replace_spaces_ = v; }
|
||||||
void set_replace_the(bool v) { replace_the_ = v; }
|
void set_replace_the(bool v) { replace_the_ = v; }
|
|
@ -40,7 +40,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Thread-safe
|
// Thread-safe
|
||||||
void SetTaskProgress(int id, int progress, int max = -1);
|
void SetTaskProgress(int id, int progress, int max = 0);
|
||||||
void SetTaskFinished(int id);
|
void SetTaskFinished(int id);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -978,6 +978,9 @@ msgstr "خيارات"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "خيارات اخرى"
|
msgstr "خيارات اخرى"
|
||||||
|
|
||||||
|
|
|
@ -982,6 +982,9 @@ msgstr "Možnosti"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Jiné možnosti"
|
msgstr "Jiné možnosti"
|
||||||
|
|
||||||
|
|
|
@ -983,6 +983,9 @@ msgstr "Indstillinger"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Andre valgmuligheder"
|
msgstr "Andre valgmuligheder"
|
||||||
|
|
||||||
|
|
|
@ -986,6 +986,9 @@ msgstr "Einstellungen"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Weitere Optionen"
|
msgstr "Weitere Optionen"
|
||||||
|
|
||||||
|
|
|
@ -987,6 +987,9 @@ msgstr "Επιλογές"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Άλλες επιλογές"
|
msgstr "Άλλες επιλογές"
|
||||||
|
|
||||||
|
|
|
@ -983,6 +983,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Other options"
|
msgstr "Other options"
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ msgstr "Options"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Other options"
|
msgstr "Other options"
|
||||||
|
|
||||||
|
|
|
@ -991,6 +991,9 @@ msgstr "Opciones"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Otras opciones"
|
msgstr "Otras opciones"
|
||||||
|
|
||||||
|
|
|
@ -978,6 +978,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -986,6 +986,9 @@ msgstr "Options"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Autres options"
|
msgstr "Autres options"
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -989,6 +989,9 @@ msgstr "Opzioni"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Altre opzioni"
|
msgstr "Altre opzioni"
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -981,6 +981,9 @@ msgstr "Instillinger"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -978,6 +978,9 @@ msgstr "Opcions"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Autras opcions"
|
msgstr "Autras opcions"
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ msgstr "Opcje"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Inne opcje"
|
msgstr "Inne opcje"
|
||||||
|
|
||||||
|
|
|
@ -985,6 +985,9 @@ msgstr "Opções"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Outras opções"
|
msgstr "Outras opções"
|
||||||
|
|
||||||
|
|
|
@ -987,6 +987,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Outras opções"
|
msgstr "Outras opções"
|
||||||
|
|
||||||
|
|
|
@ -979,6 +979,9 @@ msgstr "Opțiuni"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Alte opțiuni"
|
msgstr "Alte opțiuni"
|
||||||
|
|
||||||
|
|
|
@ -984,6 +984,9 @@ msgstr "Настройки"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Другие настройки"
|
msgstr "Другие настройки"
|
||||||
|
|
||||||
|
|
|
@ -985,6 +985,9 @@ msgstr "Možnosti"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Ostatné možnosti"
|
msgstr "Ostatné možnosti"
|
||||||
|
|
||||||
|
|
|
@ -983,6 +983,9 @@ msgstr "Flaggor"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Övriga flaggor"
|
msgstr "Övriga flaggor"
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ msgstr "Seçenekler"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Diğer Seçenekler"
|
msgstr "Diğer Seçenekler"
|
||||||
|
|
||||||
|
|
|
@ -969,6 +969,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -985,6 +985,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "Інші параметри"
|
msgstr "Інші параметри"
|
||||||
|
|
||||||
|
|
|
@ -978,6 +978,9 @@ msgstr "选项"
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr "其它选项"
|
msgstr "其它选项"
|
||||||
|
|
||||||
|
|
|
@ -978,6 +978,9 @@ msgstr ""
|
||||||
msgid "Organise Files"
|
msgid "Organise Files"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Organising files"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Other options"
|
msgid "Other options"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg
|
||||||
equalizer_(new Equalizer),
|
equalizer_(new Equalizer),
|
||||||
transcode_dialog_(new TranscodeDialog),
|
transcode_dialog_(new TranscodeDialog),
|
||||||
error_dialog_(new ErrorDialog),
|
error_dialog_(new ErrorDialog),
|
||||||
organise_dialog_(new OrganiseDialog),
|
organise_dialog_(new OrganiseDialog(task_manager_)),
|
||||||
#ifdef ENABLE_VISUALISATIONS
|
#ifdef ENABLE_VISUALISATIONS
|
||||||
visualisation_(new VisualisationContainer),
|
visualisation_(new VisualisationContainer),
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "organisedialog.h"
|
#include "organisedialog.h"
|
||||||
#include "ui_organisedialog.h"
|
#include "ui_organisedialog.h"
|
||||||
|
#include "core/organise.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
@ -28,9 +29,10 @@ const char* OrganiseDialog::kDefaultFormat =
|
||||||
"%artist/%album{ (Disc %disc)}/{%track - }%title.%extension";
|
"%artist/%album{ (Disc %disc)}/{%track - }%title.%extension";
|
||||||
const char* OrganiseDialog::kSettingsGroup = "OrganiseDialog";
|
const char* OrganiseDialog::kSettingsGroup = "OrganiseDialog";
|
||||||
|
|
||||||
OrganiseDialog::OrganiseDialog(QWidget *parent)
|
OrganiseDialog::OrganiseDialog(TaskManager* task_manager, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
ui_(new Ui_OrganiseDialog)
|
ui_(new Ui_OrganiseDialog),
|
||||||
|
task_manager_(task_manager)
|
||||||
{
|
{
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
connect(ui_->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(Reset()));
|
connect(ui_->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(Reset()));
|
||||||
|
@ -164,5 +166,11 @@ void OrganiseDialog::accept() {
|
||||||
s.setValue("replace_the", ui_->replace_the->isChecked());
|
s.setValue("replace_the", ui_->replace_the->isChecked());
|
||||||
s.setValue("overwrite", ui_->overwrite->isChecked());
|
s.setValue("overwrite", ui_->overwrite->isChecked());
|
||||||
|
|
||||||
|
// It deletes itself when it's finished.
|
||||||
|
Organise* organise = new Organise(
|
||||||
|
task_manager_, ui_->destination->currentText(), format_, true,
|
||||||
|
ui_->overwrite->isChecked(), filenames_);
|
||||||
|
organise->Start();
|
||||||
|
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,10 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include "organiseformat.h"
|
#include "core/organiseformat.h"
|
||||||
#include "core/song.h"
|
#include "core/song.h"
|
||||||
|
|
||||||
|
class TaskManager;
|
||||||
class Ui_OrganiseDialog;
|
class Ui_OrganiseDialog;
|
||||||
|
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
@ -32,7 +33,7 @@ class OrganiseDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OrganiseDialog(QWidget* parent = 0);
|
OrganiseDialog(TaskManager* task_manager, QWidget* parent = 0);
|
||||||
~OrganiseDialog();
|
~OrganiseDialog();
|
||||||
|
|
||||||
static const int kNumberOfPreviews;
|
static const int kNumberOfPreviews;
|
||||||
|
@ -60,6 +61,7 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_OrganiseDialog* ui_;
|
Ui_OrganiseDialog* ui_;
|
||||||
|
TaskManager* task_manager_;
|
||||||
|
|
||||||
OrganiseFormat format_;
|
OrganiseFormat format_;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "test_utils.h"
|
#include "test_utils.h"
|
||||||
|
|
||||||
#include "ui/organiseformat.h"
|
#include "core/organiseformat.h"
|
||||||
|
|
||||||
class OrganiseFormatTest : public ::testing::Test {
|
class OrganiseFormatTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue