Krita Source Code Documentation
Loading...
Searching...
No Matches
KisInputTypeDelegate Class Reference

A delegate providing editors for the type property of KisShortcutConfiguration. More...

#include <kis_input_type_delegate.h>

+ Inheritance diagram for KisInputTypeDelegate:

Classes

class  Private
 

Public Member Functions

QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const override
 
 KisInputTypeDelegate (QObject *parent=0)
 
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 &) const override
 
 ~KisInputTypeDelegate () override
 

Private Attributes

Private *const d
 

Detailed Description

A delegate providing editors for the type property of KisShortcutConfiguration.

Definition at line 16 of file kis_input_type_delegate.h.

Constructor & Destructor Documentation

◆ KisInputTypeDelegate()

KisInputTypeDelegate::KisInputTypeDelegate ( QObject * parent = 0)
explicit

Definition at line 19 of file kis_input_type_delegate.cpp.

20 : QStyledItemDelegate(parent), d(new Private)
21{
22
23}

◆ ~KisInputTypeDelegate()

KisInputTypeDelegate::~KisInputTypeDelegate ( )
override

Definition at line 25 of file kis_input_type_delegate.cpp.

26{
27 delete d;
28
29}

References d.

Member Function Documentation

◆ createEditor()

QWidget * KisInputTypeDelegate::createEditor ( QWidget * parent,
const QStyleOptionViewItem & ,
const QModelIndex &  ) const
override

Definition at line 31 of file kis_input_type_delegate.cpp.

32{
33 KComboBox *combo = new KComboBox(parent);
34 combo->addItems(QStringList()
35 << i18n("Key Combination")
36 << i18n("Mouse Button")
37 << i18n("Mouse Wheel")
38 << i18n("Gesture")
39 );
40 combo->setCurrentIndex(0);
41
42 return combo;
43}
QList< QString > QStringList

◆ setEditorData()

void KisInputTypeDelegate::setEditorData ( QWidget * editor,
const QModelIndex & index ) const
override

Definition at line 45 of file kis_input_type_delegate.cpp.

46{
47 KComboBox *combo = qobject_cast<KComboBox *>(editor);
48 Q_ASSERT(combo);
49
50 combo->setCurrentIndex(index.data(Qt::EditRole).toUInt() - 1);
51}

◆ setModelData()

void KisInputTypeDelegate::setModelData ( QWidget * editor,
QAbstractItemModel * model,
const QModelIndex & index ) const
override

Definition at line 53 of file kis_input_type_delegate.cpp.

54{
55 KComboBox *combo = qobject_cast<KComboBox *>(editor);
56 Q_ASSERT(combo);
57 model->setData(index, combo->currentIndex() + 1, Qt::EditRole);
58}

◆ updateEditorGeometry()

void KisInputTypeDelegate::updateEditorGeometry ( QWidget * editor,
const QStyleOptionViewItem & option,
const QModelIndex &  ) const
override

Definition at line 60 of file kis_input_type_delegate.cpp.

61{
62 editor->setGeometry(option.rect);
63}

Member Data Documentation

◆ d

Private* const KisInputTypeDelegate::d
private

Definition at line 30 of file kis_input_type_delegate.h.


The documentation for this class was generated from the following files: