on xenial help sign in
Because FilterGrid doesn't like LimitProxyModel.
b4bc047Michał Karnicki
qml/Components/FilterGrid.qml+1−2
@@ -47,8 +47,7 @@ Item {
47 }
47 }
48 property int uncollapsedRowCount: Math.ceil(model.count / columns)
48 property int uncollapsedRowCount: Math.ceil(model.count / columns)
49 readonly property int collapsedHeight: {
49 readonly property int collapsedHeight: {
50− return iconTileGrid.contentHeightForRows(Math.min(
50+ return iconTileGrid.contentHeightForRows(rowsWhenCollapsed)
51− rowsWhenCollapsed, Math.ceil(model.count / columns)))
52 }
51 }
53 readonly property int uncollapsedHeight: {
52 readonly property int uncollapsedHeight: {
54 return iconTileGrid.contentHeightForRows(uncollapsedRowCount)
53 return iconTileGrid.contentHeightForRows(uncollapsedRowCount)
tests/qmltests/Components/tst_FilterGrid.qml+26−15
@@ -81,10 +81,18 @@ Rectangle {
81 ListElement { name: "L" }
81 ListElement { name: "L" }
82 }
82 }
83
83
84− LimitProxyModel {
84+ ListModel {
85− id: limitedFakeModel
85+ id: fakeModelTwoItems
86− model: fakeModel
86+ ListElement { name: "A" }
87− limit: modelCountLimitSelector.values[modelCountLimitSelector.selectedIndex]
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" }
88 }
96 }
89
97
90 Rectangle {
98 Rectangle {
@@ -98,7 +106,7 @@ Rectangle {
98 FilterGrid {
106 FilterGrid {
99 id: filterGrid
107 id: filterGrid
100 anchors.fill: parent
108 anchors.fill: parent
101− model: limitedFakeModel
109+ model: fakeModel
102 maximumNumberOfColumns: 3
110 maximumNumberOfColumns: 3
103 collapsedRowCount:
111 collapsedRowCount:
104 collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
112 collapsedRowCountSelector.values[collapsedRowCountSelector.selectedIndex]
@@ -128,7 +136,7 @@ Rectangle {
128 when: windowShown
136 when: windowShown
129
137
130 function test_turningFilterOffShowsAllElements() {
138 function test_turningFilterOffShowsAllElements() {
131− modelCountLimitSelector.selectedIndex = 4 // all items
139+ filterGrid.model = fakeModel
132 tryCompareFunction(countVisibleDelegates, 6)
140 tryCompareFunction(countVisibleDelegates, 6)
133
141
134 filterCheckBox.checked = false
142 filterCheckBox.checked = false
@@ -140,7 +148,7 @@ Rectangle {
140 }
148 }
141
149
142 function test_collapsedRowCount() {
150 function test_collapsedRowCount() {
143− modelCountLimitSelector.selectedIndex = 4 // all items
151+ filterGrid.model = fakeModel
144
152
145 for (var i = 0; i < 4; ++i) {
153 for (var i = 0; i < 4; ++i) {
146 collapsedRowCountSelector.selectedIndex = i
154 collapsedRowCountSelector.selectedIndex = i
@@ -155,19 +163,22 @@ Rectangle {
155
163
156 function test_modelSizeAffectsCollapsedRowCount_data() {
164 function test_modelSizeAffectsCollapsedRowCount_data() {
157 var data = new Array()
165 var data = new Array()
166+ data.push({ model: fakeModelTwoItems, collapsedRowCountIndex: 0,
158− data.push({modelLimitIndex: 3, rowsWhenCollapsed: 2, visibleDelegates: 6})
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,
159− data.push({modelLimitIndex: 2, rowsWhenCollapsed: 2, visibleDelegates: 4})
173+ 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})
163 return data
174 return data
164 }
175 }
165
176
166 function test_modelSizeAffectsCollapsedRowCount(data) {
177 function test_modelSizeAffectsCollapsedRowCount(data) {
178+ filterGrid.model = data.model
167− collapsedRowCountSelector.selectedIndex = 1 // 2 rows
179+ collapsedRowCountSelector.selectedIndex = data.collapsedRowCountIndex
168
180
169− modelCountLimitSelector.selectedIndex = data.modelLimitIndex
170− compare(filterGrid.rowsWhenCollapsed, data.rowsWhenCollapsed)
181+ tryCompare(filterGrid, "rowsWhenCollapsed", data.rowsWhenCollapsed)
171 tryCompareFunction(countVisibleDelegates, data.visibleDelegates)
182 tryCompareFunction(countVisibleDelegates, data.visibleDelegates)
172 }
183 }
173
184