diff --git a/mainwindow.cpp b/mainwindow.cpp index a65ff39..09750c9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -407,6 +407,9 @@ void MainWindow::copyOrMove(bool copy, const QString &dest) if(!dest.isEmpty() && dir.exists()) { int i = 0; + int missing = 0; + bool overwriteAll = false; + bool skipAll = false; QStringList files = m_database->getMarkedFiles(); QProgressDialog progress(copy ? tr("Copying") : tr("Moving"), tr("Cancel"), 0, files.size(), this); progress.setWindowModality(Qt::WindowModal); @@ -418,8 +421,42 @@ void MainWindow::copyOrMove(bool copy, const QString &dest) QFile srcFile(file); QFile dstFile(dir.absoluteFilePath(info.fileName())); - if(dstFile.exists()) + if(!srcFile.exists()) + { + missing++; continue; + } + + if(dstFile.exists()) + { + if(skipAll) + { + continue; + } + else if(overwriteAll) + { + dstFile.remove(); + } + else + { + QMessageBox::StandardButton button = QMessageBox::question(this, tr("Overwrite file?"), tr("Destination file %1 already exists. Overwrite?").arg(dstFile.fileName()), + QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll); + switch (button) + { + case QMessageBox::YesToAll: + overwriteAll = true; + case QMessageBox::Yes: + dstFile.remove(); + break; + case QMessageBox::NoToAll: + skipAll = true; + case QMessageBox::No: + continue; + default: + break; + } + } + } if(progress.wasCanceled()) return; @@ -458,6 +495,8 @@ void MainWindow::copyOrMove(bool copy, const QString &dest) progress.setValue(i++); } m_database->clearMarkedFiles(); + if(missing) + QMessageBox::information(this, tr("Missing marked files"), tr("%1 marked files were missing. They were skipped.").arg(missing)); } }