Skip to content

Commit

Permalink
qml: set content height when orientation is horizontal in ListViewExt
Browse files Browse the repository at this point in the history
We were already setting the content width, primarily for vertical
list view. However, there is no restriction as such that ListViewExt
can not be used in horizontal orientation.

By default, list view does not estimate content height when the
orientation is horizontal. However, in most cases if not all, the
delegate uses the content size to set its size. For example, in a
vertical list view, it is sensible that the delegate uses content
width to determine its width.

If the delegate does not set its width when orientation is vertical,
or height when orientation is horizontal based on content width and
height, respectively, then it is the view's responsibility to override
the content size.
  • Loading branch information
fuzun authored and fcartegnie committed Aug 31, 2024
1 parent 0dd936d commit 8bf7ebe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/gui/qt/widgets/qml/ListViewExt.qml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ ListView {
section.criteria: ViewSection.FullString
section.delegate: sectionHeading

// Content width is set to the width by default
// Content size is set to the size by default
// If the delegate does not obey it, calculate
// the content width appropriately.
// the content size appropriately.
contentWidth: (orientation === ListView.Vertical) ? width - (leftMargin + rightMargin) : -1
contentHeight: (orientation === ListView.Horizontal) ? height - (topMargin + bottomMargin) : -1

footer: !!root.acceptDropFunc ? footerDragAccessoryComponent : null

Expand Down

0 comments on commit 8bf7ebe

Please sign in to comment.