Merge lp:~kevin-wright-1/u1db-qt/example-3-development-march-11-2013-iii into lp:u1db-qt

Proposed by Kevin Wright
Status: Merged
Merged at revision: 43
Proposed branch: lp:~kevin-wright-1/u1db-qt/example-3-development-march-11-2013-iii
Merge into: lp:u1db-qt
Diff against target: 183 lines (+86/-21) (has conflicts)
1 file modified
examples/u1db-qt-example-3.qml (+86/-21)
Text conflict in examples/u1db-qt-example-3.qml
To merge this branch: bzr merge lp:~kevin-wright-1/u1db-qt/example-3-development-march-11-2013-iii
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+152652@code.launchpad.net

Description of the change

Improved u1db-qt-example-3.qml by adding in the ability to return to 'home', added more tutorial text (including an opening summmary and learning outcomes), and removed some console output calls.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) :
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-3.qml'
--- examples/u1db-qt-example-3.qml 2013-03-11 10:59:20 +0000
+++ examples/u1db-qt-example-3.qml 2013-03-11 11:54:21 +0000
@@ -21,19 +21,78 @@
21import U1db 1.0 as U1db21import U1db 1.0 as U1db
22import Ubuntu.Components 0.122import Ubuntu.Components 0.1
2323
24/*!
25
26This example and tutorial is designed to show a wide variety of U1Db-Qt functionality and usage. The example demonstrates:
27
28\list 1
29 \li Combining U1Db-Qt with elements and components that do not utilize models
30 \li Blending the U1Db-Qt plugin with QML and Javascript
31\endlist
32
33 */
34
24Item {35Item {
2536
26 width: units.gu(45)37 width: units.gu(45)
27 height: units.gu(80)38 height: units.gu(80)
2839
40 /*!
41
42 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.
43
44 U1db.Database {
45 id: aDatabase
46 path: "aU1DbDSatabase2"
47 }
48
49 */
50
51 U1db.Database {
52 id: aDatabase
53 path: "aU1DbDSatabase3"
54 }
55
56 /*!
57
58 A Document can be declared at runtime. It requires at the very least a unique 'docId', but that alone won't do anything special. The snipet below snippet demonstrates the basic requirements.
59
60 In addition to this, this example displays text from the database for a specific docId and id key in a text area called 'documentContent. To update the text area at startup with either the default value or a value from the database the onCompleted function is utilized, which is also demonstrated below.
61
62 U1db.Document {
63 id: aDocument
64 database: aDatabase
65 docId: 'helloworld'
66 create: true
67 defaults: { "helloworld":"Hello World" }
68
69 Component.onCompleted: {
70 documentContent.text = aDocument.contents.helloworld
71 }
72
73 }
74
75 */
76
77 U1db.Document {
78 id: aDocument
79 database: aDatabase
80 docId: 'helloworld'
81 create: true
82 defaults: { "helloworld":"Hello World" }
83
84 Component.onCompleted: {
85 documentContent.text = aDocument.contents.helloworld
86 }
87
88 }
89
29 function getCurrentDocumentKey(documentObject){90 function getCurrentDocumentKey(documentObject){
3091
31 if(typeof documentObject!='undefined'){92 if(typeof documentObject!='undefined'){
3293
33 var keys = Object.keys(documentObject);94 var keys = Object.keys(documentObject);
3495
35 print("keys[0] = " + keys[0])
36
37 return keys[0]96 return keys[0]
3897
39 }98 }
@@ -54,11 +113,9 @@
54113
55 if(documentText!==addressBarText) {114 if(documentText!==addressBarText) {
56115
57 print('Current Document Key != Address Bar Text')
58
59 /*!116 /*!
60117
61 The next steps demonstrate the creation of a temporary document, based on a copy of the global document. This will then be used to determine if there is already a document in the database with the same docId as the address bar, and additionally with a key id with the same name.118 Thes steps demonstrate the creation of a temporary document, based on a copy of the global document. This will then be used to determine if there is already a document in the database with the same docId as the address bar, and additionally with a key id with the same name.
62119
63 var tempDocument = {}120 var tempDocument = {}
64 var tempFieldName = addressBarText;121 var tempFieldName = addressBarText;
@@ -110,19 +167,26 @@
110 tempDocument.contents = tempContents167 tempDocument.contents = tempContents
111 aDocument = tempDocument168 aDocument = tempDocument
112169
113
114 }170 }
115171
116 }172 }
117 else {173 else {
118174
119 print('Current Document Key == Address Bar Text')175 /*!
120176
121 tempContents = {}177 In this instance the current document's content is updated from the text view. The unique key and docId are not modified because the database already contains a record with those properties.
122 tempFieldName = getCurrentDocumentKey(aDocument.contents)178
123 tempContents[tempFieldName] = documentContent.text179 tempContents = {}
124 aDocument.contents = tempContents180 tempFieldName = getCurrentDocumentKey(aDocument.contents)
125181 tempContents[tempFieldName] = documentContent.text
182 aDocument.contents = tempContents
183
184 */
185
186 tempContents = {}
187 tempFieldName = getCurrentDocumentKey(aDocument.contents)
188 tempContents[tempFieldName] = documentContent.text
189 aDocument.contents = tempContents
126190
127 }191 }
128192
@@ -135,6 +199,7 @@
135 height: units.gu(80)199 height: units.gu(80)
136 anchors.top: parent.top;200 anchors.top: parent.top;
137201
202<<<<<<< TREE
138 /*!203 /*!
139204
140 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.205 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.
@@ -172,6 +237,9 @@
172 create: true237 create: true
173 defaults: { "helloworld":"Hello World" }238 defaults: { "helloworld":"Hello World" }
174 }239 }
240=======
241
242>>>>>>> MERGE-SOURCE
175243
176 Tabs {244 Tabs {
177 id: tabs245 id: tabs
@@ -248,8 +316,6 @@
248 height: units.gu(58)316 height: units.gu(58)
249 color: "#000000"317 color: "#000000"
250318
251 text: aDocument.contents.helloworld
252
253 }319 }
254320
255 }321 }
@@ -278,13 +344,11 @@
278 }344 }
279 Button {345 Button {
280 text: "Home"346 text: "Home"
281 onClicked: print("clicked Home Button")347 onClicked: updateContentWindow(getCurrentDocumentKey(aDocument.contents),'helloworld')
282 // add and call a function to find the document (in the database) defined as 'home', and then change both the address bar and content window to match as appropriate348 }
283 }
284 Button {349 Button {
285 text: "+"350 text: "Save"
286 onClicked: print("clicked Save Button"), updateContentWindow(getCurrentDocumentKey(aDocument.contents),addressBar.text)351 onClicked: updateContentWindow(getCurrentDocumentKey(aDocument.contents),addressBar.text)
287 // add a function to save the text in the content window, which will be applied to the name/key in the address bar
288 }352 }
289 Button {353 Button {
290 text: ">"354 text: ">"
@@ -342,6 +406,7 @@
342406
343 }407 }
344408
409
345 }410 }
346411
347412

Subscribers

People subscribed via source and target branches

to all changes: