summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e8d956a)
When overwriting directory with another directory, 'No' would mean to
skip it altogether. But it should mean only not to overwrite the files
inside, but move those that are not there. Thats how it works now, and
there is a 'Skip' button that will skip the directory altogether.
Signed-off-by: Lukas Hrazky <lukkash@email.cz>
QAbstractButton *noToAllButton = msgBox.addButton(QMessageBox::NoToAll);
QAbstractButton *abortButton = msgBox.addButton(tr("Abort"), QMessageBox::DestructiveRole);
QAbstractButton *askButton = 0;
QAbstractButton *noToAllButton = msgBox.addButton(QMessageBox::NoToAll);
QAbstractButton *abortButton = msgBox.addButton(tr("Abort"), QMessageBox::DestructiveRole);
QAbstractButton *askButton = 0;
+ QAbstractButton *skipDirButton = 0;
if (dirOverDir) {
msgBox.setText(tr("Directory %1 already exists. Overwrite the files inside?")
.arg(FileOperator::shortenPath(fileName)));
askButton = msgBox.addButton(tr("Ask"), QMessageBox::AcceptRole);
if (dirOverDir) {
msgBox.setText(tr("Directory %1 already exists. Overwrite the files inside?")
.arg(FileOperator::shortenPath(fileName)));
askButton = msgBox.addButton(tr("Ask"), QMessageBox::AcceptRole);
+ skipDirButton = msgBox.addButton(tr("Skip"), QMessageBox::NoRole);
} else {
msgBox.setText(tr("File %1 already exists. Overwrite?").arg(FileOperator::shortenPath(fileName)));
}
} else {
msgBox.setText(tr("File %1 already exists. Overwrite?").arg(FileOperator::shortenPath(fileName)));
}
manipulator->setResponse(KEEP, true);
} else if (msgBox.clickedButton() == askButton) {
manipulator->setResponse(NONE, true);
manipulator->setResponse(KEEP, true);
} else if (msgBox.clickedButton() == askButton) {
manipulator->setResponse(NONE, true);
+ } else if (msgBox.clickedButton() == skipDirButton) {
+ manipulator->setResponse(SKIP_DIR);
- if (response == FileOperator::KEEP) {
- updateProgress(fileSizeMap[path]);
- removeExcludeFiles.insert(path);
- return;
- }
-
+ // save the overwrite response, because the response variable will get ovewritten in remove(...)
FileOperator::Response overwriteResponse = response;
if (newFile.exists() && !newFile.isDir()) {
FileOperator::Response overwriteResponse = response;
if (newFile.exists() && !newFile.isDir()) {
+ // overwriting a file, so check for KEEP and handle it
+ if (response == FileOperator::KEEP) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
+
+ // if it should not be kept, remove it and return on failure
if(!remove(newPath)) {
updateProgress(fileSizeMap[path]);
return;
}
if(!remove(newPath)) {
updateProgress(fileSizeMap[path]);
return;
}
+ // create new info since we deleted the file - is it needed?
newFile = QFileInfo(newPath);
newFile = QFileInfo(newPath);
+ } else {
+ // overwriting a directory - response KEEP means to keep the files inside,
+ // SKIP_DIR means to skip the dir completely
+ if (response == FileOperator::SKIP_DIR) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
}
if (!newFile.exists()) {
}
if (!newFile.exists()) {
tr("Error creating directory %1."), newPath)
}
tr("Error creating directory %1."), newPath)
}
+ // we've done the job with the dir, so update progress and recurse into the dir
+ // change the dest for the recursion
QDir destBackup = dest;
dest = newPath;
QDir destBackup = dest;
dest = newPath;
+ // and set overwriteAll to the response we got a while ago
+ // because it applies to the files inside the dir
FileOperator::Response tmpResp = overwriteAll;
overwriteAll = overwriteResponse;
FileOperator::Response tmpResp = overwriteAll;
overwriteAll = overwriteResponse;
dest = destBackup;
} else {
dest = destBackup;
} else {
+ if (response == FileOperator::KEEP) {
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
+ return;
+ }
+
SPECIAL_COPY_ERROR_PROMPT(engine.isSequential(), tr("Cannot copy sequential file %1."), path)
if (newFile.exists() && newFile.isDir()) {
SPECIAL_COPY_ERROR_PROMPT(engine.isSequential(), tr("Cannot copy sequential file %1."), path)
if (newFile.exists() && newFile.isDir()) {
QString path = files[i].absoluteFilePath();
QFSFileEngine engine(path);
QString newPath = dest.absolutePath() + "/" + files[i].fileName();
QString path = files[i].absoluteFilePath();
QFSFileEngine engine(path);
QString newPath = dest.absolutePath() + "/" + files[i].fileName();
+ QFileInfo newFile(newPath);
- OVERWRITE_PROMPT(files[i], QFileInfo(newPath))
+ OVERWRITE_PROMPT(files[i], newFile)
- if (response == FileOperator::KEEP) {
- if (abort) break;
- updateProgress(1);
- continue;
+ if (files[i].isDir() && newFile.exists() && newFile.isDir()) {
+ if (response == FileOperator::SKIP_DIR) {
+ if (abort) break;
+ updateProgress(1);
+ removeExcludeFiles.insert(path);
+ continue;
+ }
+ } else {
+ if (response == FileOperator::KEEP) {
+ if (abort) break;
+ updateProgress(1);
+ removeExcludeFiles.insert(path);
+ continue;
+ }
}
while (!abort && !engine.rename(newPath)) {
}
while (!abort && !engine.rename(newPath)) {
- ERROR_PROMPT(!engine.rmdir(path, false), tr("Error deleting directory %1."), path)
break;
// source and target are nonmatching types(file and dir)
break;
// source and target are nonmatching types(file and dir)
public:
// DONT_ASK_ONCE is a hackish way to avoid asking twice to overwrite the same directory when moving
public:
// DONT_ASK_ONCE is a hackish way to avoid asking twice to overwrite the same directory when moving
- enum Response{NONE, ABORT, RETRY, IGNORE, KEEP, OVERWRITE, DONT_ASK_ONCE};
+ enum Response{NONE, ABORT, RETRY, IGNORE, KEEP, OVERWRITE, SKIP_DIR, DONT_ASK_ONCE};
FileOperator(QWidget *parent = 0);
FileOperator(QWidget *parent = 0);