-
Notifications
You must be signed in to change notification settings - Fork 15
/
ListsList.qml
325 lines (266 loc) · 12.9 KB
/
ListsList.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
import QtQuick 1.1
import "Storage.js" as Storage
Rectangle {
id: root
property alias tasks_lists_listmodel: tasks_lists_listmodel
property alias tasks_lists_listview: tasks_lists_listview
property alias new_task_list_button: new_task_list
color: styl.panel_back_color
Button {
id: new_task_list
width: parent.width - 10
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
topMargin: 5
}
buttontext: "New List of Tasks"
button_ma.onClicked: {
helppomodoro.state = "";
overlay.scale = 1
new_list_window_main.scale = 1
new_list_window_main.list_name.forceActiveFocus()
new_list_window_main.list_name.selectAll()
}
}
ListView {
id: tasks_lists_listview
width: parent.width
height: parent.height - new_task_list.height - divider_big.height - toolbarbottom.height - 15
anchors {
left: parent.left
top: new_task_list.bottom
topMargin: 5
}
spacing: 1
keyNavigationWraps: true
clip: true
header:
Item {
id: main_list_rectangle
property bool isCurrent: "123456789" == todo_list_timestamp
width: parent.width
height: main_list.height + 20
Behavior on height { NumberAnimation { duration: 100 }}
MenuButton {
id: header_list_menu
z: header_list_controls.z + 1
anchors {
top: parent.top
topMargin: 6
right: parent.right
rightMargin: 6
}
buttonma.onClicked: {
if (header_list_controls.opacity === 0){
header_list_menu.isActive = true
header_list_controls.delete_list.visible = false
header_list_controls.edit_list.visible = false
header_list_controls.height = header_list_controls.select_list_ma.height + 24
main_list_rectangle.height = main_list_rectangle.height + header_list_controls.height
header_list_controls.opacity = 1
}
else {
header_list_menu.isActive = false
main_list_rectangle.height = main_list_rectangle.height - header_list_controls.height
header_list_controls.height = 0
header_list_controls.opacity = 0;
}
}
}
ControlsWPList {
id: header_list_controls
opacity: 0
width: parent.width
anchors {
top: parent.top
}
select_list_ma.onClicked: {
main_list_rectangle.height = main_list_rectangle.height - header_list_controls.height
header_list_controls.height = 0
header_list_controls.opacity = 0;
main_list_rectangle_ma.clicked(true)
}
}
Text {
id: main_list
color: main_list_rectangle.isCurrent ? styl.info_text_color : styl.text_color_secondary
width: parent.width - 10
anchors {
left: parent.left
leftMargin: 12
top: header_list_controls.bottom
topMargin: 6
}
text: qsTr("ToDo List")
font {family: "Ubuntu"; pixelSize: 14}
MouseArea {
id: main_list_rectangle_ma
anchors.fill: parent
hoverEnabled: true
onClicked: {
todo_list_name.text = main_list.text;
todo_list_timestamp = "123456789"
todo_header.text = "Tasks";
listoftasks.opacity = 0
listoftasks.height = 0
todo_list_name_background.visible = true
todo_list_name_background.height = todo_list_name.height + 5
tasks_lists_listmodel.clear()
header_list_menu.isActive = false
Storage.checkIfSettingExist("todo_list_timestamp") == "true" ? Storage.updateSettings("todo_list_timestamp", todo_list_timestamp) :
Storage.saveSetting("todo_list_timestamp", todo_list_timestamp);
Storage.checkIfSettingExist("todo_list_name") == "true" ? Storage.updateSettings("todo_list_name", todo_list_name.text) :
Storage.saveSetting("todo_list_name", todo_list_name.text);
tasklist.todo_listmodel.clear();
if (controls_tasks_gen.hiddenfinished == false){
Storage.getTasksFromDB("123456789", tasklist.todo_listmodel);
if (todo_list_name.selected_task_color !== ""){
tasklist.todo_listmodel.clear();
Storage.getTasksWithColor("123456789", todo_list_name.selected_task_color, tasklist.todo_listmodel)
}
}
else if (controls_tasks_gen.hiddenfinished == true){
Storage.getNotFinishedTasksFromDB("123456789", false, tasklist.todo_listmodel);
if (todo_list_name.selected_task_color !== ""){
tasklist.todo_listmodel.clear();
Storage.getNotFinishedTasksWithColor("123456789", todo_list_name.selected_task_color, false, tasklist.todo_listmodel)
}
}
}
}
}
DividerSmallHor {
id: small_divider1
width: parent.width
anchors.bottom: parent.bottom
}
}
delegate:
Item {
id: list_item
property bool isCurrent: list_name.list_timestamp == todo_list_timestamp
Behavior on height { NumberAnimation { duration: 100 }}
width: parent.width
height: list_name.height + 20
MenuButton {
id: list_menu
z: list_controls.z + 1
anchors {
top: parent.top
topMargin: 6
right: parent.right
rightMargin: 6
}
buttonma.onClicked: {
if (list_controls.opacity === 0){
list_menu.isActive = true
tasks_lists_listview.currentIndex = index
list_controls.height = list_controls.delete_list_ma.height + list_controls.edit_list_ma.height + 24
list_item.height = list_item.height + list_controls.height
list_controls.opacity = 1
}
else {
list_menu.isActive = false
list_item.height = list_item.height - list_controls.height
list_controls.height = 0
list_controls.opacity = 0;
}
}
}
ControlsWPList {
id: list_controls
opacity: 0
width: parent.width
anchors {
top: parent.top
}
select_list_ma.onClicked: list_item_ma.clicked(true)
edit_list_ma.onClicked: {
helppomodoro.state = "";
tasks_lists_listview.currentIndex = index;
overlay.scale = 1;
edit_list_window_main.scale = 1;
edit_list_window_main.list_name.text = tasks_lists_listmodel.get(tasks_lists_listview.currentIndex).taskslistname
edit_list_window_main.list_name.forceActiveFocus();
edit_list_window_main.list_name.selectAll();
edit_list_window_main.list_name.listtimestamp = tasks_lists_listmodel.get(tasks_lists_listview.currentIndex).timestamp
}
delete_list_ma.onClicked: {
helppomodoro.state = "";
tasks_lists_listview.currentIndex = index;
overlay.scale = 1;
delete_list_confirm.scale = 1;
delete_list_confirm.thing_to_delete = listoftasks.tasks_lists_listmodel.get(listoftasks.tasks_lists_listview.currentIndex).taskslistname;
delete_list_confirm.cancel_button.focus = true
}
}
Text {
id: list_name
property string list_timestamp: timestamp
color: list_item.isCurrent ? styl.info_text_color : styl.text_color_secondary
width: parent.width - 10
anchors {
left: parent.left
leftMargin: 12
top: list_controls.bottom
topMargin: 6
}
text: taskslistname
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font {family: "Ubuntu"; pixelSize: 14}
MouseArea {
id: list_item_ma
anchors.fill: parent
onClicked: {
todo_list_name.text = list_name.text;
todo_list_timestamp = list_name.list_timestamp;
todo_header.text = "Tasks";
todo_list_name_background.visible = true
todo_list_name_background.height = todo_list_name.height + 5
listoftasks.opacity = 0;
listoftasks.height = 0;
list_menu.isActive = false;
Storage.checkIfSettingExist("todo_list_timestamp") == "true" ? Storage.updateSettings("todo_list_timestamp", todo_list_timestamp) :
Storage.saveSetting("todo_list_timestamp", todo_list_timestamp)
Storage.checkIfSettingExist("todo_list_name") == "true" ? Storage.updateSettings("todo_list_name", todo_list_name.text) :
Storage.saveSetting("todo_list_name", todo_list_name.text)
tasks_lists_listmodel.clear();
tasklist.todo_listmodel.clear();
if (controls_tasks_gen.hiddenfinished == false){
Storage.getTasksFromDB(list_name.list_timestamp, tasklist.todo_listmodel)
if (todo_list_name.selected_task_color !== ""){
tasklist.todo_listmodel.clear();
Storage.getTasksWithColor(list_name.list_timestamp, todo_list_name.selected_task_color, tasklist.todo_listmodel)
}
}
else if (controls_tasks_gen.hiddenfinished == true){
Storage.getNotFinishedTasksFromDB(list_name.list_timestamp, false, tasklist.todo_listmodel);
if (todo_list_name.selected_task_color !== ""){
tasklist.todo_listmodel.clear();
Storage.getNotFinishedTasksWithColor(list_name.list_timestamp, todo_list_name.selected_task_color, false, tasklist.todo_listmodel)
}
}
}
}
}
DividerSmallHor {
id: small_divider2
width: parent.width
anchors.bottom: parent.bottom
}
ListView.onAdd: SequentialAnimation {
PropertyAction { target: list_item; property: "scale"; value: 0 }
NumberAnimation { target: list_item; property: "scale"; to: 1; duration: 200; }
}
ListView.onRemove: SequentialAnimation {
PropertyAction { target: list_item; property: "ListView.delayRemove"; value: true }
NumberAnimation { target: list_item; property: "scale"; to: 0; duration: 200; }
PropertyAction { target: list_item; property: "ListView.delayRemove"; value: false }
}
}
model: ListModel {
id: tasks_lists_listmodel
}
}
}