From 87394c679846713062b3a50bdc26cbf4884eb85f Mon Sep 17 00:00:00 2001 From: Shinnok Date: Mon, 5 Jun 2017 15:35:55 +0300 Subject: [PATCH] Display list of files to be restored in restore dialog. Issue #129. --- forms/restoredialog.ui | 75 ++++++++++++++++++++++++------- src/widgets/archivelistwidget.cpp | 4 +- src/widgets/archivewidget.cpp | 3 +- src/widgets/joblistwidget.cpp | 4 +- src/widgets/jobwidget.cpp | 2 +- src/widgets/restoredialog.cpp | 17 ++++--- src/widgets/restoredialog.h | 4 +- 7 files changed, 77 insertions(+), 32 deletions(-) diff --git a/forms/restoredialog.ui b/forms/restoredialog.ui index 244664fd..3c6a59dd 100644 --- a/forms/restoredialog.ui +++ b/forms/restoredialog.ui @@ -7,35 +7,41 @@ 0 0 500 - 300 + 335 - 500 - 300 + 400 + 0 Archive restore + + true + true + + 6 + - 12 + 6 - 12 + 6 - 12 + 6 0 - + @@ -51,6 +57,41 @@ + + + + + 0 + 0 + + + + #filesListWidget +{ +font-family: Monospace, Monaco; +font-size: 12px; +} + +#filesListWidget::item +{ +height: 25px; +} + + + + QAbstractItemView::NoEditTriggers + + + true + + + QListView::Batched + + + true + + + @@ -158,16 +199,6 @@ - - - - Attempt to restore the full permissions, including owner, file modes, file flags and ACLs, if available, for each item extracted from the archive. - - - Preserve file permissions - - - @@ -185,6 +216,16 @@ + + + + Attempt to restore the full permissions, including owner, file modes, file flags and ACLs, if available, for each item extracted from the archive. + + + Preserve file permissions + + + diff --git a/src/widgets/archivelistwidget.cpp b/src/widgets/archivelistwidget.cpp index c9a6a3c9..db944f06 100644 --- a/src/widgets/archivelistwidget.cpp +++ b/src/widgets/archivelistwidget.cpp @@ -168,7 +168,7 @@ void ArchiveListWidget::restoreSelectedItem() static_cast(selectedItems().first()); if(archiveItem && !archiveItem->archive()->deleteScheduled()) { - RestoreDialog restoreDialog(archiveItem->archive(), this); + RestoreDialog restoreDialog(this, archiveItem->archive()); if(QDialog::Accepted == restoreDialog.exec()) emit restoreArchive(archiveItem->archive(), restoreDialog.getOptions()); @@ -257,7 +257,7 @@ void ArchiveListWidget::restoreItem() qobject_cast(sender()); if(archiveItem) { - RestoreDialog restoreDialog(archiveItem->archive(), this); + RestoreDialog restoreDialog(this, archiveItem->archive()); if(QDialog::Accepted == restoreDialog.exec()) emit restoreArchive(archiveItem->archive(), restoreDialog.getOptions()); diff --git a/src/widgets/archivewidget.cpp b/src/widgets/archivewidget.cpp index e269bc61..6a12719d 100644 --- a/src/widgets/archivewidget.cpp +++ b/src/widgets/archivewidget.cpp @@ -186,12 +186,11 @@ void ArchiveWidget::restoreFiles() foreach(QModelIndex index, indexes) files << index.data().toString(); - RestoreDialog restoreDialog(_archive, this); + RestoreDialog restoreDialog(this, _archive, files); restoreDialog.displayTarOption(false); if(QDialog::Accepted == restoreDialog.exec()) { ArchiveRestoreOptions options = restoreDialog.getOptions(); - options.files = files; emit restoreArchive(_archive, options); } } diff --git a/src/widgets/joblistwidget.cpp b/src/widgets/joblistwidget.cpp index 1a7e1ae1..66683cf0 100644 --- a/src/widgets/joblistwidget.cpp +++ b/src/widgets/joblistwidget.cpp @@ -111,7 +111,7 @@ void JobListWidget::restoreItem() if(!job->archives().isEmpty()) { ArchivePtr archive = job->archives().first(); - RestoreDialog restoreDialog(archive, this); + RestoreDialog restoreDialog(this, archive); if(QDialog::Accepted == restoreDialog.exec()) emit restoreArchive(archive, restoreDialog.getOptions()); } @@ -218,7 +218,7 @@ void JobListWidget::restoreSelectedItem() if(!job->archives().isEmpty()) { ArchivePtr archive = job->archives().first(); - RestoreDialog restoreDialog(archive, this); + RestoreDialog restoreDialog(this, archive); if(QDialog::Accepted == restoreDialog.exec()) emit restoreArchive(archive, restoreDialog.getOptions()); } diff --git a/src/widgets/jobwidget.cpp b/src/widgets/jobwidget.cpp index 6b42f589..2738bf82 100644 --- a/src/widgets/jobwidget.cpp +++ b/src/widgets/jobwidget.cpp @@ -249,7 +249,7 @@ void JobWidget::restoreButtonClicked() if(_job && !_job->archives().isEmpty()) { ArchivePtr archive = _job->archives().first(); - RestoreDialog restoreDialog(archive, this); + RestoreDialog restoreDialog(this, archive); if(QDialog::Accepted == restoreDialog.exec()) emit restoreJobArchive(archive, restoreDialog.getOptions()); } diff --git a/src/widgets/restoredialog.cpp b/src/widgets/restoredialog.cpp index d8237ab7..265b54f0 100644 --- a/src/widgets/restoredialog.cpp +++ b/src/widgets/restoredialog.cpp @@ -6,12 +6,10 @@ #include #include -RestoreDialog::RestoreDialog(ArchivePtr archive, QWidget *parent) - : QDialog(parent), _archive(archive) +RestoreDialog::RestoreDialog(QWidget *parent, ArchivePtr archive, QStringList files) + : QDialog(parent), _archive(archive), _files(files) { _ui.setupUi(this); - setWindowFlags((windowFlags() | Qt::CustomizeWindowHint) - & ~Qt::WindowMaximizeButtonHint); QSettings settings; _downDir = settings.value("app/downloads_dir", DEFAULT_DOWNLOADS).toString(); @@ -58,6 +56,10 @@ RestoreDialog::RestoreDialog(ArchivePtr archive, QWidget *parent) displayRestoreOption(canRestore); _ui.optionRestoreRadio->setChecked(canRestore); _ui.optionBaseDirRadio->setChecked(!canRestore); + if(!_files.isEmpty()) + _ui.filesListWidget->addItems(_files); + else + _ui.filesListWidget->addItems(_archive->contents().split(QChar('\n'))); } RestoreDialog::~RestoreDialog() @@ -73,6 +75,7 @@ ArchiveRestoreOptions RestoreDialog::getOptions() options.overwriteFiles = _ui.overwriteCheckBox->isChecked(); options.keepNewerFiles = _ui.keepNewerCheckBox->isChecked(); options.preservePerms = _ui.preservePermCheckBox->isChecked(); + options.files = _files; if(options.optionRestoreDir) options.path = _ui.baseDirLineEdit->text(); else if(options.optionTarArchive) @@ -94,7 +97,7 @@ void RestoreDialog::displayTarOption(bool display) void RestoreDialog::optionBaseDirToggled(bool checked) { - _ui.infoLabel->setText(tr("Restore archive %1 contents to specified" + _ui.infoLabel->setText(tr("Restore from archive %1 to specified" " directory? Any existing files will not be" " replaced by default. Use the options below to" " modify this behavior:") @@ -110,7 +113,7 @@ void RestoreDialog::optionBaseDirToggled(bool checked) void RestoreDialog::optionTarArchiveToggled(bool checked) { _ui.infoLabel->setText(tr("Download archive %1 contents as an" - " uncompressed TAR archive.") + " uncompressed TAR archive?") .arg(_archive->name())); _ui.archiveLineEdit->setVisible(checked); _ui.changeArchiveButton->setVisible(checked); @@ -119,7 +122,7 @@ void RestoreDialog::optionTarArchiveToggled(bool checked) void RestoreDialog::optionRestoreToggled(bool checked) { - _ui.infoLabel->setText(tr("Restore archive %1 contents to original" + _ui.infoLabel->setText(tr("Restore from archive %1 to original" " locations? Any existing files will not be" " replaced by default. Use the options below to" " modify this behavior:") diff --git a/src/widgets/restoredialog.h b/src/widgets/restoredialog.h index 614d2bc2..da974a4e 100644 --- a/src/widgets/restoredialog.h +++ b/src/widgets/restoredialog.h @@ -19,7 +19,8 @@ class RestoreDialog : public QDialog //! Constructor. //! \param archive: the ArchivePtr to restore. //! \param parent: standard Qt parameter. - explicit RestoreDialog(ArchivePtr archive, QWidget *parent = nullptr); + explicit RestoreDialog(QWidget *parent, ArchivePtr archive, + QStringList files = QStringList()); ~RestoreDialog(); //! Returns options from the dialog window. @@ -38,6 +39,7 @@ private slots: private: Ui::RestoreDialog _ui; ArchivePtr _archive; + QStringList _files; QString _downDir; void displayRestoreOption(bool display);