2010-06-24 18:26:49 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-06-24 18:26:49 +02:00
|
|
|
|
|
|
|
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 ORGANISEDIALOG_H
|
|
|
|
#define ORGANISEDIALOG_H
|
|
|
|
|
2014-01-28 16:04:17 +01:00
|
|
|
#include <memory>
|
2014-02-06 14:48:00 +01:00
|
|
|
|
2010-06-24 18:26:49 +02:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QUrl>
|
|
|
|
|
2014-02-02 19:28:45 +01:00
|
|
|
#include "gtest/gtest_prod.h"
|
|
|
|
|
|
|
|
#include "core/organise.h"
|
2010-06-24 20:33:38 +02:00
|
|
|
#include "core/organiseformat.h"
|
2010-06-24 18:26:49 +02:00
|
|
|
#include "core/song.h"
|
|
|
|
|
2010-06-24 23:46:18 +02:00
|
|
|
class LibraryWatcher;
|
2010-09-04 22:11:14 +02:00
|
|
|
class OrganiseErrorDialog;
|
2010-06-24 20:33:38 +02:00
|
|
|
class TaskManager;
|
2010-06-24 18:26:49 +02:00
|
|
|
class Ui_OrganiseDialog;
|
|
|
|
|
2010-06-24 19:34:23 +02:00
|
|
|
class QAbstractItemModel;
|
|
|
|
|
2010-06-24 18:26:49 +02:00
|
|
|
class OrganiseDialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-11-05 02:37:44 +01:00
|
|
|
OrganiseDialog(TaskManager* task_manager, QWidget* parent = nullptr);
|
2010-06-24 18:26:49 +02:00
|
|
|
~OrganiseDialog();
|
|
|
|
|
|
|
|
static const char* kDefaultFormat;
|
2010-06-24 19:34:23 +02:00
|
|
|
static const char* kSettingsGroup;
|
2012-01-04 23:21:39 +01:00
|
|
|
|
2014-10-30 17:09:27 +01:00
|
|
|
QSize sizeHint() const;
|
|
|
|
|
2010-07-25 11:52:29 +02:00
|
|
|
void SetDestinationModel(QAbstractItemModel* model, bool devices = false);
|
2010-06-24 18:26:49 +02:00
|
|
|
|
2014-04-23 13:46:05 +02:00
|
|
|
// These functions return true if any songs were actually added to the dialog.
|
|
|
|
// SetSongs returns immediately, SetUrls and SetFilenames load the songs in
|
|
|
|
// the background.
|
|
|
|
bool SetSongs(const SongList& songs);
|
|
|
|
bool SetUrls(const QList<QUrl>& urls);
|
|
|
|
bool SetFilenames(const QStringList& filenames);
|
|
|
|
|
2010-06-24 22:26:17 +02:00
|
|
|
void SetCopy(bool copy);
|
2010-06-24 18:26:49 +02:00
|
|
|
|
2014-11-05 02:37:44 +01:00
|
|
|
signals:
|
|
|
|
void FileCopied(int);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public slots:
|
2010-06-24 19:34:23 +02:00
|
|
|
void accept();
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2012-01-04 23:29:26 +01:00
|
|
|
void showEvent(QShowEvent*);
|
|
|
|
void resizeEvent(QResizeEvent*);
|
2010-06-24 19:34:23 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private slots:
|
2010-06-24 19:34:23 +02:00
|
|
|
void Reset();
|
|
|
|
|
2010-06-24 18:26:49 +02:00
|
|
|
void InsertTag(const QString& tag);
|
|
|
|
void UpdatePreviews();
|
|
|
|
|
2010-08-14 13:51:50 +02:00
|
|
|
void OrganiseFinished(const QStringList& files_with_errors);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2014-04-23 13:46:05 +02:00
|
|
|
SongList LoadSongsBlocking(const QStringList& filenames);
|
|
|
|
void SetLoadingSongs(bool loading);
|
|
|
|
|
2014-02-02 19:28:45 +01:00
|
|
|
static Organise::NewSongInfoList ComputeNewSongsFilenames(
|
2014-02-07 16:34:20 +01:00
|
|
|
const SongList& songs, const OrganiseFormat& format);
|
2014-02-02 19:28:45 +01:00
|
|
|
|
2010-06-24 18:26:49 +02:00
|
|
|
Ui_OrganiseDialog* ui_;
|
2010-06-24 20:33:38 +02:00
|
|
|
TaskManager* task_manager_;
|
2010-06-24 18:26:49 +02:00
|
|
|
|
|
|
|
OrganiseFormat format_;
|
|
|
|
|
2014-04-23 13:46:05 +02:00
|
|
|
QFuture<SongList> songs_future_;
|
2014-01-20 17:25:12 +01:00
|
|
|
SongList songs_;
|
2014-02-02 19:28:45 +01:00
|
|
|
Organise::NewSongInfoList new_songs_info_;
|
2010-07-31 00:25:32 +02:00
|
|
|
quint64 total_size_;
|
2010-09-04 22:11:14 +02:00
|
|
|
|
2014-01-28 16:04:17 +01:00
|
|
|
std::unique_ptr<OrganiseErrorDialog> error_dialog_;
|
2012-01-04 23:29:26 +01:00
|
|
|
|
|
|
|
bool resized_by_user_;
|
2014-02-02 19:28:45 +01:00
|
|
|
|
|
|
|
FRIEND_TEST(OrganiseDialogTest, ComputeNewSongsFilenamesTest);
|
2010-06-24 18:26:49 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // ORGANISEDIALOG_H
|