File indexing completed on 2024-04-28 05:50:39
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef PROFILESHORTCUTDELEGATE_H 0008 #define PROFILESHORTCUTDELEGATE_H 0009 0010 #include <QKeySequenceEdit> 0011 #include <QModelIndex> 0012 #include <QSet> 0013 #include <QStyledItemDelegate> 0014 0015 class QWidget; 0016 class QKeyEvent; 0017 class QPainter; 0018 0019 namespace Konsole 0020 { 0021 class StyledBackgroundPainter 0022 { 0023 public: 0024 static void drawBackground(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index); 0025 }; 0026 0027 class FilteredKeySequenceEdit : public QKeySequenceEdit 0028 { 0029 Q_OBJECT 0030 0031 public: 0032 explicit FilteredKeySequenceEdit(QWidget *parent = nullptr) 0033 : QKeySequenceEdit(parent) 0034 { 0035 } 0036 0037 protected: 0038 void keyPressEvent(QKeyEvent *event) override; 0039 }; 0040 0041 class ShortcutItemDelegate : public QStyledItemDelegate 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 explicit ShortcutItemDelegate(QObject *parent = nullptr); 0047 0048 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override; 0049 QWidget *createEditor(QWidget *aParent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0050 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0051 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 0052 void destroyEditor(QWidget *editor, const QModelIndex &index) const override; 0053 0054 private Q_SLOTS: 0055 void editorModified(); 0056 0057 private: 0058 mutable QSet<QWidget *> _modifiedEditors; 0059 mutable QSet<QModelIndex> _itemsBeingEdited; 0060 }; 0061 0062 } 0063 #endif