diff options
| author | Peter Penz <[email protected]> | 2012-06-08 16:39:13 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-06-08 16:40:01 +0200 |
| commit | 98a4aa10ef09087ce6498d09461036cb0ab9cb4d (patch) | |
| tree | a13278be9ce236be1b31b5fa0226fa6238ef6268 /src/views/dolphinview.cpp | |
| parent | 0c206bda8e7d1de1f2b9d0d96ee6960d5d8640a7 (diff) | |
Inline renaming fixes
- Don't use an outdated KFileItem when renaming an item more than once
- Use the same font as the view
- Don't lose the focus when an editor-popup is shown
BUG: 299327
BUG: 298883
BUG: 301253
FIXED-IN: 4.9.0
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index e32d82f7b..ff5c2988a 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -168,6 +168,8 @@ DolphinView::DolphinView(const KUrl& url, QWidget* parent) : this, SLOT(slotSortRoleChangedByHeader(QByteArray,QByteArray))); connect(m_view, SIGNAL(visibleRolesChanged(QList<QByteArray>,QList<QByteArray>)), this, SLOT(slotVisibleRolesChangedByHeader(QList<QByteArray>,QList<QByteArray>))); + connect(m_view, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)), + this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant))); connect(m_view, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)), this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant))); connect(m_view->header(), SIGNAL(columnWidthChanged(QByteArray,qreal,qreal)), @@ -625,7 +627,7 @@ void DolphinView::renameSelectedItems() if (items.count() == 1) { const int index = m_model->index(items.first()); - m_container->controller()->view()->editRole(index, "text"); + m_view->editRole(index, "text"); } else { RenameDialog* dialog = new RenameDialog(this, items); dialog->setAttribute(Qt::WA_DeleteOnClose); @@ -1318,15 +1320,30 @@ void DolphinView::slotVisibleRolesChangedByHeader(const QList<QByteArray>& curre emit visibleRolesChanged(m_visibleRoles, previousVisibleRoles); } +void DolphinView::slotRoleEditingCanceled(int index, const QByteArray& role, const QVariant& value) +{ + Q_UNUSED(index); + Q_UNUSED(role); + Q_UNUSED(value); + setFocus(); +} + void DolphinView::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value) { if (role == "text") { - const KFileItem item = m_model->fileItem(index); + const KFileItem oldItem = m_model->fileItem(index); const QString newName = value.toString(); - if (!newName.isEmpty() && newName != item.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) { - KonqOperations::rename(this, item.url(), newName); + if (!newName.isEmpty() && newName != oldItem.text() && newName != QLatin1String(".") && newName != QLatin1String("..")) { + const KUrl oldUrl = oldItem.url(); + + QHash<QByteArray, QVariant> data; + data.insert(role, value); + m_model->setData(index, data); + + KonqOperations::rename(this, oldUrl, newName); } } + setFocus(); } void DolphinView::loadDirectory(const KUrl& url, bool reload) |
