Forward signals/slots as well in ForwardingDelegate

This commit is contained in:
baldurk
2020-03-18 12:02:13 +00:00
parent e276146163
commit c0e84875f3
+22 -1
View File
@@ -427,7 +427,28 @@ class ForwardingDelegate : public QStyledItemDelegate
public:
explicit ForwardingDelegate(QObject *parent = NULL) : QStyledItemDelegate(parent) {}
~ForwardingDelegate() {}
void setForwardDelegate(QAbstractItemDelegate *real) { m_delegate = real; }
void setForwardDelegate(QAbstractItemDelegate *real)
{
if(m_delegate)
{
QObject::disconnect(m_delegate, &QAbstractItemDelegate::commitData, this,
&QAbstractItemDelegate::commitData);
QObject::disconnect(m_delegate, &QAbstractItemDelegate::closeEditor, this,
&QAbstractItemDelegate::closeEditor);
QObject::disconnect(m_delegate, &QAbstractItemDelegate::sizeHintChanged, this,
&QAbstractItemDelegate::sizeHintChanged);
}
m_delegate = real;
if(m_delegate)
{
QObject::connect(m_delegate, &QAbstractItemDelegate::commitData, this,
&QAbstractItemDelegate::commitData);
QObject::connect(m_delegate, &QAbstractItemDelegate::closeEditor, this,
&QAbstractItemDelegate::closeEditor);
QObject::connect(m_delegate, &QAbstractItemDelegate::sizeHintChanged, this,
&QAbstractItemDelegate::sizeHintChanged);
}
}
void paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const override
{