Commit 755c59f7 authored by Dmitrii Utkin's avatar Dmitrii Utkin Committed by Boudewijn Rempt

400357 don't update editor's text by setEditorData

parent e6b80a85
......@@ -843,22 +843,17 @@ bool NodeDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const Q
return false;
}
QWidget *NodeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const
QWidget *NodeDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex &index) const
{
d->edit = new QLineEdit(parent);
// #400357 do not override QAbstractItemDelegate::setEditorData to update editor's text
// because replacing the text while user type is confusing
const QString &text = index.data(Qt::DisplayRole).toString();
d->edit = new QLineEdit(text, parent);
d->edit->setFocusPolicy(Qt::StrongFocus);
d->edit->installEventFilter(const_cast<NodeDelegate*>(this)); //hack?
return d->edit;
}
void NodeDelegate::setEditorData(QWidget *widget, const QModelIndex &index) const
{
QLineEdit *edit = qobject_cast<QLineEdit*>(widget);
Q_ASSERT(edit);
edit->setText(index.data(Qt::DisplayRole).toString());
}
void NodeDelegate::setModelData(QWidget *widget, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *edit = qobject_cast<QLineEdit*>(widget);
......
......@@ -45,7 +45,6 @@ public:
bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex& index) const override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment