forked from iBelieve/ubuntu-ui-extras
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table.qml
227 lines (188 loc) · 7.65 KB
/
Table.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/***************************************************************************
* Whatsoever ye do in word or deed, do all in the name of the *
* Lord Jesus, giving thanks to God and the Father by him. *
* - Colossians 3:17 *
* *
* Ubuntu UI Extras - A collection of QML widgets not available *
* in the default Ubuntu UI Toolkit *
* Copyright (C) 2013 Michael Spencer <sonrisesoftware@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
import QtQuick 2.0
import Ubuntu.Components 1.1
import Ubuntu.Components.ListItems 1.0 as ListItem
Item {
id: root
property var columnHeaders: []
property var rowHeaders: []
property int columnCount: columnHeaders.length
property int rowCount: rowHeaders.length
property var model: []
property var delegate
property int cellWidth: (root.width - headerWidth)/columnCount
property int cellHeight: (root.height - headerHeight)/rowCount
property int headerWidth: units.gu(4)
property int headerHeight: units.gu(4)
property color color: "white"
property int radius: units.gu(2)
property var modelCompleted: []
Rectangle {
anchors {
left: parent.left
right: parent.right
top: parent.top
leftMargin: root.headerWidth
}
height: headerHeight * 3
radius: root.radius
antialiasing: true
}
Rectangle {
anchors {
left: parent.left
bottom: parent.bottom
top: parent.top
topMargin: root.headerHeight
}
width: headerWidth * 3
radius: root.radius
antialiasing: true
}
Rectangle {
anchors {
left: parent.left
bottom: parent.bottom
top: parent.top
right: parent.right
topMargin: root.headerHeight
leftMargin: root.headerWidth
}
radius: root.radius
antialiasing: true
}
Repeater {
model: columnCount
delegate: Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
topMargin: index === 0 ? root.headerHeight : 0
}
width: 1
color: UbuntuColors.warmGrey
x: (index) * cellWidth + headerWidth
}
}
Column {
anchors.fill: parent
Row {
anchors {
left: parent.left
leftMargin: root.headerWidth
}
Repeater {
id: headerRepeater
model: root.columnHeaders
delegate: Label {
width: cellWidth
horizontalAlignment: Text.AlignHCenter
text: modelData
color: UbuntuColors.coolGrey
height: root.headerHeight
verticalAlignment: Text.AlignVCenter
}
}
}
Repeater {
model: root.rowCount
delegate: Column {
anchors {
left: parent.left
right: parent.right
}
property int row: index
Rectangle {
anchors {
left: parent.left
right: parent.right
leftMargin: index === 0 ? root.headerWidth : 0
}
height: 1
color: UbuntuColors.warmGrey
}
Row {
Item {
width: root.headerWidth
height: root.cellHeight
Label {
text: rowHeaders[index]
anchors.centerIn: parent
color: UbuntuColors.coolGrey
rotation: -90
}
}
Repeater {
id: rowRepeater
model: columnCount
delegate: Item {
height: root.cellHeight
width: root.cellWidth
property bool done: false
MouseArea {
anchors.fill: parent
onClicked: done = !done
}
Label {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: root.model[row][index]
color: UbuntuColors.coolGrey
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
opacity: done ? 0.2 : 1
Behavior on opacity {
UbuntuNumberAnimation {}
}
}
Rectangle {
anchors.centerIn: parent
rotation: -180/Math.PI * Math.atan(parent.height/parent.width)
width: Math.sqrt(parent.height * parent.height + parent.width * parent.width)
height: 1
color: UbuntuColors.warmGrey
antialiasing: true
smooth: true
opacity: done ? 1 : 0
Behavior on opacity {
UbuntuNumberAnimation {}
}
}
// Rectangle {
// anchors.centerIn: parent
// rotation: 180/Math.PI * Math.atan(parent.height/parent.width)
// width: Math.sqrt(parent.height * parent.height + parent.width * parent.width)
// height: 1
// color: UbuntuColors.warmGrey
// antialiasing: true
// smooth: true
// visible: done
// }
}
}
}
}
}
}
}