From 0c5a9537c1aeb60223fbf1d0f5df62cfa901a48d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 12 Mar 2014 19:12:26 +0100 Subject: 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 Reviewed-by: J-P Nurmi --- src/controls/Private/ColumnMenuContent.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/controls/Private') 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 -- cgit v1.2.1