fix(StatusCommunityTags): fix width calculation
This commit is contained in:
parent
7071a29700
commit
bc0db0a632
|
@ -13,21 +13,23 @@ Item {
|
||||||
property alias model: repeater.model
|
property alias model: repeater.model
|
||||||
property alias contentWidth: flow.width
|
property alias contentWidth: flow.width
|
||||||
|
|
||||||
|
readonly property int itemsWidth: {
|
||||||
|
let result = 0;
|
||||||
|
for (let i = 0; i < repeater.count; ++i) {
|
||||||
|
result += flow.spacing + repeater.itemAt(i).width;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
signal clicked(var item)
|
signal clicked(var item)
|
||||||
|
|
||||||
implicitWidth: flow.implicitWidth
|
implicitWidth: itemsWidth
|
||||||
implicitHeight: flow.implicitHeight
|
implicitHeight: flow.height
|
||||||
|
|
||||||
Flow {
|
Flow {
|
||||||
id: flow
|
id: flow
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
width: {
|
width: Math.min(parent.width, root.itemsWidth);
|
||||||
let itemsWidth = 0;
|
|
||||||
for (let i = 0; i < repeater.count; ++i) {
|
|
||||||
itemsWidth += spacing + repeater.itemAt(i).width;
|
|
||||||
}
|
|
||||||
return Math.min(parent.width, itemsWidth);
|
|
||||||
}
|
|
||||||
spacing: 10
|
spacing: 10
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -38,7 +40,7 @@ Item {
|
||||||
name: model.name
|
name: model.name
|
||||||
visible: (root.showOnlySelected ? model.selected : !model.selected) &&
|
visible: (root.showOnlySelected ? model.selected : !model.selected) &&
|
||||||
(filterString == 0 || name.toUpperCase().indexOf(filterString.toUpperCase()) !== -1)
|
(filterString == 0 || name.toUpperCase().indexOf(filterString.toUpperCase()) !== -1)
|
||||||
width: visible ? implicitWidth : -10
|
width: visible ? implicitWidth : -flow.spacing
|
||||||
height: visible ? implicitHeight : 0
|
height: visible ? implicitHeight : 0
|
||||||
removable: root.showOnlySelected && root.active
|
removable: root.showOnlySelected && root.active
|
||||||
onClicked: root.clicked(model)
|
onClicked: root.clicked(model)
|
||||||
|
|
Loading…
Reference in New Issue