1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef KITEMLISTROLEEDITOR_H
21 #define KITEMLISTROLEEDITOR_H
23 #include "libdolphin_export.h"
28 * @brief Editor for renaming roles of a KItemListWidget.
30 * Provides signals when the editing got cancelled (e.g. by
31 * pressing Escape or when losing the focus) or when the editing
32 * got finished (e.g. by pressing Enter or Return).
34 * The size automatically gets increased if the text does not fit.
36 class LIBDOLPHINPRIVATE_EXPORT KItemListRoleEditor
: public KTextEdit
41 explicit KItemListRoleEditor(QWidget
* parent
);
42 virtual ~KItemListRoleEditor();
44 void setIndex(int index
);
47 void setRole(const QByteArray
& role
);
48 QByteArray
role() const;
50 virtual bool eventFilter(QObject
* watched
, QEvent
* event
);
53 void roleEditingFinished(int index
, const QByteArray
& role
, const QVariant
& value
);
54 void roleEditingCanceled(int index
, const QByteArray
& role
, const QVariant
& value
);
57 virtual bool event(QEvent
* event
);
58 virtual void keyPressEvent(QKeyEvent
* event
);
62 * Increases the size of the editor in case if there is not
63 * enough room for the text.
65 void autoAdjustSize();
69 * Emits the signal roleEditingFinished if m_blockFinishedSignal
72 void emitRoleEditingFinished();
77 bool m_blockFinishedSignal
;