Model delegate to provide editing/painting for custom variants.
More...
|
void | initStyleOption (QStyleOptionViewItem *option, const QModelIndex &index) const override |
|
Model delegate to provide editing/painting for custom variants.
Definition at line 29 of file viewmodeldelegate.h.
◆ ViewModelDelegate()
ViewModelDelegate::ViewModelDelegate |
( |
QObject * |
parent = nullptr | ) |
|
|
explicit |
Definition at line 28 of file viewmodeldelegate.cpp.
29 : QStyledItemDelegate(parent)
std::unique_ptr< EditorFactoryInterface > m_editor_factory
std::unique_ptr< CellDecoratorInterface > m_cell_decoration
◆ ~ViewModelDelegate()
ViewModelDelegate::~ViewModelDelegate |
( |
| ) |
|
|
overridedefault |
◆ createEditor()
QWidget * ViewModelDelegate::createEditor |
( |
QWidget * |
parent, |
|
|
const QStyleOptionViewItem & |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
override |
◆ initStyleOption()
void ViewModelDelegate::initStyleOption |
( |
QStyleOptionViewItem * |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
overrideprotected |
◆ onCustomEditorDataChanged
void ViewModelDelegate::onCustomEditorDataChanged |
( |
| ) |
|
|
slot |
◆ setCellDecoration()
◆ setEditorData()
void ViewModelDelegate::setEditorData |
( |
QWidget * |
editor, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
override |
Definition at line 59 of file viewmodeldelegate.cpp.
64 if (
auto customEditor =
dynamic_cast<CustomEditor*
>(editor))
65 customEditor->setData(index.data());
67 QStyledItemDelegate::setEditorData(editor, index);
Base class for all custom variant editors.
◆ setEditorFactory()
◆ setModelData()
void ViewModelDelegate::setModelData |
( |
QWidget * |
editor, |
|
|
QAbstractItemModel * |
model, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
override |
Definition at line 70 of file viewmodeldelegate.cpp.
76 if (
auto customEditor =
dynamic_cast<CustomEditor*
>(editor)) {
77 model->setData(index, customEditor->data());
79 QStyledItemDelegate::setModelData(editor, model, index);
◆ sizeHint()
QSize ViewModelDelegate::sizeHint |
( |
const QStyleOptionViewItem & |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
override |
Increases height of the row by 20% wrt the default.
Definition at line 85 of file viewmodeldelegate.cpp.
88 QSize result = QStyledItemDelegate::sizeHint(option, index);
89 result.setHeight(
static_cast<int>(result.height() * scale_default_height_factor));
◆ updateEditorGeometry()
void ViewModelDelegate::updateEditorGeometry |
( |
QWidget * |
editor, |
|
|
const QStyleOptionViewItem & |
option, |
|
|
const QModelIndex & |
index |
|
) |
| const |
|
override |
Makes an editor occupying whole available space in a cell.
If cell contains an icon as a decoration (i.e. icon of material property), it will be hidden as soon as editor up and running.
Definition at line 97 of file viewmodeldelegate.cpp.
100 QStyledItemDelegate::updateEditorGeometry(editor, option, index);
101 editor->setGeometry(option.rect);
◆ m_cell_decoration
◆ m_editor_factory
The documentation for this class was generated from the following files: