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
)
24 EditResultDirection direction
;
26 Q_DECLARE_METATYPE(EditResult
)
29 * @brief Editor for renaming roles of a KItemListWidget.
31 * Provides signals when the editing got cancelled (e.g. by
32 * pressing Escape or when losing the focus) or when the editing
33 * got finished (e.g. by pressing Enter, Tab or Return).
35 * The size automatically gets increased if the text does not fit.
37 class DOLPHIN_EXPORT KItemListRoleEditor
: public KTextEdit
42 explicit KItemListRoleEditor(QWidget
* parent
);
43 ~KItemListRoleEditor() override
;
45 void setRole(const QByteArray
& role
);
46 QByteArray
role() const;
48 void setAllowUpDownKeyChainEdit(bool allowChainEdit
);
49 bool eventFilter(QObject
* watched
, QEvent
* event
) override
;
52 void roleEditingFinished(const QByteArray
& role
, const QVariant
& value
);
53 void roleEditingCanceled(const QByteArray
& role
, const QVariant
& value
);
56 bool event(QEvent
* event
) override
;
57 void keyPressEvent(QKeyEvent
* event
) override
;
61 * Increases the size of the editor in case if there is not
62 * enough room for the text.
64 void autoAdjustSize();
68 * Emits the signal roleEditingFinished if m_blockFinishedSignal
71 void emitRoleEditingFinished(EditResultDirection direction
= EditDone
);
75 bool m_blockFinishedSignal
;
76 bool m_allowUpDownKeyChainEdit
;