mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
When renaming, use the actual name of the item (from the KFileItem) in the dialog.
svn path=/trunk/KDE/kdebase/apps/; revision=700054
This commit is contained in:
parent
466ffaabbf
commit
f8fa4e8df1
4 changed files with 16 additions and 11 deletions
|
@ -190,10 +190,11 @@ void DolphinViewContainer::renameSelectedItems()
|
|||
{
|
||||
DolphinViewContainer* view = m_mainWindow->activeViewContainer();
|
||||
const KUrl::List urls = m_view->selectedUrls();
|
||||
const QList<KFileItem> items = m_view->selectedItems();
|
||||
if (urls.count() > 1) {
|
||||
// More than one item has been selected for renaming. Open
|
||||
// a rename dialog and rename all items afterwards.
|
||||
RenameDialog dialog(urls);
|
||||
RenameDialog dialog(urls, items);
|
||||
if (dialog.exec() == QDialog::Rejected) {
|
||||
return;
|
||||
}
|
||||
|
@ -238,7 +239,7 @@ void DolphinViewContainer::renameSelectedItems()
|
|||
// 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);
|
||||
RenameDialog dialog(urls, items);
|
||||
if (dialog.exec() == QDialog::Rejected) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -19,20 +19,21 @@
|
|||
|
||||
#include "renamedialog.h"
|
||||
|
||||
#include <kfileitem.h>
|
||||
#include <klineedit.h>
|
||||
#include <klocale.h>
|
||||
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QBoxLayout>
|
||||
|
||||
RenameDialog::RenameDialog(const KUrl::List& items) :
|
||||
RenameDialog::RenameDialog(const KUrl::List& urls, const QList<KFileItem>& items) :
|
||||
KDialog(),
|
||||
m_renameOneItem(false)
|
||||
{
|
||||
const QSize minSize = minimumSize();
|
||||
setMinimumSize(QSize(320, minSize.height()));
|
||||
|
||||
const int itemCount = items.count();
|
||||
const int itemCount = urls.count();
|
||||
Q_ASSERT(itemCount >= 1);
|
||||
m_renameOneItem = (itemCount == 1);
|
||||
|
||||
|
@ -52,8 +53,7 @@ RenameDialog::RenameDialog(const KUrl::List& items) :
|
|||
|
||||
QLabel* editLabel = 0;
|
||||
if (m_renameOneItem) {
|
||||
const KUrl& url = items.first();
|
||||
m_newName = url.fileName();
|
||||
m_newName = items.first().name();
|
||||
editLabel = new QLabel(i18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
|
||||
page);
|
||||
} else {
|
||||
|
@ -65,13 +65,13 @@ RenameDialog::RenameDialog(const KUrl::List& items) :
|
|||
}
|
||||
|
||||
m_lineEdit = new KLineEdit(page);
|
||||
QString extension = extensionString(items[0].prettyUrl());
|
||||
QString extension = extensionString(urls[0].prettyUrl());
|
||||
if (extension.length() > 0) {
|
||||
// The first item seems to have a extension (e. g. '.jpg' or '.txt'). Now
|
||||
// check whether all other items have the same extension. If this is the
|
||||
// check whether all other URLs have the same extension. If this is the
|
||||
// case, add this extension to the name suggestion.
|
||||
for (int i = 1; i < itemCount; ++i) {
|
||||
if (!items[i].prettyUrl().contains(extension)) {
|
||||
if (!urls[i].prettyUrl().contains(extension)) {
|
||||
// at least one item does not have the same extension
|
||||
extension.truncate(0);
|
||||
break;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <kurl.h>
|
||||
|
||||
|
||||
class KFileItem;
|
||||
class KLineEdit;
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,7 @@ class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RenameDialog(const KUrl::List& items);
|
||||
explicit RenameDialog(const KUrl::List& urls, const QList<KFileItem>& items);
|
||||
virtual ~RenameDialog();
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "treeviewcontextmenu.h"
|
||||
|
||||
#include <kfileitem.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kio/deletejob.h>
|
||||
#include <kmenu.h>
|
||||
|
@ -140,7 +141,9 @@ void TreeViewContextMenu::paste()
|
|||
void TreeViewContextMenu::rename()
|
||||
{
|
||||
const KUrl& oldUrl = m_fileInfo.url();
|
||||
RenameDialog dialog(oldUrl);
|
||||
QList<KFileItem> items;
|
||||
items.append( m_fileInfo );
|
||||
RenameDialog dialog(oldUrl, items);
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
const QString& newName = dialog.newName();
|
||||
if (!newName.isEmpty()) {
|
||||
|
|
Loading…
Reference in a new issue