┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-04-17 18:13:31 +0200
committerPeter Penz <[email protected]>2012-04-17 18:15:12 +0200
commitb2e54c3a316b502ab4f7a95250f8316dc591c057 (patch)
tree227eda97fcf699633f49fa7ea6ccdf38a19626e7 /src/views
parenteb1b53103d67784c68bb33e5fe3fefcad4cdbdea (diff)
Implement inline-renaming for the new view-engine
BUG: 286893 FIXED-IN: 4.9.0
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp53
-rw-r--r--src/views/dolphinview.h2
-rw-r--r--src/views/dolphinviewactionhandler.cpp1
3 files changed, 33 insertions, 23 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index daf6aca76..3e1ed34ec 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -156,6 +156,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) :
this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray)));
connect(view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)),
this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>)));
+ connect(view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
+ this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
connect(view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)),
this, SLOT(slotHeaderColumnWidthChanged(QByteArray,qreal,qreal)));
@@ -598,30 +600,26 @@ void DolphinView::clearSelection()
void DolphinView::renameSelectedItems()
{
- KFileItemList items = selectedItems();
- const int itemCount = items.count();
- if (itemCount < 1) {
- return;
- }
+ const KFileItemList items = selectedItems();
+ if (items.isEmpty()) {
+ return;
+ }
- // TODO: The new view-engine introduced with Dolphin 2.0 does not support inline
- // renaming yet.
- /*if ((itemCount == 1) && DolphinSettings::instance().generalSettings()->renameInline()) {
- const QModelIndex dirIndex = m_viewAccessor.dirModel()->indexForItem(items.first());
- const QModelIndex proxyIndex = m_viewAccessor.proxyModel()->mapFromSource(dirIndex);
- m_viewAccessor.itemView()->edit(proxyIndex);
- } else {*/
- RenameDialog* dialog = new RenameDialog(this, items);
- dialog->setAttribute(Qt::WA_DeleteOnClose);
- dialog->show();
- dialog->raise();
- dialog->activateWindow();
- //}
+ if (items.count() == 1) {
+ const int index = fileItemModel()->index(items.first());
+ m_container->controller()->view()->editRole(index, "name");
+ } else {
+ RenameDialog* dialog = new RenameDialog(this, items);
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->show();
+ dialog->raise();
+ dialog->activateWindow();
+ }
- // Assure that the current index remains visible when KFileItemModel
- // will notify the view about changed items (which might result in
- // a changed sorting).
- m_assureVisibleCurrentIndex = true;
+ // Assure that the current index remains visible when KFileItemModel
+ // will notify the view about changed items (which might result in
+ // a changed sorting).
+ m_assureVisibleCurrentIndex = true;
}
void DolphinView::trashSelectedItems()
@@ -1291,6 +1289,17 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre
emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles);
}
+void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value)
+{
+ if (role == "name") {
+ const KFileItem item = fileItemModel()->fileItem(index);
+ const QString newName = value.toString();
+ if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) {
+ KonqOperations::rename(this, item.url(), newName);
+ }
+ }
+}
+
KFileItemModel* DolphinView::fileItemModel() const
{
return static_cast<KFileItemModel*>(m_container->controller()->model());
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index f95572564..a9cf0ade4 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -617,6 +617,8 @@ private slots:
void slotVisibleRolesChangedByHeader(const QList<QByteArray>& current,
const QList<QByteArray>& previous);
+ void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value);
+
/**
* Observes the item with the URL \a url. As soon as the directory
* model indicates that the item is available, the item will
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index bc8f059a4..e22936740 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -36,7 +36,6 @@
#include <KNewFileMenu>
#include <KSelectAction>
#include <KToggleAction>
-#include <KRun>
#include <KPropertiesDialog>
#include <KIcon>