2010-08-14 13:51:50 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-08-14 13:51:50 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "organiseerrordialog.h"
|
|
|
|
#include "ui_organiseerrordialog.h"
|
|
|
|
|
2018-10-05 17:19:05 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2011-11-28 14:51:35 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
OrganiseErrorDialog::OrganiseErrorDialog(QWidget* parent)
|
|
|
|
: QDialog(parent), ui_(new Ui_OrganiseErrorDialog) {
|
2010-08-14 13:51:50 +02:00
|
|
|
ui_->setupUi(this);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
const int icon_size =
|
|
|
|
style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this);
|
2010-08-14 13:51:50 +02:00
|
|
|
QIcon icon = style()->standardIcon(QStyle::SP_MessageBoxCritical, 0, this);
|
|
|
|
|
|
|
|
ui_->icon->setPixmap(icon.pixmap(icon_size));
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
OrganiseErrorDialog::~OrganiseErrorDialog() { delete ui_; }
|
2010-08-14 13:51:50 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void OrganiseErrorDialog::Show(OperationType type,
|
|
|
|
const SongList& songs_with_errors) {
|
2010-08-14 13:51:50 +02:00
|
|
|
QStringList files;
|
2014-02-10 14:29:07 +01:00
|
|
|
for (const Song& song : songs_with_errors) {
|
2011-04-28 14:27:53 +02:00
|
|
|
files << song.url().toLocalFile();
|
2010-08-14 13:51:50 +02:00
|
|
|
}
|
|
|
|
Show(type, files);
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void OrganiseErrorDialog::Show(OperationType type,
|
|
|
|
const QStringList& files_with_errors) {
|
2010-08-14 13:51:50 +02:00
|
|
|
QStringList sorted_files = files_with_errors;
|
2018-10-05 17:19:05 +02:00
|
|
|
std::stable_sort(sorted_files.begin(), sorted_files.end());
|
2010-08-14 13:51:50 +02:00
|
|
|
|
|
|
|
switch (type) {
|
2014-02-07 16:34:20 +01:00
|
|
|
case Type_Copy:
|
|
|
|
setWindowTitle(tr("Error copying songs"));
|
|
|
|
ui_->label->setText(
|
|
|
|
tr("There were problems copying some songs. The following files "
|
|
|
|
"could not be copied:"));
|
|
|
|
break;
|
2010-08-14 13:51:50 +02:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
case Type_Delete:
|
|
|
|
setWindowTitle(tr("Error deleting songs"));
|
|
|
|
ui_->label->setText(
|
|
|
|
tr("There were problems deleting some songs. The following files "
|
|
|
|
"could not be deleted:"));
|
|
|
|
break;
|
2010-08-14 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ui_->list->addItems(sorted_files);
|
|
|
|
|
|
|
|
show();
|
|
|
|
}
|