From e261fffa8d88e385a21cadb2f45b68e6c96b5d67 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Mon, 28 Sep 2020 20:30:19 +0200 Subject: Fix transfer saves for recursive saves. --- src/transfersavesdialog.cpp | 25 +++++++++++++++++-------- src/transfersavesdialog.h | 5 +++-- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index ea1861d5..f8ebbb9d 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -182,7 +182,9 @@ void TransferSavesDialog::on_moveToLocalBtn_clicked() { QString character = ui->globalCharacterList->currentItem()->text(); if (transferCharacters( - character, MOVE_SAVES TO_PROFILE, m_GlobalSaves[character], + character, MOVE_SAVES TO_PROFILE, + m_GamePlugin->savesDirectory(), + m_GlobalSaves[character], m_Profile.savePath(), [this](const QString &source, const QString &destination) -> bool { return shellMove(source, destination, this); @@ -199,7 +201,9 @@ void TransferSavesDialog::on_copyToLocalBtn_clicked() { QString character = ui->globalCharacterList->currentItem()->text(); if (transferCharacters( - character, COPY_SAVES TO_PROFILE, m_GlobalSaves[character], + character, COPY_SAVES TO_PROFILE, + m_GamePlugin->savesDirectory(), + m_GlobalSaves[character], m_Profile.savePath(), [this](const QString &source, const QString &destination) -> bool { return shellCopy(source, destination, this); @@ -214,7 +218,9 @@ void TransferSavesDialog::on_moveToGlobalBtn_clicked() { QString character = ui->localCharacterList->currentItem()->text(); if (transferCharacters( - character, MOVE_SAVES TO_GLOBAL, m_LocalSaves[character], + character, MOVE_SAVES TO_GLOBAL, + m_Profile.savePath(), + m_LocalSaves[character], m_GamePlugin->savesDirectory().absolutePath(), [this](const QString &source, const QString &destination) -> bool { return shellMove(source, destination, this); @@ -231,7 +237,9 @@ void TransferSavesDialog::on_copyToGlobalBtn_clicked() { QString character = ui->localCharacterList->currentItem()->text(); if (transferCharacters( - character, COPY_SAVES TO_GLOBAL, m_LocalSaves[character], + character, COPY_SAVES TO_GLOBAL, + m_Profile.savePath(), + m_LocalSaves[character], m_GamePlugin->savesDirectory().absolutePath(), [this](const QString &source, const QString &destination) -> bool { return shellCopy(source, destination, this); @@ -326,8 +334,10 @@ void TransferSavesDialog::refreshCharacters(const SaveCollection &saveCollection } bool TransferSavesDialog::transferCharacters( - QString const &character, char const *message, SaveList &saves, - QString const &dest, + QString const &character, char const *message, + QDir const& sourceDirectory, + SaveList &saves, + QDir const& destination, const std::function &method, char const *errmsg) { @@ -339,11 +349,10 @@ bool TransferSavesDialog::transferCharacters( OverwriteMode overwriteMode = OVERWRITE_ASK; - QDir destination(dest); for (SaveListItem const &save : saves) { for (QString source : save->allFiles()) { QFileInfo sourceFile(source); - QString destinationFile(destination.absoluteFilePath(sourceFile.fileName())); + QString destinationFile(destination.absoluteFilePath(sourceDirectory.relativeFilePath(source))); //If the file is already there, let them skip (or not). if (QFile::exists(destinationFile)) { diff --git a/src/transfersavesdialog.h b/src/transfersavesdialog.h index dee41c72..b983ad9e 100644 --- a/src/transfersavesdialog.h +++ b/src/transfersavesdialog.h @@ -92,8 +92,9 @@ private: QPushButton *move); bool transferCharacters( - QString const &character, char const *message, SaveList &saves, - QString const &dest, + QString const &character, char const *message, + QDir const& sourceDirectory, SaveList &saves, + QDir const& dest, const std::function &method, char const *errmsg); }; -- cgit v1.3.1