Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
CommonItemDelegate.h
Go to the documentation of this file.
1#pragma once
2
3#include <QStyledItemDelegate>
4#include <misc/global.h>
5
6namespace sf
7{
8
12class _MISC_CLASS CommonItemDelegate : public QStyledItemDelegate
13{
14 Q_OBJECT
15
16 public:
20 typedef QList<QPair<QVariant, QString>> OptionsType;
21
25 enum EItemDataRole : int
26 {
28 TypeRole = Qt::ItemDataRole::UserRole,
40 AlignmentRole
41 };
42
62
68 // ReSharper disable once CppFunctionIsNotImplemented
69 Q_SIGNAL void addLineEditActions(QLineEdit* lineEdit, const QModelIndex& index) const;
70
74 explicit CommonItemDelegate(QObject* parent = nullptr);
75
81 static EEditorType getEditorType(const QModelIndex& index);
82
86 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
87
91 void setEditorData(QWidget* editor, const QModelIndex& index) const override;
92
96 void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
97
101 void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
102
106 void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
107};
108
109}// namespace sf
Allows a list model to determine the editor for a field.
Definition CommonItemDelegate.h:13
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Overridden from base class.
static EEditorType getEditorType(const QModelIndex &index)
Gets the editor type by calling the modal data() method with TypeRole.
CommonItemDelegate(QObject *parent=nullptr)
Constructor.
EEditorType
Possible inline editors for a column in the list model.
Definition CommonItemDelegate.h:47
@ etStringList
Definition CommonItemDelegate.h:59
@ etDropDown
Definition CommonItemDelegate.h:50
@ etDefault
Definition CommonItemDelegate.h:48
@ etDropDownIndex
Definition CommonItemDelegate.h:51
@ etDropDownEdit
Definition CommonItemDelegate.h:52
@ etDoubleSpinBox
Definition CommonItemDelegate.h:56
@ etShortcut
Definition CommonItemDelegate.h:54
@ etSpinBox
Definition CommonItemDelegate.h:55
@ etDropDownFlags
Definition CommonItemDelegate.h:53
@ etColorEdit
Definition CommonItemDelegate.h:58
@ etULongLong
Definition CommonItemDelegate.h:57
@ etTextEdit
Definition CommonItemDelegate.h:49
QList< QPair< QVariant, QString > > OptionsType
Type for the named options available in case of a dropdown.
Definition CommonItemDelegate.h:20
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overridden from base class.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overridden from base class.
Q_SIGNAL void addLineEditActions(QLineEdit *lineEdit, const QModelIndex &index) const
Signal allowing adding actions to a line edit.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Overridden from base class.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overridden from base class.
EItemDataRole
Extension on the Qt::ItemDataRole enumerate.
Definition CommonItemDelegate.h:26
@ MaximumRole
Maximum for scalar value e.g. a spin box.
Definition CommonItemDelegate.h:34
@ IncrementRole
Increment for scalar value e.g. a spin box.
Definition CommonItemDelegate.h:36
@ TextColorRole
Determines the text color of the text. Can be a QColor or QPalette::ColorRole (integer) type.
Definition CommonItemDelegate.h:38
@ MinimumRole
Minimum for scalar value e.g. a spin box.
Definition CommonItemDelegate.h:32
@ OptionsRole
For retrieving the options list for a dropdown edit.
Definition CommonItemDelegate.h:30
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10