2 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0-or-later
7 #ifndef KITEMLISTROLEEDITOR_H
8 #define KITEMLISTROLEEDITOR_H
10 #include "dolphin_export.h"
14 enum EditResultDirection
{
19 Q_DECLARE_METATYPE(EditResultDirection
)
23 EditResultDirection direction
;
25 Q_DECLARE_METATYPE(EditResult
)
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, Tab or Return).
34 * The size automatically gets increased if the text does not fit.
36 class DOLPHIN_EXPORT KItemListRoleEditor
: public KTextEdit
41 explicit KItemListRoleEditor(QWidget
*parent
);
42 ~KItemListRoleEditor() override
;
44 void setRole(const QByteArray
&role
);
45 QByteArray
role() const;
47 void setAllowUpDownKeyChainEdit(bool allowChainEdit
);
48 bool eventFilter(QObject
*watched
, QEvent
*event
) override
;
51 void roleEditingFinished(const QByteArray
&role
, const QVariant
&value
);
52 void roleEditingCanceled(const QByteArray
&role
, const QVariant
&value
);
55 bool event(QEvent
*event
) override
;
56 void keyPressEvent(QKeyEvent
*event
) override
;
60 * Increases the size of the editor in case if there is not
61 * enough room for the text.
63 void autoAdjustSize();
67 * Emits the signal roleEditingFinished if m_blockFinishedSignal
70 void emitRoleEditingFinished(EditResultDirection direction
= EditDone
);
74 bool m_blockFinishedSignal
;
75 bool m_allowUpDownKeyChainEdit
;