Merge lp:~kevin-wright-1/u1db-qt/example-development-05-march-2013-ii into lp:u1db-qt

Proposed by Kevin Wright
Status: Merged
Merged at revision: 34
Proposed branch: lp:~kevin-wright-1/u1db-qt/example-development-05-march-2013-ii
Merge into: lp:u1db-qt
Diff against target: 404 lines (+350/-8)
3 files modified
examples/u1db-qt-example-1.qml (+15/-8)
examples/u1db-qt-example-2.qml (+108/-0)
examples/u1db-qt-example-3.qml (+227/-0)
To merge this branch: bzr merge lp:~kevin-wright-1/u1db-qt/example-development-05-march-2013-ii
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+151916@code.launchpad.net

Description of the change

Fixed some more formatting issues in example code, changed some code comments in the example code, reduced the interval value in example 2 to 5 from 500, and ensured every delegate in each example is using 'text: contents.hello'

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

As discussed, I simplified the delegates. Looking brilliant!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/u1db-qt-example-1.qml'
--- examples/u1db-qt-example-1.qml 2013-03-04 13:58:58 +0000
+++ examples/u1db-qt-example-1.qml 2013-03-06 10:48:20 +0000
@@ -51,7 +51,7 @@
51 database: aDatabase51 database: aDatabase
52 docId: 'helloworld'52 docId: 'helloworld'
53 create: true53 create: true
54 defaults: { "hello": "world" }54 defaults: { "hello": "Hello World!" }
55 }55 }
56 56
57 Tabs {57 Tabs {
@@ -60,12 +60,12 @@
6060
61 Tab {61 Tab {
62 objectName: "Tab1"62 objectName: "Tab1"
63 63
64 title: i18n.tr("Hello U1Db!")64 title: i18n.tr("Hello U1Db!")
6565
66 page: Page {66 page: Page {
67 id: helloPage67 id: helloPage
68 ListView {68 ListView {
69 width: units.gu(45)69 width: units.gu(45)
70 height: units.gu(80)70 height: units.gu(80)
71 71
@@ -74,13 +74,20 @@
74 */ 74 */
75 model: aDatabase75 model: aDatabase
76 76
77 /* A delegate will be created for each Document retrieved from the Database */77 /* A delegate will be created for each Document retrieved from the Database */
78 delegate: Text {78 delegate: Text {
79 x: 66; y: 7779 x: 66; y: 77
80 text: {80 text: {
81 /*81 /*!
82 The contents of each Document are represented by a string that can be used in on the console or text as demonstrated here.82 The object called 'contents' contains a string as demonstrated here. In this example 'hello' is our search string.
83 */83
84 if(contents !== undefined){
85 text: contents.hello
86 }
87 else { "" }
88
89
90 */
84 text: contents.hello91 text: contents.hello
85 }92 }
86 }93 }
@@ -93,4 +100,4 @@
93 100
94 }101 }
95102
96}
97\ No newline at end of file103\ No newline at end of file
104}
98105
=== added file 'examples/u1db-qt-example-2.qml'
--- examples/u1db-qt-example-2.qml 1970-01-01 00:00:00 +0000
+++ examples/u1db-qt-example-2.qml 2013-03-06 10:48:20 +0000
@@ -0,0 +1,108 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Kevin Wright <kevin.wright@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.0
21import U1db 1.0 as U1db
22import Ubuntu.Components 0.1
23
24
25MainView {
26
27 id: u1dbView
28 width: units.gu(45)
29 height: units.gu(80)
30
31 /*!
32
33 A Database is very simple to create. It only needs an id and a path where the file will be created. A Database is a model, which can be used by elements, such as the ListView further in this example.
34
35 */
36
37 U1db.Database {
38 id: aDatabase
39 path: "aU1DbDSatabase2"
40 }
41
42 Timer {
43
44 property int i: 0; interval: 5; running: true; repeat: true
45 onTriggered: newDocumentObject()
46
47 function newDocumentObject() {
48
49 var qmlString = "import QtQuick 2.0; import U1db 1.0 as U1db; U1db.Document {id: aDcoument"+i+";database: aDatabase;docId: 'helloworld"+i+"';create: true; defaults: { 'hello': 'Hello New Document "+i+"!' }}"
50
51 Qt.createQmlObject(qmlString, u1dbView, "dynamicNewDocument"+i);
52
53 i = i+1
54 }
55
56 }
57
58 Tabs {
59 id: tabs
60 anchors.fill: parent
61
62 Tab {
63 objectName: "Tab1"
64
65 title: i18n.tr("Hello U1Db!")
66
67 page: Page {
68 id: helloPage
69 ListView {
70 width: units.gu(45)
71 height: units.gu(80)
72
73 /*
74 Here is the reference to the Database model mentioned earlier.
75 */
76 model: aDatabase
77
78 /* A delegate will be created for each Document retrieved from the Database */
79 delegate: Text {
80 x: 66; y: 77
81 text: {
82 /*!
83 The object called 'contents' contains a string as demonstrated here. In this example 'hello' is our search string.
84
85 if(contents !== undefined){
86 text: contents.hello
87 }
88 else { "" }
89
90
91 */
92
93 if(contents !== undefined){
94 text: contents.hello
95 }
96 else { "" }
97 }
98 }
99 }
100 }
101
102
103 }
104
105
106 }
107
108}
0109
=== added file 'examples/u1db-qt-example-3.qml'
--- examples/u1db-qt-example-3.qml 1970-01-01 00:00:00 +0000
+++ examples/u1db-qt-example-3.qml 2013-03-06 10:48:20 +0000
@@ -0,0 +1,227 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Kevin Wright <kevin.wright@canonical.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; version 3.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20import QtQuick 2.0
21import U1db 1.0 as U1db
22import Ubuntu.Components 0.1
23
24Item {
25
26 width: units.gu(45)
27 height: units.gu(80)
28
29 MainView {
30
31 id: u1dbView
32 width: units.gu(45)
33 height: units.gu(80)
34 anchors.top: parent.top;
35
36 /*!
37
38 A Database is very simple to create. It only needs an id and a path where the file will be created. A Database is a model, which can be used by elements, such as the ListView further in this example.
39
40 U1db.Database {
41 id: aDatabase
42 path: "aU1DbDSatabase2"
43 }
44
45 */
46
47 U1db.Database {
48 id: aDatabase
49 path: "aU1DbDSatabase2"
50 }
51
52 /*!
53
54 A Document can be declared at runtime. It requires at the very least a unique 'docId', but that alone won't do anything special. In order for a document to be entered into the database the below snippet demonstrates the basic requirements. The id might be optional.
55
56 U1db.Document {
57 id: aDocument
58 database: aDatabase
59 docId: 'helloworld'
60 create: true
61 defaults: { "hello":"Hello World" }
62 }
63
64 */
65
66 U1db.Document {
67 id: aDocument
68 database: aDatabase
69 docId: 'helloworld'
70 create: true
71 defaults: { "hello":"Hello World" }
72 }
73
74 Tabs {
75 id: tabs
76 anchors.fill: parent
77
78 Tab {
79 objectName: "Tab1"
80
81 title: i18n.tr("Hello U1Db!")
82
83 page: Page {
84
85 id: helloPage
86
87 Rectangle {
88
89 width: units.gu(45)
90 height: units.gu(70)
91 anchors.bottom: parent.bottom
92
93 color: "#00FFFFFF"
94
95 ListView {
96
97 width: units.gu(45)
98 height: units.gu(60)
99 anchors.bottom: parent.bottom
100
101 TextArea{
102
103 x: units.gu(1)
104 y: units.gu(1)
105 width: units.gu(43)
106 height: units.gu(58)
107
108 color: "#FFFFFF"
109
110 }
111
112 }
113
114 Rectangle {
115
116 width: units.gu(43)
117 height: units.gu(5)
118 anchors.top: addressBar.bottom
119 x: units.gu(1.5)
120
121 color: "#00FFFFFF"
122
123 Row{
124
125 width: units.gu(43)
126 height: units.gu(5)
127 anchors.verticalCenter: parent.verticalCenter
128 spacing: units.gu(2)
129
130
131 Button {
132 text: "<"
133 onClicked: print("clicked Back Button")
134 }
135 Button {
136 text: "Home"
137 onClicked: print("clicked Home Button")
138 }
139 Button {
140 text: "+"
141 onClicked: print("clicked Save Button")
142 }
143 Button {
144 text: ">"
145 onClicked: print("clicked Forward Button")
146 }
147 }
148
149 }
150
151 ListView {
152
153 width: units.gu(45)
154 height: units.gu(5)
155 anchors.top: parent.top
156
157 id: addressBar
158
159 /*! Inside this example ListView is a reference to the Database model mentioned earlier:
160
161 ListView {
162
163 model: aDatabase
164
165 }
166
167 */
168
169 model: aDatabase
170
171 /*!
172
173 Once a model is assigned to a ListView a delegate can represent each Document retrieved from the Database.
174
175 ListView {
176
177 model: aDatabase
178
179 delegate: Rectangle{
180 anchors.right: parent.right
181 }
182
183 }
184
185
186 */
187
188 delegate: TextField {
189 width: units.gu(43)
190 anchors.verticalCenter: parent.verticalCenter
191 x: units.gu(1)
192
193 text: {
194 /*!
195 The object called 'contents' contains a string as demonstrated here. In this example 'hello' is our search string.
196
197 if(contents !== undefined){
198 text: contents.hello
199 }
200 else { "" }
201
202
203 */
204
205 if(contents !== undefined){
206 text: contents.hello
207 }
208 else { "" }
209 }
210
211 }
212
213
214 }
215
216 }
217
218
219 }
220
221 }
222
223 }
224
225 }
226
227}

Subscribers

People subscribed via source and target branches

to all changes: