From cadc0f385512b2d5609bce7c55e9034da21e45c2 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 22 Nov 2017 15:52:27 +0000 Subject: [PATCH] Fix issue chaining RDTreeWidgetDelegate onto RDTreeViewDelegate * We need to inherit to chain these two, as otherwise when the tree view delegate calls sizeHint() it passes to the tree widget delegate, but then has no way to return back to the tree view for the overridden initStyleOption. * If there was a built-in way to chain delegates like styles (which solve this problem by calling back to baseStyle when going from one function to another), or better yet a way to avoid the base QStyledItemDelegate initStyleOption from completely trampling all over the option passed in to any function, this wouldn't be necessary. --- qrenderdoc/Widgets/Extended/RDTreeWidget.cpp | 10 +++++----- qrenderdoc/Widgets/Extended/RDTreeWidget.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp index 0fb2ecfb6..61f7aa365 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp @@ -544,7 +544,7 @@ RDTreeWidgetItemIterator &RDTreeWidgetItemIterator::operator++() } RDTreeWidgetDelegate::RDTreeWidgetDelegate(RDTreeWidget *parent) - : m_widget(parent), ForwardingDelegate(parent) + : m_widget(parent), RDTreeViewDelegate(parent) { } @@ -567,7 +567,7 @@ void RDTreeWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem & if(RichResourceTextCheck(v)) { // draw the item without text, so we get the proper background/selection/etc. - // we'd like to be able to use ForwardingDelegate::paint here, but either it calls to + // we'd like to be able to use the parent delegate's paint here, but either it calls to // QStyledItemDelegate which will re-fetch the text (bleh), or it calls to the manual // delegate which could do anything. So for this case we just use the style and skip the // delegate and hope it works out. @@ -588,7 +588,7 @@ void RDTreeWidgetDelegate::paint(QPainter *painter, const QStyleOptionViewItem & } } - return ForwardingDelegate::paint(painter, option, index); + return RDTreeViewDelegate::paint(painter, option, index); } QSize RDTreeWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -607,7 +607,7 @@ QSize RDTreeWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const Q } } - return ForwardingDelegate::sizeHint(option, index); + return RDTreeViewDelegate::sizeHint(option, index); } bool RDTreeWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, @@ -631,7 +631,7 @@ bool RDTreeWidgetDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, } } - return ForwardingDelegate::editorEvent(event, model, option, index); + return RDTreeViewDelegate::editorEvent(event, model, option, index); } bool RDTreeWidgetDelegate::linkHover(QMouseEvent *e, const QModelIndex &index) diff --git a/qrenderdoc/Widgets/Extended/RDTreeWidget.h b/qrenderdoc/Widgets/Extended/RDTreeWidget.h index 6e063fc4d..e7f7b00d2 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeWidget.h +++ b/qrenderdoc/Widgets/Extended/RDTreeWidget.h @@ -194,7 +194,7 @@ private: RDTreeWidgetItem *m_Current; }; -class RDTreeWidgetDelegate : public ForwardingDelegate +class RDTreeWidgetDelegate : public RDTreeViewDelegate { Q_OBJECT public: