File bnc722684-fix-renaming-in-folderview.diff of Package kdebase4
commit 1a284bb79e547f0789f02b202fa309823e6198b5
Author: Aaron Seigo <aseigo@kde.org>
Date: Wed Sep 21 15:00:39 2011 +0200
only try to change the name once
BUG:270414
Updated to match 4.7.2
diff --git a/plasma/applets/folderview/itemeditor.cpp b/plasma/applets/folderview/itemeditor.cpp
index 63febf6..3ff708a 100644
--- plasma/applets/folderview/itemeditor.cpp
+++ plasma/applets/folderview/itemeditor.cpp
@@ -29,7 +29,8 @@
ItemEditor::ItemEditor(QGraphicsWidget *parent, const QStyleOptionViewItemV4 &option,
const QModelIndex &index)
: QGraphicsProxyWidget(parent),
- m_index(index)
+ m_index(index),
+ m_uncommitted(true)
{
// Create the editor
m_editor = new KTextEdit();
@@ -66,14 +67,18 @@ ItemEditor::~ItemEditor()
void ItemEditor::commitData()
{
- const_cast<QAbstractItemModel*>(m_index.model())->setData(m_index, m_editor->toPlainText(), Qt::EditRole);
+ if (m_uncommitted) {
+ const_cast<QAbstractItemModel*>(m_index.model())->setData(m_index, m_editor->toPlainText(), Qt::EditRole);
+ m_uncommitted = false;
+ }
}
bool ItemEditor::eventFilter(QObject *watched, QEvent *event)
{
KTextEdit *editor = qobject_cast<KTextEdit*>(watched);
- if (!editor)
+ if (!editor) {
return false;
+ }
switch (event->type())
{
@@ -107,8 +112,10 @@ bool ItemEditor::eventFilter(QObject *watched, QEvent *event)
case QEvent::FocusOut:
{
- commitData();
- emit closeEditor(this, QAbstractItemDelegate::NoHint);
+ if (m_uncommitted) {
+ commitData();
+ emit closeEditor(this, QAbstractItemDelegate::NoHint);
+ }
return true;
}
diff --git a/plasma/applets/folderview/itemeditor.h b/plasma/applets/folderview/itemeditor.h
index 3d54ea6..7ffa450 100644
--- plasma/applets/folderview/itemeditor.h
+++ plasma/applets/folderview/itemeditor.h
@@ -49,6 +49,7 @@ protected:
private:
KTextEdit *m_editor;
QModelIndex m_index;
+ bool m_uncommitted;
};
#endif