2
* Copyright (C) 2015 Szymon Waliczek.
5
* Szymon Waliczek <majsterrr@gmail.com>
7
* This file is part of SocketWorld app for Ubuntu Touch
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as published by
11
* the Free Software Foundation; version 3.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24
import Ubuntu.Components 1.3
25
import Ubuntu.Components.Popups 1.0
26
//import QtQuick.XmlListModel 2.0
27
//import Ubuntu.Components.Pickers 0.1
28
//import "../backEnd/utils.js" as Utils
29
import "../components"
37
property string randomColor: "#ee6d00"
43
ListElement {colorBG: "#f44336"}
44
ListElement {colorBG: "#e91e63"}
45
ListElement {colorBG: "#9c27b0"}
46
ListElement {colorBG: "#673ab7"}
47
ListElement {colorBG: "#3f51b5"}
48
ListElement {colorBG: "#2196f3"}
49
ListElement {colorBG: "#03a9f4"}
50
ListElement {colorBG: "#00bcd4"}
51
ListElement {colorBG: "#009688"}
52
ListElement {colorBG: "#4caf50"}
53
ListElement {colorBG: "#8bc34a"}
54
ListElement {colorBG: "#cddc39"}
55
ListElement {colorBG: "#ffeb3b"}
56
ListElement {colorBG: "#ffc107"}
57
ListElement {colorBG: "#ff9800"}
58
ListElement {colorBG: "#ff5722"}
59
ListElement {colorBG: "#795548"}
60
ListElement {colorBG: "#9e9e9e"}
61
ListElement {colorBG: "#607d8b"}
74
onTriggered: addNewList()
79
text: "restart welcome"
80
// onTriggered: firstRunDoc.contents = { firstrun: "true" }
82
main_shopping_list_MODEL.addItemToList()
89
name: "multiselection"
95
root.state = "default"
96
mainShoppingListView.ViewItems.selectMode = !mainShoppingListView.ViewItems.selectMode
97
mainShoppingListView.ViewItems.selectedIndices = []
104
text: i18n.tr("Select All")
106
if(mainShoppingListView.ViewItems.selectedIndices.length <= 0) {
107
mainShoppingListView.ViewItems.selectedIndices = main_shopping_list_MODEL.mainListLengthInArray()
109
mainShoppingListView.ViewItems.selectedIndices = []
117
text: i18n.tr("Delete Selected")
119
main_shopping_list_MODEL.removeMultipleMainLists(mainShoppingListView.ViewItems.selectedIndices)
120
mainShoppingListView.ViewItems.selectedIndices = []
121
mainShoppingListView.ViewItems.selectMode = !mainShoppingListView.ViewItems.selectMode
122
root.state = "default"
135
InfoMailListComponent {
136
id: infoMainListDialog
139
// EDIT LIST NAME DIALOG
140
EditListItelComponent {
141
id: editMainListDialog
144
// Add new list Dialoge
145
AddNewListItemComponent {
146
id: addNewListDialoge
157
// function to open Dialog
158
function addNewList() {
159
PopupUtils.open(addNewListDialoge)
160
//get random backgroundColor
161
var randomNumber = Math.floor((Math.random() * colorsToUse.count) + 1) - 1;
162
randomColor = colorsToUse.get(randomNumber).colorBG
170
id: mainShoppingListView
172
height: parent.height
174
model: main_shopping_list_MODEL
175
// ViewItems.dragMode: true
176
displaced: Transition {
177
UbuntuNumberAnimation { property: "y"; duration: UbuntuAnimation.BriskDuration }
182
root.state = "default"
183
mainShoppingListView.ViewItems.selectMode = false
185
swipeItemDemo.enable()
193
color: selected ? "#edffcf" : "transparent"
195
// ListView.view.ViewItems.dragMode = !ListView.view.ViewItems.dragMode
196
// dragMode = !dragMode;
197
selectMode = !selectMode
198
root.state === "multiselection" ? root.state = "default" : root.state = "multiselection"
206
currentMainListIndex = index
207
mainPageStack.push(Qt.resolvedUrl("ShopListMain.qml"),{title: name, bgColor:def_color})
209
// mainView.backgroundColor = def_color
214
anchors.margins: units.gu(1)
218
height: parent.height
219
anchors.verticalCenter: parent.verticalCenter
222
height: parent.height
224
backgroundColor: def_color === undefined ? "white" : def_color
228
anchors.centerIn: parent
229
text: name.match(/\b\w/g).join('').toUpperCase().slice(0,2)
236
// width: parent.width - parent.height - units.gu(2)
237
anchors.verticalCenter: parent.verticalCenter
246
leadingActions: ListItemActions {
251
main_shopping_list_MODEL.removeMainList(index)
252
main_shopping_list_MODEL.remove(index)
257
trailingActions: ListItemActions {
262
editListIndex = index
263
PopupUtils.open(editMainListDialog)
270
editListIndex = index
271
PopupUtils.open(infoMainListDialog)
278
// ListView.view.ViewItems.selectMode = !ListView.view.ViewItems.selectMode
294
// No list added information (on the middle of the main page)
296
id: noShoppingListInfo
299
visible: main_shopping_list_MODEL.count != 0 ? false: true
303
anchors.margins: units.gu(3)
306
anchors.verticalCenter: parent.verticalCenter
312
horizontalAlignment: Text.AlignHCenter
313
font.pixelSize: units.gu(3)
315
text: i18n.tr("You have no shopping list added yet.")
320
horizontalAlignment: Text.AlignHCenter
321
font.pixelSize: units.gu(2.5)
323
text: i18n.tr("Please tap anywhere or use <b>Plus</b> symbol on header to add new list.")
333
onClicked: addNewList()
338
// Swipe demo to be showen only once when user creates first shopping list. (left, right swipe)
342
property bool parentActive: true
347
if (status === Loader.Ready) {
348
Qt.inputMethod.hide()