~ubuntu-branches/debian/sid/kde-baseapps/sid

« back to all changes in this revision

Viewing changes to plasma/applets/folderview/itemeditor.cpp

  • Committer: Package Import Robot
  • Author(s): Modestas Vainius, Eshat Cakar, Pino Toscano
  • Date: 2012-06-09 22:18:08 UTC
  • mfrom: (4.2.1) (6.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20120609221808-h1l0ekd5qmb8nefr
Tags: 4:4.8.4-1
* New upstream release.

[ Eshat Cakar ]
* Add watch file.
* Bump kde-sc-dev-latest build dependency to version 4:4.8.4.
* Update installed files.

[ Pino Toscano ]
* Move files of the konqueror documentation from kde-baseapps-data to
  konqueror itself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
ItemEditor::ItemEditor(QGraphicsWidget *parent, const QStyleOptionViewItemV4 &option,
30
30
                       const QModelIndex &index)
31
31
    : QGraphicsProxyWidget(parent),
32
 
      m_index(index)
 
32
      m_index(index),
 
33
      m_uncommitted(true)
33
34
{
34
35
    // Create the editor
35
36
    m_editor = new KTextEdit();
66
67
 
67
68
void ItemEditor::commitData()
68
69
{
69
 
    const_cast<QAbstractItemModel*>(m_index.model())->setData(m_index, m_editor->toPlainText(), Qt::EditRole);
 
70
    if (m_uncommitted) {
 
71
        const_cast<QAbstractItemModel*>(m_index.model())->setData(m_index, m_editor->toPlainText(), Qt::EditRole);
 
72
        m_uncommitted = false;
 
73
    }
70
74
}
71
75
 
72
76
bool ItemEditor::eventFilter(QObject *watched, QEvent *event)
73
77
{
74
78
    KTextEdit *editor = qobject_cast<KTextEdit*>(watched);
75
 
    if (!editor)
 
79
    if (!editor) {
76
80
        return false;
 
81
    }
77
82
 
78
83
    switch (event->type())
79
84
    {
107
112
 
108
113
    case QEvent::FocusOut:
109
114
    {
110
 
        commitData();
111
 
        emit closeEditor(this, QAbstractItemDelegate::NoHint);
 
115
        if (m_uncommitted) {
 
116
            commitData();
 
117
            emit closeEditor(this, QAbstractItemDelegate::NoHint);
 
118
        }
112
119
        return true;
113
120
    }
114
121