summaryrefslogtreecommitdiff
path: root/src/controls/Private
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@digia.com>2014-03-12 19:12:26 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-13 15:05:48 +0100
commit0c5a9537c1aeb60223fbf1d0f5df62cfa901a48d (patch)
tree8cd9360c6647c1daa30043d16cb741380387f7b9 /src/controls/Private
parent9f5d2093cb53fb5c322ebf8c319db520ae043eb9 (diff)
downloadqtquickcontrols-0c5a9537c1aeb60223fbf1d0f5df62cfa901a48d.tar.gz
Menu: Estimate item height from first visible item
The first item could be hidden, or not a normal item, thus returning an unproper height. The consequence in the reported issue being that the popup's maximum height would be that of a scroll indicator. Task-number: QTBUG-37445 Change-Id: Ib06d25643cd11224d5eab0452dadd0f6d4119fb9 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/Private')
-rw-r--r--src/controls/Private/ColumnMenuContent.qml14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/controls/Private/ColumnMenuContent.qml b/src/controls/Private/ColumnMenuContent.qml
index 41d5bbb0..ab197bb9 100644
--- a/src/controls/Private/ColumnMenuContent.qml
+++ b/src/controls/Private/ColumnMenuContent.qml
@@ -63,7 +63,19 @@ Item {
readonly property int currentIndex: __menu.__currentIndex
property Item currentItem: null
- readonly property int itemHeight: (list.count > 0 && list.contentItem.children[0]) ? list.contentItem.children[0].height : 23
+ property int itemHeight: 23
+
+ Component.onCompleted: {
+ var children = list.contentItem.children
+ for (var i = 0; i < list.count; i++) {
+ var child = children[i]
+ if (child.visible && child.styleData.type === MenuItemType.Item) {
+ itemHeight = children[i].height
+ break
+ }
+ }
+ }
+
readonly property int fittingItems: Math.floor((maxHeight - downScroller.height) / itemHeight)
readonly property real fittedMaxHeight: itemHeight * fittingItems + downScroller.height
readonly property bool shouldUseScrollers: scrollView.style === emptyScrollerStyle && itemsModel.length > fittingItems