on xenial help sign in
Use a Column
commit2fdcd1fe31647a23a94556937556d2bb99667e1f authorAlbert Astals <albert.astals@canonical.com> dateThu 19 Jun 2014, 11:54 (12 years ago) parentc790b14
1 file changed+102−101
qml/Dash/DashDepartmentsList.qml+102−101
qml/Dash/DashDepartmentsList.qml+102−101
@@ -52,122 +52,68 @@ Item {
5252
5353 anchors.fill: parent
5454
55− readonly property int nTopButtonsVisible: 0 + (backButton.visible ? 1 : 0) + (allButton.visible ? 1 : 0)
56− readonly property int nItems: department && department.loaded ? (department.count + nTopButtonsVisible) : 0
57− contentHeight: nItems * root.itemHeight
55+ contentHeight: column.height
5856 contentWidth: width
5957
60− AbstractButton {
61− id: backButton
62− objectName: "backButton"
58+ Column {
59+ id: column
6360 width: parent.width
64− visible: department && !department.isRoot || false
65− height: visible ? itemHeight : 0
66−
67− onClicked: root.goBackToParentClicked();
68−
69− Image {
70− id: backImage
71− anchors.verticalCenter: parent.verticalCenter
72− anchors.left: parent.left
73− anchors.leftMargin: units.gu(2)
74− source: "image://theme/back"
75− sourceSize.height: parent.height - units.gu(3)
76− sourceSize.width: units.gu(3)
77− fillMode: Image.PreserveAspectFit
78− }
79−
80− Label {
81− anchors.verticalCenter: parent.verticalCenter
82− anchors.left: backImage.right
83− anchors.leftMargin: units.gu(0.5)
84− text: department ? department.parentLabel : ""
85− color: "gray" // TODO remove once we're a separate app
86− }
8761
88− Rectangle {
89− anchors.bottom: parent.bottom
90− anchors.left: parent.left
91− anchors.right: parent.right
92− anchors.leftMargin: units.gu(2)
93− anchors.rightMargin: units.gu(2)
62+ AbstractButton {
63+ id: backButton
64+ objectName: "backButton"
9465 width: parent.width
95− color: "gray"
96− opacity: 0.2
97− height: units.dp(1)
98− }
99− }
100−
101− AbstractButton {
102− id: allButton
103− objectName: "allButton"
104− anchors.top: backButton.bottom
105− width: parent.width
106− visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentDepartmentId == department.departmentId)) || false
107− height: itemHeight
108−
109− Label {
110− anchors.verticalCenter: parent.verticalCenter
111− anchors.left: parent.left
112− anchors.leftMargin: units.gu(2)
113− text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
114− font.bold: true
115− color: "gray" // TODO remove once we're a separate app
116− }
117−
118− Rectangle {
119− anchors.bottom: parent.bottom
120− anchors.left: parent.left
121− anchors.right: parent.right
122− anchors.leftMargin: units.gu(2)
123− anchors.rightMargin: units.gu(2)
124− width: parent.width
125− color: "gray"
126− opacity: 0.2
127− height: units.dp(1)
128− }
129−
130− onClicked: root.allDepartmentClicked();
131− }
66+ visible: department && !department.isRoot || false
67+ height: itemHeight
13268
133− Repeater {
134− model: department && department.loaded ? department : null
135− clip: true
136− delegate: AbstractButton {
137− objectName: root.objectName + "child" + index
138− height: root.itemHeight
139− width: root.width
140− y: (flickable.nTopButtonsVisible + index) * root.itemHeight
69+ onClicked: root.goBackToParentClicked();
14170
142− onClicked: root.enterDepartment(departmentId, hasChildren)
143−
144− Label {
71+ Image {
72+ id: backImage
14573 anchors.verticalCenter: parent.verticalCenter
14674 anchors.left: parent.left
14775 anchors.leftMargin: units.gu(2)
148− text: label
149− color: "gray" // TODO remove once we're a separate app
150− }
151−
152− Image {
153− anchors.verticalCenter: parent.verticalCenter
154− anchors.right: parent.right
155− anchors.rightMargin: units.gu(2)
156− source: "image://theme/chevron"
76+ source: "image://theme/back"
15777 sourceSize.height: parent.height - units.gu(3)
15878 sourceSize.width: units.gu(3)
15979 fillMode: Image.PreserveAspectFit
160− visible: hasChildren
16180 }
162− Image {
81+
82+ Label {
16383 anchors.verticalCenter: parent.verticalCenter
84+ anchors.left: backImage.right
85+ anchors.leftMargin: units.gu(0.5)
86+ text: department ? department.parentLabel : ""
87+ color: "gray" // TODO remove once we're a separate app
88+ }
89+
90+ Rectangle {
91+ anchors.bottom: parent.bottom
92+ anchors.left: parent.left
16493 anchors.right: parent.right
94+ anchors.leftMargin: units.gu(2)
16595 anchors.rightMargin: units.gu(2)
166− source: "graphics/tick.png"
167− sourceSize.height: parent.height - units.gu(2)
168− sourceSize.width: units.gu(3)
169− fillMode: Image.PreserveAspectFit
170− visible: !hasChildren && isActive
96+ width: parent.width
97+ color: "gray"
98+ opacity: 0.2
99+ height: units.dp(1)
100+ }
101+ }
102+
103+ AbstractButton {
104+ id: allButton
105+ objectName: "allButton"
106+ width: parent.width
107+ visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentDepartmentId == department.departmentId)) || false
108+ height: itemHeight
109+
110+ Label {
111+ anchors.verticalCenter: parent.verticalCenter
112+ anchors.left: parent.left
113+ anchors.leftMargin: units.gu(2)
114+ text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
115+ font.bold: true
116+ color: "gray" // TODO remove once we're a separate app
171117 }
172118
173119 Rectangle {
@@ -178,9 +124,64 @@ Item {
178124 anchors.rightMargin: units.gu(2)
179125 width: parent.width
180126 color: "gray"
181− opacity: 0.1
127+ opacity: 0.2
182128 height: units.dp(1)
183− visible: index != department.count - 1
129+ }
130+
131+ onClicked: root.allDepartmentClicked();
132+ }
133+
134+ Repeater {
135+ model: department && department.loaded ? department : null
136+ clip: true
137+ delegate: AbstractButton {
138+ objectName: root.objectName + "child" + index
139+ height: root.itemHeight
140+ width: root.width
141+
142+ onClicked: root.enterDepartment(departmentId, hasChildren)
143+
144+ Label {
145+ anchors.verticalCenter: parent.verticalCenter
146+ anchors.left: parent.left
147+ anchors.leftMargin: units.gu(2)
148+ text: label
149+ color: "gray" // TODO remove once we're a separate app
150+ }
151+
152+ Image {
153+ anchors.verticalCenter: parent.verticalCenter
154+ anchors.right: parent.right
155+ anchors.rightMargin: units.gu(2)
156+ source: "image://theme/chevron"
157+ sourceSize.height: parent.height - units.gu(3)
158+ sourceSize.width: units.gu(3)
159+ fillMode: Image.PreserveAspectFit
160+ visible: hasChildren
161+ }
162+ Image {
163+ anchors.verticalCenter: parent.verticalCenter
164+ anchors.right: parent.right
165+ anchors.rightMargin: units.gu(2)
166+ source: "graphics/tick.png"
167+ sourceSize.height: parent.height - units.gu(2)
168+ sourceSize.width: units.gu(3)
169+ fillMode: Image.PreserveAspectFit
170+ visible: !hasChildren && isActive
171+ }
172+
173+ Rectangle {
174+ anchors.bottom: parent.bottom
175+ anchors.left: parent.left
176+ anchors.right: parent.right
177+ anchors.leftMargin: units.gu(2)
178+ anchors.rightMargin: units.gu(2)
179+ width: parent.width
180+ color: "gray"
181+ opacity: 0.1
182+ height: units.dp(1)
183+ visible: index != department.count - 1
184+ }
184185 }
185186 }
186187 }