20 #include <QApplication>
23 : QStyledItemDelegate(parent)
28 const QModelIndex& index)
const
34 QStyledItemDelegate::paint(painter, option, index);
38 const QModelIndex& index)
const
42 if (
auto* customEditor =
dynamic_cast<CustomEditor*
>(result)) {
49 result = QStyledItemDelegate::createEditor(parent, option, index);
57 const QModelIndex& index)
const
62 if (
auto* customEditor =
dynamic_cast<CustomEditor*
>(editor))
63 model->setData(index, customEditor->editorData());
65 QStyledItemDelegate::setModelData(editor, model, index);
75 if (
auto* customEditor =
dynamic_cast<CustomEditor*
>(editor))
76 customEditor->setData(index.data());
78 QStyledItemDelegate::setEditorData(editor, index);
84 const QModelIndex& index)
const
86 QSize result = QStyledItemDelegate::sizeHint(option, index);
87 result.setHeight(
static_cast<int>(result.height() * 1.2));
96 const QModelIndex& index)
const
98 QStyledItemDelegate::updateEditorGeometry(editor, option, index);
99 editor->setGeometry(option.rect);
104 QWidget* parent)
const
106 if (index.internalPointer()) {
107 auto* item =
static_cast<SessionItem*
>(index.internalPointer());
117 auto* editor = qobject_cast<CustomEditor*>(sender());
119 emit commitData(editor);
125 const QModelIndex& index,
const QString& text)
const
127 QStyleOptionViewItem opt = option;
128 initStyleOption(&opt, index);
129 opt.text = displayText(text, option.locale);
130 const QWidget* widget = opt.widget;
131 QStyle* style = widget ? widget->style() : QApplication::style();
132 style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
Defines CustomEditors classes.
Defines classes releted to event filtering.
Defines class FitParameterDelegate.
Defines namespace GUI::View::PropertyEditorFactory.
Defines class SessionItem.
Base class for all custom variants editors.
void dataChanged(const QVariant &data)
Signal emit then user changed the data through the editor.
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Propagates the data change from the model to the editor (if it is still opened).
void paintCustomLabel(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const QString &text) const
Paints custom text in a a place corresponding given index.
void 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 (...
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
Increases height of the row by 20% wrt the default.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
FitParameterDelegate(QObject *parent)
void onCustomEditorDataChanged(const QVariant &)
Notifies everyone that the editor has completed editing the data.
virtual QWidget * createEditorFromIndex(const QModelIndex &index, QWidget *parent) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Propagates changed data from the editor to the model.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Base class for a GUI data item.
Propagate tab events from focusProxy to parent.
QWidget * CreateEditor(const SessionItem &item, QWidget *parent=nullptr)
Creates an editor suitable for editing of item.value()
QString toString(const QModelIndex &index)
Provides string representation of index data.
bool hasStringRepresentation(const QModelIndex &index)
Returns true if the index data has known (custom) conversion to string.