[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bugs-dist
Subject: [Bug 77315] Special characters when renaming on certain file
From: Scott Wheeler <wheeler () kde ! org>
Date: 2004-10-18 14:13:10
Message-ID: 20041018141310.19660.qmail () ktown ! kde ! org
[Download RAW message or body]
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
http://bugs.kde.org/show_bug.cgi?id=77315
------- Additional Comments From wheeler kde org 2004-10-18 16:13 -------
CVS commit by wheeler:
Patch from Tim Hutt to fix QString -> KURL encoding. This produces similar
symptoms to #77315, but actually isn't the same bug.
CCBUG:77315
M +34 -26 filerenamer.cpp 1.36
--- kdemultimedia/juk/filerenamer.cpp #1.35:1.36
@ -20,4 +20,5 @
#include <kmacroexpander.h>
#include <kmessagebox.h>
+#include <kstandarddirs.h>
#include <qdir.h>
@ -28,4 +29,5 @
#include <qpainter.h>
#include <qsimplerichtext.h>
+#include <qstylesheet.h>
class FileRenamer::ConfirmationDialog : public KDialogBase
@ -166,14 +168,16 @ void FileRenamer::rename(PlaylistItem *i
return;
- if(KMessageBox::warningContinueCancel(0,
- i18n("<qt>You are about to rename the file<br/><br/> '%1'<br/><br/> to \
<br/><br/>'%2'<br/><br/>Are you sure you "
- "want to \
continue?</qt>").arg(item->file().absFilePath()).arg(newFilename),
- i18n("Warning"), KStdGuiItem::cont(), "ShowFileRenamerWarning")
- == KMessageBox::Continue) {
+ QString message = i18n("<qt>You are about to rename the \
file<br/><br/>'%1'<br/><br/> to <br/>" + \
"<br/>'%2'<br/><br/>Are you sure you want to continue?</qt>"); + message = \
message.arg(QStyleSheet::escape(item->file().absFilePath())); + message = \
message.arg(QStyleSheet::escape(newFilename)); +
+ if(KMessageBox::warningContinueCancel(0, message, i18n("Warning"), \
KStdGuiItem::cont(), + \
"ShowFileRenamerWarning") == KMessageBox::Continue) + {
if(moveFile(item->file().absFilePath(), newFilename))
item->setFile(FileHandle(newFilename));
else
- KMessageBox::error(0,
- i18n("<qt>Failed to rename the \
file<br/><br/>'%1'<br/><br/>to<br/><br/>'%2'</qt>") + \
KMessageBox::error(0, i18n("<qt>Failed to rename the \
file<br/><br/>'%1'<br/><br/>to<br/><br/>'%2'</qt>")
.arg(item->file().absFilePath()).arg(newFilename));
}
@ -250,23 +254,27 @ bool FileRenamer::moveFile(const QString
return false;
- QString dest_ = dest.mid(1); // strip the leading "/"
- if(dest_.find("/") > 0) {
- const QStringList components = QStringList::split("/", dest_.left( \
dest.findRev("/")));
- QStringList::ConstIterator it = components.begin();
- QStringList::ConstIterator end = components.end();
- QString processedComponents;
- for(; it != end; ++it) {
- processedComponents += "/" + *it;
- kdDebug(65432) << "Checking path " << processedComponents << endl;
- QDir dir(processedComponents);
- if(!dir.exists()) {
- if (!dir.mkdir(processedComponents, true))
+ // Escape URL.
+ KURL srcURL = KURL::fromPathOrURL(src);
+ KURL dstURL = KURL::fromPathOrURL(dest);
+
+ // Clean it.
+ srcURL.cleanPath();
+ dstURL.cleanPath();
+
+ // Make sure it is valid.
+ if(!srcURL.isValid() || !dstURL.isValid())
return false;
- kdDebug(65432) << "Need to create " << processedComponents << endl;
- }
- }
- }
- return KIO::NetAccess::file_move(KURL(src), KURL(dest));
+ // Get just the directory.
+ KURL dir = dstURL;
+ dir.setFileName(QString::null);
+
+ // Create the directory.
+ if(!KStandardDirs::exists(dir.path()))
+ if(!KStandardDirs::makeDir(dir.path()))
+ return false;
+
+ // Move the file.
+ return KIO::NetAccess::file_move(srcURL, dstURL);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic