diff options
| author | Peter Penz <[email protected]> | 2007-03-13 18:33:00 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-03-13 18:33:00 +0000 |
| commit | 507984415a2953000ef1edb77c9dbc3364846b13 (patch) | |
| tree | 90623c9904c049270c30d5edc5a510f129776b9c /src/dolphinview.cpp | |
| parent | d9ac44e08f8d2abe7104c20e308d05038e1896da (diff) | |
improve renaming for n selected items/1 selected item
svn path=/trunk/KDE/kdebase/apps/; revision=642235
Diffstat (limited to 'src/dolphinview.cpp')
| -rw-r--r-- | src/dolphinview.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 3602d1563..da8aa3c82 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -265,45 +265,31 @@ void DolphinView::renameSelectedItems() } else { // TODO: check how this can be integrated into KonqUndoManager/KonqOperations - - //UndoManager& undoMan = UndoManager::instance(); - //undoMan.beginMacro(); - + // as one operation instead of n rename operations like it is done now... Q_ASSERT(newName.contains('#')); - const int urlsCount = urls.count(); - // iterate through all selected items and rename them... const int replaceIndex = newName.indexOf('#'); Q_ASSERT(replaceIndex >= 0); - for (int i = 0; i < urlsCount; ++i) { - const KUrl& source = urls[i]; + int index = 1; + + KUrl::List::const_iterator it = urls.begin(); + KUrl::List::const_iterator end = urls.end(); + while (it != end) { + const KUrl& oldUrl = *it; QString number; - number.setNum(i + 1); + number.setNum(index++); QString name(newName); name.replace(replaceIndex, 1, number); - if (source.fileName() != name) { - KUrl dest(source.upUrl()); - dest.addPath(name); - - const bool destExists = KIO::NetAccess::exists(dest, false, view); - if (destExists) { - view->statusBar()->setMessage(i18n("Renaming failed (item '%1' already exists).",name), - DolphinStatusBar::Error); - break; - } - else if (KIO::NetAccess::file_move(source, dest)) { - // TODO: From the users point of view he executed one 'rename n files' operation, - // but internally we store it as n 'rename 1 file' operations for the undo mechanism. - //DolphinCommand command(DolphinCommand::Rename, source, dest); - //undoMan.addCommand(command); - } + if (oldUrl.fileName() != name) { + KUrl newUrl(oldUrl.upUrl()); + newUrl.addPath(name); + m_mainWindow->rename(oldUrl, newUrl); } + ++it; } - - //undoMan.endMacro(); } } else { @@ -311,8 +297,9 @@ void DolphinView::renameSelectedItems() // renaming mechanism from the views. Q_ASSERT(urls.count() == 1); - // TODO: until KFileItemDelegate supports editing, use the the Dolphin - // rename dialog as temporary workaround: + // TODO: Think about using KFileItemDelegate as soon as it supports editing. + // Currently the RenameDialog is used, but I'm not sure whether inline renaming + // is a benefit for the user at all -> let's wait for some input first... RenameDialog dialog(urls); if (dialog.exec() == QDialog::Rejected) { return; |
