32 : QStyledItemDelegate(parent)
34 this->proxyModel = proxyModel;
38 const QModelIndex &proxyIndex)
const
41 QModelIndex index = proxyModel->mapToSource(proxyIndex);
55 QComboBox *comboBox =
dynamic_cast<QComboBox *
>(object);
57 if (event->type() == QEvent::MouseButtonRelease) {
58 comboBox->showPopup();
63 return QStyledItemDelegate::eventFilter(
object, event);
68 QModelIndex index = proxyModel->mapToSource(proxyIndex);
70 QVariant value = proxyIndex.model()->
data(proxyIndex, Qt::EditRole);
75 const QModelIndex &proxyIndex)
const
77 QModelIndex index = proxyModel->mapToSource(proxyIndex);
80 bool ret = model->setData(proxyIndex, value, Qt::EditRole);
85 const QModelIndex & )
const
87 editor->setGeometry(option.rect);
91 const QModelIndex &index)
const
95 return QSpinBox().sizeHint();
BrowserItemDelegate(TreeSortFilterProxyModel *proxyModel, QObject *parent=nullptr)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
virtual QVariant getEditorValue(QWidget *editor)=0
virtual void setEditorValue(QWidget *editor, QVariant value)=0
virtual QWidget * createEditor(QWidget *parent)=0
void setEditorData(QWidget *editor, const QModelIndex &index) const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
bool eventFilter(QObject *object, QEvent *event)
This filter is required to make combo boxes work.
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
QVariant data(int column=1) const
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const