~ubuntu-tn-dev/simpletodo/trunk

« back to all changes in this revision

Viewing changes to app.qml

  • Committer: Ahmed Sghaier
  • Date: 2013-10-27 03:48:12 UTC
  • Revision ID: ahmed.sghaier@ubuntu.com-20131027034812-ngzpzeiltsuat2mc
Initial project sprint developed during GNU30

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*import QtQuick 2.0
 
2
import File 1.0
 
3
 
 
4
Item {
 
5
    width: 300; height: 200
 
6
 
 
7
    ToDo {
 
8
        id: todo
 
9
    }
 
10
 
 
11
    Text {
 
12
        anchors.centerIn: parent
 
13
        text: "Click to read file into console"
 
14
    }
 
15
 
 
16
    MouseArea {
 
17
        anchors.fill: parent
 
18
        onClicked: console.log(todo.read('app.qml'))
 
19
    }
 
20
}
 
21
*/
 
22
 
 
23
 
 
24
import QtQuick 2.0
 
25
import Ubuntu.Components 0.1
 
26
import "ui"
 
27
import Ubuntu.Components.ListItems 0.1 as ListItem
 
28
import ToDo 1.0
 
29
 
 
30
MainView {
 
31
 
 
32
    ToDo {
 
33
        id: todo
 
34
    }
 
35
 
 
36
    objectName: "ToDo"
 
37
 
 
38
 
 
39
    applicationName: "com.ubuntu.developer..tabbedui"
 
40
 
 
41
    width: units.gu(100)
 
42
    height: units.gu(75)
 
43
 
 
44
    PageStack {
 
45
            id: pageStack
 
46
            Component.onCompleted: push(page0)
 
47
 
 
48
            Page {
 
49
                id: page0
 
50
                title: i18n.tr("ToDo")
 
51
                visible: false
 
52
 
 
53
                Column {
 
54
                    width: parent.width
 
55
                Column {
 
56
 
 
57
 
 
58
                    spacing: units.gu(2)
 
59
                    Button {
 
60
                        objectName: "button_text"
 
61
                        text: i18n.tr("Add")
 
62
                        onClicked: {pageStack.push(page1); oldText.text = ""; todoname.text = ""}
 
63
                        //onClicked: print("clicked text and icon Button")
 
64
                        //onClicked: console.log(todo.readToDos('app.qml'))
 
65
                    }
 
66
                }
 
67
 
 
68
                Column {
 
69
                    anchors.left: parent.left
 
70
                    anchors.right: parent.right
 
71
 
 
72
                    Repeater {
 
73
                        id: repeater
 
74
                        model: todo.readToDos()//["design", "sqlite", "coding", "integration"]
 
75
                        ListItem.Standard {
 
76
                                text: i18n.tr(modelData)
 
77
                                removable: true
 
78
                                onClicked: pageStack.push(page1, {text: modelData})
 
79
                                onItemRemoved: todo.deleteToDo(modelData)//print(index)
 
80
                                backgroundIndicator: Rectangle {
 
81
                                    anchors.fill: parent
 
82
                                    color: Theme.palette.normal.base
 
83
                                }
 
84
                        }
 
85
                    }
 
86
                }
 
87
                }
 
88
            }
 
89
 
 
90
            Page {
 
91
                title: "Add"
 
92
                id: page1
 
93
                visible: false
 
94
                property alias text: oldText.text
 
95
                Column {
 
96
                    width: parent.width
 
97
                Column {
 
98
                    spacing: units.gu(2)
 
99
                    Button {
 
100
                        objectName: "button_text"
 
101
                        text: i18n.tr("Save")
 
102
                        onClicked: {todo.editToDo(todoname.text, oldText.text); pageStack.pop();repeater.model = todo.refresh()}
 
103
                    }
 
104
                    Button {
 
105
                        objectName: "button_text1"
 
106
                        text: i18n.tr("Close")
 
107
                        onClicked: pageStack.pop()
 
108
                    }
 
109
                }
 
110
 
 
111
                Column {
 
112
                    anchors.left: parent.left
 
113
                    anchors.right: parent.right
 
114
                    TextField {
 
115
                        id: todoname
 
116
                        objectName: "textfield_standard"
 
117
                        placeholderText: i18n.tr("Type todo name...")
 
118
                        width: parent.width
 
119
                    }
 
120
                    Label {
 
121
                        id: oldText
 
122
                        fontSize: "medium"
 
123
                        text: ""
 
124
                    }
 
125
 
 
126
                }
 
127
                }
 
128
            }
 
129
        }
 
130
 
 
131
}
 
132
/*Item {
 
133
    width: 300; height: 200
 
134
 
 
135
    ToDo {
 
136
        id: todo
 
137
    }
 
138
 
 
139
 
 
140
    MouseArea {
 
141
        anchors.fill: parent
 
142
        onClicked: console.log(todo.read('app.qml'))
 
143
    }
 
144
}
 
145
*/