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.
This commit is contained in:
baldurk
2017-11-22 19:11:24 +00:00
parent 1fcc41effa
commit cadc0f3855
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -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)
+1 -1
View File
@@ -194,7 +194,7 @@ private:
RDTreeWidgetItem *m_Current;
};
class RDTreeWidgetDelegate : public ForwardingDelegate
class RDTreeWidgetDelegate : public RDTreeViewDelegate
{
Q_OBJECT
public: