DropDownDynamicMenu.qml 726 Bytes
Newer Older
1 2
import Utils 1.0

3 4 5 6
// ===================================================================
// Menu which supports `ListView`.
// ===================================================================

7
AbstractDropDownMenu {
8 9
  // Can be computed, but for performance usage, it must be given
  // in attribute.
10 11 12 13
  property int entryHeight
  property int maxMenuHeight

  function _computeHeight () {
14 15 16 17 18 19 20 21 22 23
    var list = _content[0]

    Utils.assert(list != null, 'No list found.')
    Utils.assert(
      Utils.qmlTypeof(list, 'QQuickListView'),
      'No list view parameter.'
    )

    var height = list.count * entryHeight

24 25 26 27 28
    return (maxMenuHeight !== undefined && height > maxMenuHeight)
      ? maxMenuHeight
      : height
  }
}