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
1=== modified file 'examples/u1db-qt-example-3.qml'
2--- examples/u1db-qt-example-3.qml 2013-03-11 10:59:20 +0000
3+++ examples/u1db-qt-example-3.qml 2013-03-11 11:54:21 +0000
4@@ -21,19 +21,78 @@
5 import U1db 1.0 as U1db
6 import Ubuntu.Components 0.1
7
8+/*!
9+
10+This example and tutorial is designed to show a wide variety of U1Db-Qt functionality and usage. The example demonstrates:
11+
12+\list 1
13+ \li Combining U1Db-Qt with elements and components that do not utilize models
14+ \li Blending the U1Db-Qt plugin with QML and Javascript
15+\endlist
16+
17+ */
18+
19 Item {
20
21 width: units.gu(45)
22 height: units.gu(80)
23
24+ /*!
25+
26+ 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.
27+
28+ U1db.Database {
29+ id: aDatabase
30+ path: "aU1DbDSatabase2"
31+ }
32+
33+ */
34+
35+ U1db.Database {
36+ id: aDatabase
37+ path: "aU1DbDSatabase3"
38+ }
39+
40+ /*!
41+
42+ 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.
43+
44+ 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.
45+
46+ U1db.Document {
47+ id: aDocument
48+ database: aDatabase
49+ docId: 'helloworld'
50+ create: true
51+ defaults: { "helloworld":"Hello World" }
52+
53+ Component.onCompleted: {
54+ documentContent.text = aDocument.contents.helloworld
55+ }
56+
57+ }
58+
59+ */
60+
61+ U1db.Document {
62+ id: aDocument
63+ database: aDatabase
64+ docId: 'helloworld'
65+ create: true
66+ defaults: { "helloworld":"Hello World" }
67+
68+ Component.onCompleted: {
69+ documentContent.text = aDocument.contents.helloworld
70+ }
71+
72+ }
73+
74 function getCurrentDocumentKey(documentObject){
75
76 if(typeof documentObject!='undefined'){
77
78 var keys = Object.keys(documentObject);
79
80- print("keys[0] = " + keys[0])
81-
82 return keys[0]
83
84 }
85@@ -54,11 +113,9 @@
86
87 if(documentText!==addressBarText) {
88
89- print('Current Document Key != Address Bar Text')
90-
91 /*!
92
93- 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.
94+ 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.
95
96 var tempDocument = {}
97 var tempFieldName = addressBarText;
98@@ -110,19 +167,26 @@
99 tempDocument.contents = tempContents
100 aDocument = tempDocument
101
102-
103 }
104
105 }
106 else {
107
108- print('Current Document Key == Address Bar Text')
109-
110- tempContents = {}
111- tempFieldName = getCurrentDocumentKey(aDocument.contents)
112- tempContents[tempFieldName] = documentContent.text
113- aDocument.contents = tempContents
114-
115+ /*!
116+
117+ 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.
118+
119+ tempContents = {}
120+ tempFieldName = getCurrentDocumentKey(aDocument.contents)
121+ tempContents[tempFieldName] = documentContent.text
122+ aDocument.contents = tempContents
123+
124+ */
125+
126+ tempContents = {}
127+ tempFieldName = getCurrentDocumentKey(aDocument.contents)
128+ tempContents[tempFieldName] = documentContent.text
129+ aDocument.contents = tempContents
130
131 }
132
133@@ -135,6 +199,7 @@
134 height: units.gu(80)
135 anchors.top: parent.top;
136
137+<<<<<<< TREE
138 /*!
139
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.
141@@ -172,6 +237,9 @@
142 create: true
143 defaults: { "helloworld":"Hello World" }
144 }
145+=======
146+
147+>>>>>>> MERGE-SOURCE
148
149 Tabs {
150 id: tabs
151@@ -248,8 +316,6 @@
152 height: units.gu(58)
153 color: "#000000"
154
155- text: aDocument.contents.helloworld
156-
157 }
158
159 }
160@@ -278,13 +344,11 @@
161 }
162 Button {
163 text: "Home"
164- onClicked: print("clicked Home Button")
165- // 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 appropriate
166- }
167+ onClicked: updateContentWindow(getCurrentDocumentKey(aDocument.contents),'helloworld')
168+ }
169 Button {
170- text: "+"
171- onClicked: print("clicked Save Button"), updateContentWindow(getCurrentDocumentKey(aDocument.contents),addressBar.text)
172- // add a function to save the text in the content window, which will be applied to the name/key in the address bar
173+ text: "Save"
174+ onClicked: updateContentWindow(getCurrentDocumentKey(aDocument.contents),addressBar.text)
175 }
176 Button {
177 text: ">"
178@@ -342,6 +406,7 @@
179
180 }
181
182+
183 }
184
185

Subscribers

People subscribed via source and target branches

to all changes: