summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h')
-rw-r--r--examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
new file mode 100644
index 0000000000..2818438db3
--- /dev/null
+++ b/examples/widgets/widgets/shortcuteditor/shortcuteditordelegate.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2022 Laszlo Papp <lpapp@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+#ifndef SHORTCUTEDITORDELEGATE_H
+#define SHORTCUTEDITORDELEGATE_H
+
+#include <QStyledItemDelegate>
+
+//! [0]
+class ShortcutEditorDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ explicit ShortcutEditorDelegate(QObject *parent = nullptr);
+ ~ShortcutEditorDelegate() override = default;
+
+protected:
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+
+ void setEditorData(QWidget *editor, const QModelIndex &index) const override;
+ void setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const override;
+
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const override;
+
+private:
+ void commitAndCloseEditor();
+};
+//! [0]
+
+#endif