Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_input_type_delegate.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the KDE project
3 * SPDX-FileCopyrightText: 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9
10#include <kcombobox.h>
12
14{
15public:
16 Private() { }
17};
18
20 : QStyledItemDelegate(parent), d(new Private)
21{
22
23}
24
30
45
46void KisInputTypeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
47{
48 KComboBox *combo = qobject_cast<KComboBox *>(editor);
49 Q_ASSERT(combo);
50
51 combo->setCurrentIndex(index.data(Qt::EditRole).toUInt() - 1);
52}
53
54void KisInputTypeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
55{
56 KComboBox *combo = qobject_cast<KComboBox *>(editor);
57 Q_ASSERT(combo);
58 model->setData(index, combo->currentIndex() + 1, Qt::EditRole);
59}
60
61void KisInputTypeDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const
62{
63 editor->setGeometry(option.rect);
64}
QList< QString > QStringList
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const override
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const override
void setEditorData(QWidget *editor, const QModelIndex &index) const override
KisInputTypeDelegate(QObject *parent=0)
static QString shortcutTypeToText(ShortcutType type)
@ MouseButtonType
A mouse button, possibly with key modifiers.
@ MouseWheelType
Mouse wheel movement, possibly with key modifiers.
@ KeyCombinationType
A list of keys that should be pressed.