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

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

#include <kis_input_mode_delegate.h>

+ Inheritance diagram for KisInputModeDelegate:

Classes

class  Private
 

Public Member Functions

QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const override
 
 KisInputModeDelegate (QObject *parent=nullptr)
 
void setAction (KisAbstractInputAction *action)
 
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
 
 ~KisInputModeDelegate () override
 

Private Attributes

Private *const d {nullptr}
 

Detailed Description

A delegate providing editors for the mode property of KisShortcutConfiguration.

Definition at line 17 of file kis_input_mode_delegate.h.

Constructor & Destructor Documentation

◆ KisInputModeDelegate()

KisInputModeDelegate::KisInputModeDelegate ( QObject * parent = nullptr)
explicit

Definition at line 22 of file kis_input_mode_delegate.cpp.

23 : QStyledItemDelegate(parent), d(new Private)
24{
25}

◆ ~KisInputModeDelegate()

KisInputModeDelegate::~KisInputModeDelegate ( )
override

Definition at line 27 of file kis_input_mode_delegate.cpp.

28{
29 delete d;
30
31}

References d.

Member Function Documentation

◆ createEditor()

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

Definition at line 33 of file kis_input_mode_delegate.cpp.

34{
35 KComboBox *combo = new KComboBox(parent);
36 QStringList sorted = d->action->shortcutIndexes().keys();
37 std::sort(sorted.begin(), sorted.end());
38 combo->addItems(sorted);
39 return combo;
40}
virtual QHash< QString, int > shortcutIndexes() const

References KisInputModeDelegate::Private::action, d, and KisAbstractInputAction::shortcutIndexes().

◆ setAction()

void KisInputModeDelegate::setAction ( KisAbstractInputAction * action)

Definition at line 65 of file kis_input_mode_delegate.cpp.

66{
67 d->action = action;
68}

References KisInputModeDelegate::Private::action, and d.

◆ setEditorData()

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

Definition at line 42 of file kis_input_mode_delegate.cpp.

43{
44 KComboBox *combo = qobject_cast<KComboBox *>(editor);
45 Q_ASSERT(combo);
46
47 int i = combo->findText(d->action->shortcutIndexes().key(index.data(Qt::EditRole).toUInt()));
48 combo->setCurrentIndex(i);
49}

References KisInputModeDelegate::Private::action, d, and KisAbstractInputAction::shortcutIndexes().

◆ setModelData()

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

Definition at line 51 of file kis_input_mode_delegate.cpp.

52{
53 KComboBox *combo = qobject_cast<KComboBox *>(editor);
54 Q_ASSERT(combo);
55
56 int i = d->action->shortcutIndexes().value(combo->currentText());
57 model->setData(index, i, Qt::EditRole);
58}

References KisInputModeDelegate::Private::action, d, and KisAbstractInputAction::shortcutIndexes().

◆ updateEditorGeometry()

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

Definition at line 60 of file kis_input_mode_delegate.cpp.

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

Member Data Documentation

◆ d

Private* const KisInputModeDelegate::d {nullptr}
private

Definition at line 33 of file kis_input_mode_delegate.h.

33{nullptr};

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