* 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.
* Reported by Coverity Scan - most of these are not an issue and a
couple of them are coverity getting really confused (like seeing a
pointer being assigned to NULL and a count to 0, then a few lines
later declaring that a loop 0..count will dereference the pointer).
* However it's harmless in all cases to add a bit of robustness to keep
the analysis happy.
* The Qt behaviour is that if you call setMinimumSize on a widget, then
the minimumSizeHint is IGNORED. So it is impossible to say "use this
minimum size, unless the widget wants a higher minimum size".
* So instead we do this ourselves in RDLabel. Sigh.
* This item delegate will forward on either to a specified other
delegate or to the base implementation. This allows chaining delegates
(i.e. having one built-in to the widget, which forwards to a user-set
delegate).
* The basic idea here is to have a reasonable middleground between
ResizeToContents and Stretch. We want to show at *least* enough for
the contents, but the remaining space should be shared between the
columns according to some proportions.
* That way you don't end up with one huge column and several tiny ones
that are just big enough but no more, but all data is still visible.
* This prevents a feedback loop where the label resizes wider to make
room for the margins, then the margins get bigger to keep the image
centred/scaled properly, etc.
* This is used primarily for the buffer/mesh viewer to be able to pin
the index/element column to the left side, group columns together with
a noticeable separator, and other minor tweaks.
* Unfortunately due to tight private coupling and lack of virtual
functions in the QTableView and QHeaderView, a few unrelated functions
have to be re-implemented to point to our own header.
* This means that e.g. right clicking on an item in a list/tree widget
will make sure it's selected before trying to display a context menu
or anything.
There are a few places where the logical 'and' operator
was used to check if a given flag is enabled however
that is not the correct operator.
The binary 'and' operator should be used where
the enum acts as a flag.
* Annoyingly although Qt has an internal bool allowUserMoveOfSection0
which does exactly what we want allowing the tree column to be
movable, we can't enable it because it's private. So instead we have
to re-implement section moving ourselves.
* Minor tweak - also made RDTreeWidgets non-movable by default since
usually we don't want to allow it.