~cimi/unity8/card_touchdown

« back to all changes in this revision

Viewing changes to qml/Dash/DashDepartmentsList.qml

  • Committer: Andrea Cimitan
  • Date: 2014-06-24 09:54:02 UTC
  • mfrom: (917.6.36 unity8)
  • Revision ID: andrea.cimitan@gmail.com-20140624095402-gaw0o3l8y9fmoqhz
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)
[ Pawel Stolowski ]
* Extend the hack for click scope categories with the upcoming 'store'
  category: single-tap on results from the 'store' category should
  activate them, instead of requesting a preview. (LP: #1326292)
[ Albert Astals ]
* Drop the " Preview" suffix from Preview title As requested in
  https://bugs.launchpad.net/unity8/+bug/1316671 (LP: #1316671)
[ Michael Terry ]
* Revert split greeter for now.  We will bring it back as an option
  for Desktop, but use a big hammer revert right now to get Touch back
  in shape.
[ CI bot ]
* Fix build problems. Reviewed by: Michael Terry (LP: #1328850)
[ Michał Sawicz ]
* Make lockscreen buttons translatable.
[ Albert Astals ]
* Correctly mark these functions as overrides
* Remove connections to non existant signal
* Better test name
* Improvements for headerless categories LVPWH: No section name -> no
  header LVPWH: New hasSectionHeader context property for delegates
  GSV: Add topMargin if no hasSectionHeader (LP: #1326415)
* Make tryVerticalJournal, tryHorizontalJournal and tryOrganicGrid
  work again
[ Michael Zanetti ]
* Don't crash when we get an invalid app from ApplicationManager (LP:
  #1309162)
[ Andrea Cimitan ]
* Workaround for lp1324159 (LP: #1322233, #1324159)
[ CI bot ]
* Resync trunk
[ Florian Boucault ]
* Application startup: changed splash rectangle to be black instead of
  white and added a neat little animation. (LP: #1124265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
import QtQuick 2.2
 
18
import Ubuntu.Components 0.1
 
19
 
 
20
Item {
 
21
    id: root
 
22
    property var department: null
 
23
    property var currentDepartment: null
 
24
    signal enterDepartment(var newDepartmentId, bool hasChildren)
 
25
    signal goBackToParentClicked()
 
26
    signal allDepartmentClicked()
 
27
 
 
28
    readonly property int itemHeight: units.gu(5)
 
29
    implicitHeight: flickable.contentHeight
 
30
 
 
31
    Rectangle {
 
32
        color: "white"
 
33
        anchors.fill: parent
 
34
    }
 
35
 
 
36
    ActivityIndicator {
 
37
        id: loadingIndicator
 
38
        anchors.centerIn: parent
 
39
        running: !(department && department.loaded)
 
40
    }
 
41
    clip: true
 
42
 
 
43
    Behavior on height {
 
44
        UbuntuNumberAnimation {
 
45
            id: heightAnimation
 
46
            duration: UbuntuAnimation.SnapDuration
 
47
        }
 
48
    }
 
49
 
 
50
    Flickable {
 
51
        id: flickable
 
52
 
 
53
        anchors.fill: parent
 
54
 
 
55
        contentHeight: column.height
 
56
        contentWidth: width
 
57
 
 
58
        Column {
 
59
            id: column
 
60
            width: parent.width
 
61
 
 
62
            // TODO: check if SDK ListItems could be used here
 
63
            // and if not make them be useful since this is a quite common pattern
 
64
 
 
65
            AbstractButton {
 
66
                id: backButton
 
67
                objectName: "backButton"
 
68
                width: parent.width
 
69
                visible: department && !department.isRoot || false
 
70
                height: itemHeight
 
71
 
 
72
                onClicked: root.goBackToParentClicked();
 
73
 
 
74
                Image {
 
75
                    id: backImage
 
76
                    anchors {
 
77
                        verticalCenter: parent.verticalCenter
 
78
                        left: parent.left
 
79
                        leftMargin: units.gu(2)
 
80
                    }
 
81
                    source: "image://theme/back"
 
82
                    sourceSize.height: parent.height - units.gu(3)
 
83
                    sourceSize.width: units.gu(3)
 
84
                    fillMode: Image.PreserveAspectFit
 
85
                }
 
86
 
 
87
                Label {
 
88
                    anchors {
 
89
                        verticalCenter: parent.verticalCenter
 
90
                        left: backImage.right
 
91
                        leftMargin: units.gu(0.5)
 
92
                    }
 
93
                    text: department ? department.parentLabel : ""
 
94
                    color: "gray" // TODO remove once we're a separate app
 
95
                }
 
96
 
 
97
                Rectangle {
 
98
                    anchors {
 
99
                        bottom: parent.bottom
 
100
                        left: parent.left
 
101
                        right: parent.right
 
102
                        leftMargin: units.gu(2)
 
103
                        rightMargin: units.gu(2)
 
104
                    }
 
105
                    color: "gray"
 
106
                    opacity: 0.2
 
107
                    height: units.dp(1)
 
108
                }
 
109
            }
 
110
 
 
111
            AbstractButton {
 
112
                id: allButton
 
113
                objectName: "allButton"
 
114
                width: parent.width
 
115
                visible: department && (!department.isRoot || (root.currentDepartment && !root.currentDepartment.isRoot && root.currentDepartment.parentDepartmentId == department.departmentId)) || false
 
116
                height: itemHeight
 
117
 
 
118
                Label {
 
119
                    anchors {
 
120
                        verticalCenter: parent.verticalCenter
 
121
                        left: parent.left
 
122
                        leftMargin: units.gu(2)
 
123
                    }
 
124
                    text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
 
125
                    font.bold: true
 
126
                    color: "gray" // TODO remove once we're a separate app
 
127
                }
 
128
 
 
129
                Rectangle {
 
130
                    anchors {
 
131
                        bottom: parent.bottom
 
132
                        left: parent.left
 
133
                        right: parent.right
 
134
                        leftMargin: units.gu(2)
 
135
                        rightMargin: units.gu(2)
 
136
                    }
 
137
                    color: "gray"
 
138
                    opacity: 0.2
 
139
                    height: units.dp(1)
 
140
                }
 
141
 
 
142
                onClicked: root.allDepartmentClicked();
 
143
            }
 
144
 
 
145
            Repeater {
 
146
                model: department && department.loaded ? department : null
 
147
                clip: true
 
148
                delegate: AbstractButton {
 
149
                    objectName: root.objectName + "child" + index
 
150
                    height: root.itemHeight
 
151
                    width: root.width
 
152
 
 
153
                    onClicked: root.enterDepartment(departmentId, hasChildren)
 
154
 
 
155
                    Label {
 
156
                        anchors {
 
157
                            verticalCenter: parent.verticalCenter
 
158
                            left: parent.left
 
159
                            leftMargin: units.gu(2)
 
160
                        }
 
161
                        text: label
 
162
                        color: "gray" // TODO remove once we're a separate app
 
163
                    }
 
164
 
 
165
                    Image {
 
166
                        anchors {
 
167
                            verticalCenter: parent.verticalCenter
 
168
                            right: parent.right
 
169
                            rightMargin: units.gu(2)
 
170
                        }
 
171
                        source: hasChildren ? "image://theme/chevron" : "graphics/tick.png"
 
172
                        sourceSize.height: parent.height - units.gu(3)
 
173
                        sourceSize.width: units.gu(3)
 
174
                        fillMode: Image.PreserveAspectFit
 
175
                        visible: hasChildren || isActive
 
176
                    }
 
177
 
 
178
                    Rectangle {
 
179
                        anchors {
 
180
                            bottom: parent.bottom
 
181
                            left: parent.left
 
182
                            right: parent.right
 
183
                            leftMargin: units.gu(2)
 
184
                            rightMargin: units.gu(2)
 
185
                        }
 
186
                        color: "gray"
 
187
                        opacity: 0.1
 
188
                        height: units.dp(1)
 
189
                        visible: index != department.count - 1
 
190
                    }
 
191
                }
 
192
            }
 
193
        }
 
194
    }
 
195
}