2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry 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.
|
|
|
|
*
|
|
|
|
* Strawberry 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 Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:39:44 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-10-19 20:18:46 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QStyle>
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <QList>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QListWidget>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
#include "organizeerrordialog.h"
|
|
|
|
#include "ui_organizeerrordialog.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeErrorDialog::OrganizeErrorDialog(QWidget *parent) : QDialog(parent), ui_(new Ui_OrganizeErrorDialog) {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
ui_->setupUi(this);
|
|
|
|
|
2020-06-14 17:02:47 +02:00
|
|
|
const int icon_size = style()->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, this);
|
|
|
|
QIcon icon = style()->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, this);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
ui_->icon->setPixmap(icon.pixmap(icon_size));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-08-04 21:18:14 +02:00
|
|
|
OrganizeErrorDialog::~OrganizeErrorDialog() {
|
2018-02-27 18:06:05 +01:00
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
2023-02-18 14:09:27 +01:00
|
|
|
void OrganizeErrorDialog::Show(const OperationType operation_type, const SongList &songs_with_errors, const QStringList &log) {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QStringList files;
|
2021-06-20 19:04:08 +02:00
|
|
|
files.reserve(songs_with_errors.count());
|
2018-02-27 18:06:05 +01:00
|
|
|
for (const Song &song : songs_with_errors) {
|
|
|
|
files << song.url().toLocalFile();
|
|
|
|
}
|
2023-02-18 14:09:27 +01:00
|
|
|
Show(operation_type, files, log);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-18 14:09:27 +01:00
|
|
|
void OrganizeErrorDialog::Show(const OperationType operation_type, const QStringList &files_with_errors, const QStringList &log) {
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
QStringList sorted_files = files_with_errors;
|
2018-10-19 20:18:46 +02:00
|
|
|
std::stable_sort(sorted_files.begin(), sorted_files.end());
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2023-02-18 14:09:27 +01:00
|
|
|
switch (operation_type) {
|
|
|
|
case OperationType::Copy:
|
2018-02-27 18:06:05 +01:00
|
|
|
setWindowTitle(tr("Error copying songs"));
|
|
|
|
ui_->label->setText(tr("There were problems copying some songs. The following files could not be copied:"));
|
|
|
|
break;
|
|
|
|
|
2023-02-18 14:09:27 +01:00
|
|
|
case OperationType::Delete:
|
2018-02-27 18:06:05 +01:00
|
|
|
setWindowTitle(tr("Error deleting songs"));
|
|
|
|
ui_->label->setText(tr("There were problems deleting some songs. The following files could not be deleted:"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-24 19:20:10 +01:00
|
|
|
ui_->files->addItems(sorted_files);
|
|
|
|
ui_->log->addItems(log);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
show();
|
2023-02-18 14:09:27 +01:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|