moment/src/gui/Base/HRepeater.qml

40 lines
1.0 KiB
QML
Raw Normal View History

// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
2019-12-19 22:46:16 +11:00
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick.Controls 2.12
import QtQuick 2.12
Repeater {
id: repeater
2019-12-20 06:56:07 +11:00
readonly property var childrenImplicitWidth: {
const widths = []
for (let i = 0; i < repeater.count; i++) {
const item = repeater.itemAt(i)
if (item)
widths.push(item.implicitWidth > 0 ? item.implicitWidth : 0)
}
2019-12-20 06:56:07 +11:00
return widths
}
2019-12-20 06:56:07 +11:00
readonly property var childrenWidth: {
const widths = []
2019-12-20 06:56:07 +11:00
for (let i = 0; i < repeater.count; i++) {
const item = repeater.itemAt(i)
if (item) widths.push(item.width > 0 ? item.width : 0)
}
2019-12-20 06:56:07 +11:00
return widths
}
2019-12-20 06:56:07 +11:00
readonly property real summedWidth: utils.sum(childrenWidth)
readonly property real summedImplicitWidth:utils.sum(childrenImplicitWidth)
readonly property real thinestChild: Math.min(...childrenWidth)
readonly property real widestChild: Math.max(...childrenWidth)
}