on xenial help sign in
Because FilterGrid doesn't like LimitProxyModel.
commitb4bc0473e9e93f7d9beb80b3209413f8efc20c9e authorMichał Karnicki <michal.karnicki@canonical.com> dateWed 29 Jan 2014, 03:21 (13 years ago) parent164304c
2 files changed+27−17
qml/Components/FilterGrid.qml+1−2 tests/qmltests/Components/tst_FilterGrid.qml+26−15
qml/Components/FilterGrid.qml+1−2
@@ -47,8 +47,7 @@ Item {
4747 }
4848 property int uncollapsedRowCount: Math.ceil(model.count / columns)
4949 readonly property int collapsedHeight: {
50− return iconTileGrid.contentHeightForRows(Math.min(
51− rowsWhenCollapsed, Math.ceil(model.count / columns)))
50+ return iconTileGrid.contentHeightForRows(rowsWhenCollapsed)
5251 }
5352 readonly property int uncollapsedHeight: {
5453 return iconTileGrid.contentHeightForRows(uncollapsedRowCount)
tests/qmltests/Components/tst_FilterGrid.qml+26−15
@@ -81,10 +81,18 @@ Rectangle {
8181 ListElement { name: "L" }
8282 }
8383
84− LimitProxyModel {
85− id: limitedFakeModel
86− model: fakeModel
87− limit: modelCountLimitSelector.values[modelCountLimitSelector.selectedIndex]
84+ ListModel {
85+ id: fakeModelTwoItems
86+ ListElement { name: "A" }
87+ ListElement { name: "B" }
88+ }
89+
90+ ListModel {
91+ id: fakeModelFourItems
92+ ListElement { name: "A" }
93+ ListElement { name: "B" }
94+ ListElement { name: "C" }
95+ ListElement { name: "D" }
8896 }
8997
9098 Rectangle {
@@ -98,7 +106,7 @@ Rectangle {
98106 FilterGrid {
99107 id: filterGrid
100108 anchors.fill: parent
101− model: limitedFakeModel
109+ model: fakeModel
102110 maximumNumberOfColumns: 3
103111 collapsedRowCount:
104112 collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
@@ -128,7 +136,7 @@ Rectangle {
128136 when: windowShown
129137
130138 function test_turningFilterOffShowsAllElements() {
131− modelCountLimitSelector.selectedIndex = 4 // all items
139+ filterGrid.model = fakeModel
132140 tryCompareFunction(countVisibleDelegates, 6)
133141
134142 filterCheckBox.checked = false
@@ -140,7 +148,7 @@ Rectangle {
140148 }
141149
142150 function test_collapsedRowCount() {
143− modelCountLimitSelector.selectedIndex = 4 // all items
151+ filterGrid.model = fakeModel
144152
145153 for (var i = 0; i < 4; ++i) {
146154 collapsedRowCountSelector.selectedIndex = i
@@ -155,19 +163,22 @@ Rectangle {
155163
156164 function test_modelSizeAffectsCollapsedRowCount_data() {
157165 var data = new Array()
158− data.push({modelLimitIndex: 3, rowsWhenCollapsed: 2, visibleDelegates: 6})
159− data.push({modelLimitIndex: 2, rowsWhenCollapsed: 2, visibleDelegates: 4})
160− data.push({modelLimitIndex: 1, rowsWhenCollapsed: 1, visibleDelegates: 3})
161− data.push({modelLimitIndex: 1, rowsWhenCollapsed: 1, visibleDelegates: 3})
162− data.push({modelLimitIndex: 0, rowsWhenCollapsed: 1, visibleDelegates: 1})
166+ data.push({ model: fakeModelTwoItems, collapsedRowCountIndex: 0,
167+ rowsWhenCollapsed: 1, visibleDelegates: 2 })
168+ data.push({ model: fakeModelTwoItems, collapsedRowCountIndex: 1,
169+ rowsWhenCollapsed: 1, visibleDelegates: 2 })
170+ data.push({ model: fakeModelFourItems, collapsedRowCountIndex: 0,
171+ rowsWhenCollapsed: 1, visibleDelegates: 3 })
172+ data.push({ model: fakeModelFourItems, collapsedRowCountIndex: 1,
173+ rowsWhenCollapsed: 2, visibleDelegates: 4 })
163174 return data
164175 }
165176
166177 function test_modelSizeAffectsCollapsedRowCount(data) {
167− collapsedRowCountSelector.selectedIndex = 1 // 2 rows
178+ filterGrid.model = data.model
179+ collapsedRowCountSelector.selectedIndex = data.collapsedRowCountIndex
168180
169− modelCountLimitSelector.selectedIndex = data.modelLimitIndex
170− compare(filterGrid.rowsWhenCollapsed, data.rowsWhenCollapsed)
181+ tryCompare(filterGrid, "rowsWhenCollapsed", data.rowsWhenCollapsed)
171182 tryCompareFunction(countVisibleDelegates, data.visibleDelegates)
172183 }
173184