Merge lp:~kalikiana/u1db-qt/range2 into lp:u1db-qt

Proposed by Cris Dywan
Status: Merged
Approved by: Cris Dywan
Approved revision: 91
Merged at revision: 81
Proposed branch: lp:~kalikiana/u1db-qt/range2
Merge into: lp:u1db-qt
Diff against target: 589 lines (+88/-96)
11 files modified
documentation/CMakeLists.txt (+3/-2)
documentation/concepts.qdoc (+12/-11)
documentation/overview.qdoc (+2/-2)
src/database.cpp (+12/-14)
src/database.h (+6/-4)
src/document.cpp (+9/-5)
src/document.h (+0/-1)
src/index.cpp (+7/-1)
src/index.h (+3/-3)
src/query.cpp (+34/-47)
src/query.h (+0/-6)
To merge this branch: bzr merge lp:~kalikiana/u1db-qt/range2
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+160357@code.launchpad.net

This proposal supersedes a proposal from 2013-04-23.

Commit message

Remove range property for now, it's not implemented

Description of the change

Remove range property for now, it's not implemented

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
lp:~kalikiana/u1db-qt/range2 updated
81. By Cris Dywan

Fill in documentation for remaining C++ class methods

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~kalikiana/u1db-qt/range2 updated
82. By Cris Dywan

Rename the overview - qdoc expects a page titled All Modules

83. By Cris Dywan

Fix un-closed comment in concepts.qdoc

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~kalikiana/u1db-qt/range2 updated
84. By Cris Dywan

Remove redundant documentCount variable

85. By Cris Dywan

Don't bother calling 'assistant', leave it to install

86. By Cris Dywan

Remove dataIndexed and documentsAvailable signals

87. By Cris Dywan

Sort out documentation of signals and properties

88. By Cris Dywan

Merge 'Initial ground work splitting off query tests'

89. By Cris Dywan

Document Query::results property

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
lp:~kalikiana/u1db-qt/range2 updated
90. By Cris Dywan

Mark up Javascript-only snippets as \code not \qml

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
lp:~kalikiana/u1db-qt/range2 updated
91. By Cris Dywan

Work-around to make build fail if qdoc warns

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'documentation/CMakeLists.txt'
2--- documentation/CMakeLists.txt 2013-04-23 11:17:47 +0000
3+++ documentation/CMakeLists.txt 2013-04-23 16:20:37 +0000
4@@ -5,10 +5,11 @@
5
6 set(U1DB_DOCS "${CMAKE_CURRENT_BINARY_DIR}/output")
7 add_custom_target(doc ${ALL} "mkdir" "-p" "${U1DB_DOCS}"
8- COMMAND "qdoc" "-outputdir" "${U1DB_DOCS}" "${CMAKE_CURRENT_SOURCE_DIR}/u1db.qdocconf"
9+ COMMAND "qdoc" "-outputdir" "${U1DB_DOCS}" "${CMAKE_CURRENT_SOURCE_DIR}/u1db.qdocconf" "2>" "${CMAKE_CURRENT_BINARY_DIR}/qdoc.err"
10+ COMMAND "cat" "${CMAKE_CURRENT_BINARY_DIR}/qdoc.err"
11+ COMMAND "test" "!" "-s" "${CMAKE_CURRENT_BINARY_DIR}/qdoc.err"
12 COMMAND "sed" "-r" "-i" "'s@(</head>)@<link rel=\"stylesheet\" type=\"text/css\" href=\"style/base.css\" />\\1@'" "${U1DB_DOCS}/*.html"
13 COMMAND "qhelpgenerator" "${U1DB_DOCS}/u1dbqt.qhp"
14- COMMAND "assistant" "-register" "${U1DB_DOCS}/u1dbqt.qch"
15 SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/u1db.qdocconf"
16 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
17
18
19=== modified file 'documentation/concepts.qdoc'
20--- documentation/concepts.qdoc 2013-04-23 11:55:20 +0000
21+++ documentation/concepts.qdoc 2013-04-23 16:20:37 +0000
22@@ -91,10 +91,8 @@
23
24 The listDocs method retrieves all the docId values from the current database. In this demonstration the values are put into an array, which is then checked to locate the docId for the current and previous documents within the database.
25
26- \qml
27- var documentIds = {}
28-
29- documentIds = documentObject.database.listDocs()
30+ \code
31+ var documentIds = documentObject.database.listDocs()
32
33 for(var i = 0; i < documentIds.length; i++){
34
35@@ -106,40 +104,40 @@
36 }
37
38 }
39- \endqml
40+ \endcode
41
42 These 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.
43
44- \qml
45+ \code
46 var tempFieldName = addressBarText;
47
48 var tempDocument = aDocument
49 tempDocument.docId = addressBarText;
50
51 var tempContents = tempDocument.contents
52- \endqml
53+ \endcode
54
55 \b{Note: For simplicity sake this example sometimes uses the same value for both the docId and the key id, as seen here. Real life implimentations can and will differ, and this will be demonstrated elsewhere in the example code.}
56
57 Here the contents of the temporary document are modified, which then replaces the global document.
58
59- \qml
60+ \code
61 documentContent.text = 'More Hello World...';
62
63 var tempContents = {}
64 tempContents[tempFieldName] = documentContent.text
65 tempDocument.contents = tempContents
66 aDocument = tempDocument
67- \endqml
68+ \endcode
69
70 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.
71
72- \qml
73+ \code
74 var tempContents = {}
75 tempFieldName = getCurrentDocumentKey(aDocument.contents)
76 tempContents[tempFieldName] = documentContent.text
77 aDocument.contents = tempContents
78- \endqml
79+ \endcode
80
81 Here a rectangle is defined that represents the lower portion of our application. It will contain all the main parts of the application.
82
83@@ -179,6 +177,7 @@
84 There is an object within in the 'aDocument' model defined earlier called 'contents', which contains a key called 'hello', which represents a search string. In this example the key will represent the name of a document in the database, which will be displayed in the address bar. Displaying the key is demonstrated here:
85
86 \qml
87+ TextArea{
88 text: displayKey(aDocument.contents)
89
90 function displayKey(documentObject){
91@@ -188,5 +187,7 @@
92 return keys[0]
93
94 }
95+ }
96 \endqml
97+ */
98
99
100=== modified file 'documentation/overview.qdoc'
101--- documentation/overview.qdoc 2013-04-22 11:28:15 +0000
102+++ documentation/overview.qdoc 2013-04-23 16:20:37 +0000
103@@ -19,8 +19,8 @@
104
105 /*!
106 \page overview.html overview
107- \title U1Db-Qt QML bindings for U1Db
108- \contentspage {U1Db-Qt QML bindings for U1Db} {Contents}
109+ \title All Modules
110+ \contentspage {All Modules} {Contents}
111
112 \part General Topics
113 \list
114
115=== modified file 'src/database.cpp'
116--- src/database.cpp 2013-04-22 12:54:59 +0000
117+++ src/database.cpp 2013-04-23 16:20:37 +0000
118@@ -81,7 +81,8 @@
119 }
120
121 /*!
122- Describes the error as a string if the last operation failed.
123+ \property Database::error
124+ The last error as a string if the last operation failed.
125 */
126 QString
127 Database::lastError()
128@@ -141,6 +142,10 @@
129 return true;
130 }
131
132+/*!
133+ Instantiate a new Database with an optional \a parent,
134+ usually by declaring it as a QML item.
135+ */
136 Database::Database(QObject *parent) :
137 QAbstractListModel(parent), m_path("")
138 {
139@@ -341,15 +346,14 @@
140 endInsertRows();
141 */
142
143- QList<QString> documents = listDocs();
144-
145- documentCount = documents.count();
146-
147 Q_EMIT docChanged(newOrEmptyDocId, contents);
148
149 return newRev;
150 }
151
152+/*!
153+ Returns a list of all stored documents by their docId.
154+ */
155 QList<QString>
156 Database::listDocs()
157 {
158@@ -374,11 +378,9 @@
159 }
160
161 /*!
162- A relative filename or absolute path advises the database to store documents
163- and indexes persistently on disk. Internally, an SQlite database is written.
164-
165- If no path is set, as is the default, all database contents are written in
166- memory only. The same affect can be achieved by passing the string ":memory:".
167+ \property Database::path
168+ A relative filename or absolute path to store documents
169+ and indexes persistently on disk. By default documents are stored in memory.
170 */
171 void
172 Database::setPath(const QString& path)
173@@ -396,10 +398,6 @@
174 Q_EMIT pathChanged(path);
175 }
176
177-/*!
178- The persistent storage location if set. By default the database is only
179- storted in memory. See setPath().
180- */
181 QString
182 Database::getPath()
183 {
184
185=== modified file 'src/database.h'
186--- src/database.h 2013-04-12 12:26:52 +0000
187+++ src/database.h 2013-04-23 16:20:37 +0000
188@@ -35,9 +35,6 @@
189 Q_PROPERTY(QString error READ lastError NOTIFY errorChanged)
190 public:
191 Database(QObject* parent = 0);
192- ~Database() { }
193-
194- int documentCount = 0;
195
196 // QAbstractListModel
197 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
198@@ -57,9 +54,14 @@
199 Q_SIGNALS:
200 void pathChanged(const QString& path);
201 void errorChanged(const QString& error);
202+ /*!
203+ A document's contents were modified.
204+ */
205 void docChanged(const QString& docId, QVariant content);
206+ /*!
207+ A document was loaded via its docID.
208+ */
209 void docLoaded(const QString& docId, QVariant content) const;
210- void documentsAvailable();
211 private:
212 Q_DISABLE_COPY(Database)
213 QString m_path;
214
215=== modified file 'src/document.cpp'
216--- src/document.cpp 2013-04-22 10:35:32 +0000
217+++ src/document.cpp 2013-04-23 16:20:37 +0000
218@@ -41,6 +41,10 @@
219 Database::getDoc().
220 */
221
222+/*!
223+ Instantiate a new Document with an optional \a parent,
224+ usually by declaring it as a QML item.
225+ */
226 Document::Document(QObject *parent) :
227 QObject(parent), m_database(0), m_create(false)
228 {
229@@ -73,6 +77,7 @@
230 }
231
232 /*!
233+ \property Document::database
234 The database is used to lookup the contents of the document, reflecting
235 changes done to it and conversely changes are saved to the database.
236 */
237@@ -106,6 +111,7 @@
238 }
239
240 /*!
241+ \property Document::docId
242 The docId can be that of an existing document in the database and
243 will determine what getContents() returns.
244 If no such documents exists, setDefaults() can be used to supply a preset.
245@@ -133,6 +139,7 @@
246 }
247
248 /*!
249+ \property Document::create
250 If create is true, docId is not empty and no document with the same docId
251 exists, defaults will be used to store the document.
252 */
253@@ -156,6 +163,7 @@
254 }
255
256 /*!
257+ \property Document::defaults
258 The default contents of the document, which are used only if
259 create is true, docId is not empty and no document with the same
260 docId exists in the database yet.
261@@ -174,11 +182,6 @@
262 m_database->putDoc(m_defaults, m_docId);
263 }
264
265-/*!
266- The contents of the document, as set via setContents() or stored in
267- the database via Database::putDoc().
268- onContentsChanged() can be used to monitor changes.
269- */
270 QVariant
271 Document::getContents()
272 {
273@@ -186,6 +189,7 @@
274 }
275
276 /*!
277+ \property Document::contents
278 Updates the contents of the document. A valid docId must be set.
279 */
280 void
281
282=== modified file 'src/document.h'
283--- src/document.h 2013-04-12 12:26:52 +0000
284+++ src/document.h 2013-04-23 16:20:37 +0000
285@@ -41,7 +41,6 @@
286 Q_PROPERTY(QVariant contents READ getContents WRITE setContents NOTIFY contentsChanged)
287 public:
288 Document(QObject* parent = 0);
289- ~Document() { }
290
291 Database* getDatabase();
292 void setDatabase(Database* database);
293
294=== modified file 'src/index.cpp'
295--- src/index.cpp 2013-04-22 12:54:59 +0000
296+++ src/index.cpp 2013-04-23 16:20:37 +0000
297@@ -43,6 +43,10 @@
298 Database::getIndexExpressions().
299 */
300
301+/*!
302+ Instantiate a new Index with an optional \a parent,
303+ usually by declaring it as a QML item.
304+ */
305 Index::Index(QObject *parent) :
306 QObject(parent), m_database(0)
307 {
308@@ -67,6 +71,7 @@
309 }
310
311 /*!
312+ \property Index::database
313 Sets the Database to lookup documents from and store the index in. The
314 dataInvalidated() signal will be emitted on all changes that could affect
315 the index.
316@@ -100,6 +105,7 @@
317 }
318
319 /*!
320+ \property Index::name
321 Sets the name used. Both an expression and a name must be specified
322 for an index to be created.
323 */
324@@ -126,6 +132,7 @@
325 }
326
327 /*!
328+ \property Index::expression
329 Sets the expression used. Both an expression and a name must be specified
330 for an index to be created.
331
332@@ -148,7 +155,6 @@
333 m_expression = expression;
334
335 Q_EMIT expressionChanged(expression);
336- Q_EMIT dataIndexed();
337 }
338
339 /*!
340
341=== modified file 'src/index.h'
342--- src/index.h 2013-04-12 12:26:52 +0000
343+++ src/index.h 2013-04-23 16:20:37 +0000
344@@ -39,7 +39,6 @@
345 Q_PROPERTY(QStringList expression READ getExpression WRITE setExpression NOTIFY expressionChanged)
346 public:
347 Index(QObject* parent = 0);
348- ~Index() { }
349
350 Database* getDatabase();
351 void setDatabase(Database* database);
352@@ -58,9 +57,10 @@
353 void databaseChanged(Database* database);
354 void nameChanged(const QString& name);
355 void expressionChanged(QVariant expression);
356- // Either of the above has changed:
357+ /*!
358+ The database, an indexed document or the expressions changed.
359+ */
360 void dataInvalidated();
361- void dataIndexed();
362 private:
363 Q_DISABLE_COPY(Index)
364 Database* m_database;
365
366=== modified file 'src/query.cpp'
367--- src/query.cpp 2013-04-23 12:50:30 +0000
368+++ src/query.cpp 2013-04-23 16:20:37 +0000
369@@ -36,13 +36,16 @@
370 \inmodule U1db
371 \ingroup modules
372
373- \brief The Query class generates a filtered list of documents based on either
374- a query or a range, and using the given Index.
375+ \brief The Query class generates a filtered list of documents based on a query using the given Index.
376
377 Query can be used as a QAbstractListModel, delegates will then have access to \a docId and \a contents
378 analogous to the properties of Document.
379 */
380
381+/*!
382+ Instantiate a new Query with an optional \a parent,
383+ usually by declaring it as a QML item.
384+ */
385 Query::Query(QObject *parent) :
386 QAbstractListModel(parent), m_index(0)
387 {
388@@ -87,9 +90,6 @@
389 return m_results.count();
390 }
391
392-/*!
393- Returns the Index used to query the database.
394- */
395 Index*
396 Query::getIndex()
397 {
398@@ -107,18 +107,14 @@
399
400 if (!m_index)
401 return;
402-
403- Database *db = m_index->getDatabase();
404- if(db){
405- if(db->documentCount>0){
406- QObject::connect(db, &Database::documentsAvailable, this, &Query::onDataInvalidated);
407- }
408- }
409-
410 generateQueryResults();
411
412 }
413
414+/*!
415+ \internal
416+ Manually triggers reloading of the query.
417+ */
418 void Query::generateQueryResults()
419 {
420
421@@ -157,6 +153,10 @@
422 Q_EMIT resultsChanged(m_results);
423 }
424
425+/*!
426+ \internal
427+ Query a single field.
428+ */
429 bool Query::queryField(QString field, QVariant value){
430
431 bool match = false;
432@@ -180,6 +180,10 @@
433
434 }
435
436+/*!
437+ \internal
438+ Loop through the query assuming it's a list.
439+ */
440 bool Query::iterateQueryList(QVariant query, QString field, QString value)
441 {
442
443@@ -218,6 +222,10 @@
444 return match;
445 }
446
447+/*!
448+ \internal
449+ Handle different types of string values including wildcards.
450+ */
451 bool Query::queryString(QString query, QString value)
452 {
453
454@@ -242,6 +250,10 @@
455 return match;
456 }
457
458+/*!
459+ \internal
460+ Loop through the given map of keys and queries.
461+ */
462 bool Query::queryMap(QVariantMap map, QString value, QString field)
463 {
464
465@@ -278,8 +290,9 @@
466 }
467
468 /*!
469- Sets the Index to use. The index must have a valid name and index expressions,
470- then either a range or query can be set.
471+ \property Query::index
472+ Sets the Index to use. The index must have a valid name and index expressions.
473+ If no query is set, the default is all results of the index.
474 */
475 void
476 Query::setIndex(Index* index)
477@@ -292,7 +305,6 @@
478 m_index = index;
479 if (m_index){
480 QObject::connect(m_index, &Index::dataInvalidated, this, &Query::onDataInvalidated);
481- QObject::connect(m_index, &Index::dataIndexed, this, &Query::onDataInvalidated);
482 }
483 Q_EMIT indexChanged(index);
484
485@@ -301,19 +313,17 @@
486
487 }
488
489-/*!
490- Returns the query used, in the form of a string, list or variant.
491- */
492 QVariant
493 Query::getQuery()
494 {
495 return m_query;
496 }
497
498-
499 /*!
500- Sets a range, such as ['match', false].
501- Only one of query and range is used - setting range unsets the query.
502+ \property Query::query
503+ A query in one of the allowed forms:
504+ 'value', ['value'] or [{'sub-field': 'value'}].
505+ The default is equivalent to '*'.
506 */
507 void
508 Query::setQuery(QVariant query)
509@@ -321,38 +331,15 @@
510 if (m_query == query)
511 return;
512
513- if (m_range.isValid())
514- m_range = QVariant();
515-
516 m_query = query;
517 Q_EMIT queryChanged(query);
518 onDataInvalidated();
519 }
520
521-QVariant
522-Query::getRange()
523-{
524- return m_range;
525-}
526-
527 /*!
528- Sets a range, such as [['a', 'b'], ['*']].
529- Only one of query and range is used - setting range unsets the query.
530+ \property Query::results
531+ The results of the query as a list.
532 */
533-void
534-Query::setRange(QVariant range)
535-{
536- if (m_range == range)
537- return;
538-
539- if (m_query.isValid())
540- m_query = QVariant();
541-
542- m_range = range;
543- Q_EMIT rangeChanged(range);
544- onDataInvalidated();
545-}
546-
547 QList<QVariant>
548 Query::getResults()
549 {
550
551=== modified file 'src/query.h'
552--- src/query.h 2013-04-22 13:26:42 +0000
553+++ src/query.h 2013-04-23 16:20:37 +0000
554@@ -35,11 +35,9 @@
555 Q_PROPERTY(QT_PREPEND_NAMESPACE_U1DB(Index*) index READ getIndex WRITE setIndex NOTIFY indexChanged)
556 #endif
557 Q_PROPERTY(QVariant query READ getQuery WRITE setQuery NOTIFY queryChanged)
558- Q_PROPERTY(QVariant range READ getRange WRITE setRange NOTIFY rangeChanged)
559 Q_PROPERTY(QList<QVariant> results READ getResults NOTIFY resultsChanged)
560 public:
561 Query(QObject* parent = 0);
562- ~Query() { }
563
564 // QAbstractListModel
565 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
566@@ -50,8 +48,6 @@
567 void setIndex(Index* index);
568 QVariant getQuery();
569 void setQuery(QVariant query);
570- QVariant getRange();
571- void setRange(QVariant range);
572 Q_INVOKABLE QList<QVariant> getResults();
573
574 void generateQueryResults();
575@@ -63,14 +59,12 @@
576 Q_SIGNALS:
577 void indexChanged(Index* index);
578 void queryChanged(QVariant query);
579- void rangeChanged(QVariant range);
580 void resultsChanged(QList<QVariant> results);
581 private:
582 Q_DISABLE_COPY(Query)
583 Index* m_index;
584 QList<QVariant> m_results;
585 QVariant m_query;
586- QVariant m_range;
587
588 void onDataInvalidated();
589 };

Subscribers

People subscribed via source and target branches

to all changes: