Summary: | Cervisia "Create patch against repository" does not confirm file overwrite | ||
---|---|---|---|
Product: | [Applications] cervisia | Reporter: | Paul Eggleton <bluelightning> |
Component: | general | Assignee: | Christian Loose <christian.loose> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Gentoo Packages | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Paul Eggleton
2005-06-11 05:19:32 UTC
IMHO a kdelibs problem (see Bug 102972), but I will fix it anyway until the requested feature is implemented. Thanks for the report. SVN commit 428324 by cloose: Be nice and ask before overwriting existing files. BUG: 107201 M +3 -0 cervisiapart.cpp M +3 -0 logdlg.cpp M +22 -0 misc.cpp M +2 -0 misc.h M +1 -1 resolvedlg.cpp --- trunk/KDE/kdesdk/cervisia/cervisiapart.cpp #428323:428324 @@ -1335,6 +1335,9 @@ if( fileName.isEmpty() ) return; + if( !Cervisia::CheckOverwrite(fileName) ) + return; + QFile f(fileName); if( !f.open(IO_WriteOnly) ) { --- trunk/KDE/kdesdk/cervisia/logdlg.cpp #428323:428324 @@ -466,6 +466,9 @@ if( fileName.isEmpty() ) return; + if( !Cervisia::CheckOverwrite(fileName) ) + return; + QFile f(fileName); if( !f.open(IO_WriteOnly) ) { --- trunk/KDE/kdesdk/cervisia/misc.cpp #428323:428324 @@ -26,11 +26,13 @@ #include <sys/types.h> #include <unistd.h> #include <qfile.h> +#include <qfileinfo.h> #include <qregexp.h> #include <qstringlist.h> #include <kconfig.h> #include <kemailsettings.h> #include <klocale.h> +#include <kmessagebox.h> #include <kprocess.h> #include <ktempfile.h> #include <kuser.h> @@ -204,6 +206,26 @@ } +bool Cervisia::CheckOverwrite(const QString& fileName) +{ + bool result = true; + + QFileInfo fi(fileName); + + // does the file already exist? + if( fi.exists() ) + { + result = (KMessageBox::warningYesNo(0, + i18n("A file named \"%1\" already exists. Are you sure you want to overwrite it?").arg(fileName), + i18n("Overwrite File?"), + KGuiItem(i18n("&Overwrite"), "filesave", i18n("Overwrite the file")), + KStdGuiItem::cancel()) == KMessageBox::Yes); + } + + return result; +} + + QString joinLine(const QStringList &list) { QString line; --- trunk/KDE/kdesdk/cervisia/misc.h #428323:428324 @@ -50,6 +50,8 @@ */ QString NormalizeRepository(const QString& repository); +bool CheckOverwrite(const QString& fileName); + } --- trunk/KDE/kdesdk/cervisia/resolvedlg.cpp #428323:428324 @@ -579,7 +579,7 @@ QString filename = KFileDialog::getSaveFileName(0, 0, this, 0); - if (!filename.isEmpty()) + if( !filename.isEmpty() && Cervisia::CheckOverwrite(filename) ) saveFile(filename); } |