aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@digia.com>2014-09-09 13:20:15 +0200
committerMartin Smith <martin.smith@digia.com>2014-09-25 14:18:02 +0200
commitf4b5b2c472a7e4df053919877130924b6615b44b (patch)
tree57b34d249941dd209fccf0d363694f077d49602d
parentf6528924e559313cee236d2788ed9d1c43804185 (diff)
qdoc: Correct some links in QtEnginio
Several links in the Enginio docs are either broken, or they got to the wrong page. The docs also need revising. Change-Id: I90edd39a94b6922d5fe4423f684fb8004de0dee3 Task-number: QTBUG-40919 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
-rw-r--r--doc/enginio_overview.qdoc225
-rw-r--r--examples/enginio/quick/image-gallery/doc/src/image-gallery.qdoc6
-rw-r--r--examples/enginio/quick/todos/doc/src/todos.qdoc47
-rw-r--r--examples/enginio/widgets/todos-cpp/doc/src/todos-cpp.qdoc117
-rw-r--r--src/enginio_plugin/enginioplugin.cpp20
5 files changed, 278 insertions, 137 deletions
diff --git a/doc/enginio_overview.qdoc b/doc/enginio_overview.qdoc
index 6db1761..8a26529 100644
--- a/doc/enginio_overview.qdoc
+++ b/doc/enginio_overview.qdoc
@@ -28,17 +28,26 @@
/*!
\page enginio-index.html
\contentspage {enginio-index.html}{Contents}
-\nextpage Enginio Installation and Prerequisites
+\nextpage Enginio Installation Notes and Prerequisites
\title Enginio Manual
-Enginio is a Backend-as-a-Service solution to ease backend development for any connected and data-driven application.
+This manual shows how to use the Enginio library in a Qt application.
+Both C++ and QML applications are covered. The manual is also used when
+integrating Enginio into an existing Qt project.
-\section1 Tutorials
+Enginio is a \l {http://en.wikipedia.org/wiki/Backend_as_a_service}
+{Backend-as-a-Service} solution for simplifying backend development
+of connected and data-driven applications.
+
+\section1 Getting Started
+
+First read the installation notes and prerequisites, then follow one
+of the short tutorials for using Enginio, either with QT Quick or with
+C++.
-To get started quickly, follow the mini-tutorial using Qt Quick or C++.
\list
-\li \l {Enginio Installation and Prerequisites}
+\li \l {Enginio Installation Notes and Prerequisites}
\li \l {Getting Started with Enginio using Qt Quick}
\li \l {Getting Started with Enginio using C++}
\endlist
@@ -47,26 +56,38 @@ To get started quickly, follow the mini-tutorial using Qt Quick or C++.
\list
\li \l {Enginio C++ Classes and Examples}
\li \l {Enginio QML Types and Examples}
+
+Enginio documentation is also available at the
+\l {https://developer.qtcloudservices.com} {Qt Cloud Services}
+website \l{http://engin.io/documentation/} {here}.
+
\endlist
-\section1 Overview
+\section1 Enginio Overview
-When using Enginio (with Qt Quick or C++), the API is following a general pattern that will be helpful to understand.
-This section gives a short, high-level overview of the concepts used throughout the library.
+The Enginio APIs have a general pattern that is useful to understand.
+This section gives a short overview of the API concepts used
+throughout the library.
-The Qt library is a client-side library to communicate with the server at \l {http://engin.io}.
-Several \e backends can exist for each account on the server.
-For all communication with the server, the \e backend is determined by its \e id.
-When shipping an application built with Enginio, the \c {backend id} will be the same for all users of that application.
+Enginio is a client-side library for communicating with the server
+at \l {http://engin.io}. Multiple \e backends can exist in each
+server account. When communicating with the server, the backend is
+specified by a \b {backend id}. When multiple users load an Enginio
+application, the all use the same \b {backend id}.
\section2 Objects
-Enginio provides several types of objects: \c {custom objects}, \c users, \c {user groups}, \e files, and more.
-All communication with the backend uses JSON. When writing QML, JSON can simply be written inline.
-On the C++ side, \l QJsonObject and \l QJsonValue are used.
+Enginio provides several types of objects. These include users, user
+groups, files, custom objects, and more. All communications with the
+backend use \l {http://json.org} {JSON}. When using the QML API, JSON
+objects are simply written inline. When using the C++ API, the
+\l QJsonObject and \l QJsonValue classes are used.
+
+Each JSON object in Enginio has the reserved properties \c id,
+\c objectType, \c createdAt, and \c updatedAt. For example,
+a custom object with no user-defined properties will look like
+this in JSON:
-Each object in the database has an \c id, \c objectType, \c createdAt and \c updatedAt property that are reserved and always exist.
-For example, a custom object with no additional properties (in JSON) might look like this:
\code
{
"id": "51cdbc08989e975ec300772a",
@@ -75,34 +96,58 @@ For example, a custom object with no additional properties (in JSON) might look
"updatedAt": "2013-06-28T16:38:32.725Z"
}
\endcode
-With this basis, the objects can be augmented with user defined properties that contain the actual application data and can
-even contain other objects.
-For a more detailed description see the \l{http://engin.io/documentation/overview/objects}{Enginio Object documentation}.
-\section2 Operations
+But custom object types are normally augmented with user-defined
+properties that contain the application-specific data. A user-defined
+property can also contain a JSON object. For a more detailed description of
+Enginio objects, see the \l{http://engin.io/documentation/overview/objects}
+{Enginio Object documentation}.
-To operate on objects of any type, the basic operations are:
-\list
-\li create: create a new object
-\li query: list objects
-\li update: change an object
-\li remove: delete an object
-\endlist
-
-For a detailed description of the operations see the functions
-in the \l [CPP] {EnginioClient} {EnginioClient Class} in C++ or
-\l [QML] {EnginioClient} {EnginioClient type} in QML.
+\section2 Operations
-\note User management and access control lists are conveniently done by the same functions.
+The basic operations on objects are shown in the table below.
+For a complete list of operations see the
+\l [CPP] {EnginioClient} {EnginioClient for C++} or the
+\l [QML] {EnginioClient} {EnginioClient for QML}.
+
+\table
+\header
+\li Operation
+\li Description
+\li C++
+\li QML
+\row
+\li create
+\li Insert a new object into the database
+\li \l [CPP] {EnginioClient::create()}
+\li \l [QML] {EnginioClient::create()}
+\row
+\li query
+\li Query the database
+\li \l [CPP] {EnginioClient::query()}
+\li \l [QML] {EnginioClient::query()}
+\row
+\li update
+\li Update an object in the database
+\li \l [CPP] {EnginioClient::update()}
+\li \l [QML] {EnginioClient::update()}
+\row
+\li remove
+\li Remove an object from the database
+\li \l [CPP] {EnginioClient::remove()}
+\li \l [QML] {EnginioClient::remove()}
+\endtable
+
+\note User and access control list management are also performed using
+these same functions.
\section2 File Management
-For file management, the operations are slightly different.
-Files are always attached to objects and can only be referenced through them.
-The Qt library provides convenient functions to upload and download files.
+For file management, these operations are slightly different in that
+files are always attached to objects and can only be accessed through
+their objects. The Qt library provides convenient functions to upload
+and download files.
-The entire Enginio documentation, including backend and client, is available here:
-\l{http://engin.io/documentation/}{Enginio Documentation}
*/
/*!
@@ -110,26 +155,60 @@ The entire Enginio documentation, including backend and client, is available her
\nextpage Getting Started with Enginio using Qt Quick
\previouspage {enginio-index.html}{Enginio Manual}
-\title Enginio Installation and Prerequisites
+\title Enginio Installation Notes and Prerequisites
+
+\section1 Installation Notes
-This guide shows how to use the Enginio Qt library in a Qt application
-(both Qt C++ and QML cases are covered).
-This guide can be also applied when integrating Enginio with existing Qt projects.
+Enginio is packaged with Qt beginning with Qt 5.2. When starting the
+Qt installation, ensure that the Enginio component in the \e {Qt Cloud
+Services} category is selected.
+
+Enginio requires OpenSSL to be installed, except for iOS, where the
+native SSL framework is used instead.
+
+\note For Qt 5.2.0, Enginio comes in the online installer only.
\section1 Prerequisites
-Enginio comes with Qt 5.2 and later (for 5.2.0 only in the online installer).
-Make sure to select the Enginio component in the \e {Qt Cloud Services} category.
+A Qt Account is required to use the
+\l{https://console.qtcloudservices.com} {Qt Cloud Services}. A Qt
+Account can be created at \l{Qt Account Sign-up}.
+
+To run an Enginio Client application to use
+\l{https://console.qtcloudservices.com} {Qt Cloud Services},
+the \c{backend id} of an Engino Data Storage Instance is required.
+
+Sign in to \l{https://console.qtcloudservices.com/login} {Qt Cloud
+Services} using the Qt Account. Under \uicontrol {Enginio Data
+Storage} (EDS), press the \uicontrol {Launch instance} button to create
+a new cloud instance. Enter the name for the new instance and select
+a data center. Then press \uicontrol {Create}.
+
+A dialog of the new instance appears showing the \uicontrol {General}
+tab. Here the instance \uicontrol {Name}, \uicontrol {ID}, and
+\uicontrol {Address} are shown. Select the \uicontrol {Environment}
+tab to show the \uicontrol {EDS_BACKEND_ID} and the
+\uicontrol {EDS_INSTANCE ADDRESS}. These values can be cut and pasted
+into the examples where required.
-\note Make sure to have OpenSSL installed for Enginio to work. On iOS, OpenSSL is not
-required as the native SSL framework is used.
+\note Some of the examples have built-in \uicontrol {EDS_BACKEND_ID}s.
+
+Select the \uicontrol {Configure} tab and press the \uicontrol {Open}
+button. This opens the dashboard for the new instance in a new browser
+tab. The dashboard is used for instance management.
+
+These instructions are also found in
+\l{https://developer.qtcloudservices.com/qtc/getting-started}
+{Getting Started With Qt Cloud Services}. Reading the documentation at
+\l{https://developer.qtcloudservices.com/} {Qt Cloud Services Developers}
+is also recommended.
*/
/*!
\page enginio-qml.html
\nextpage Getting Started with Enginio using C++
-\previouspage Enginio Installation and Prerequisites
+\previouspage Enginio Installation Notes and Prerequisites
\title Getting Started with Enginio using Qt Quick
\brief Introduction to using Enginio using Qt Quick
@@ -138,19 +217,19 @@ required as the native SSL framework is used.
Create a new \l [QtQuick] {Qt Quick} {Qt Quick 2} Application.
-You can use Qt Creator to get started with a template.
-(File ⇒ New File or Project ⇒ Applications ⇒ Qt Quick 2 Application)
+Qt Creator can be used to create a template.
+\uicontrol {File ⇒ New File or Project ⇒ Applications ⇒ Qt Quick 2 Application}
\section1 Initialize Enginio Client
-To use Enginio's QML API, you have to import the library.
-\code
+To use Enginio's QML API, the Enginio library must be imported.
+\badcode
import Enginio 1.0
\endcode
-Initialize the \l [QML] {EnginioClient} with the \c {backend id} value, which can be copied from the Dashboard.
+Initialize the \l [QML] {EnginioClient} with the \b {backend id} value, which can be copied from the Dashboard.
-Go to Dashboard ⇒ Your Backend home-view ⇒ See ’Keys box’ ⇒ Copy backend id value.
+Go to \uicontrol{Dashboard ⇒ The Backend home-view ⇒ See ’Keys box’ ⇒ Copy backend id value}.
\code
EnginioClient {
@@ -159,9 +238,9 @@ EnginioClient {
}
\endcode
-\section1 Store your first Object
+\section1 Store the First Object
-Now you can store an \e object with Enginio. First, create an \e object in JSON format and fill it with data as needed.
+Now an \e object can be stored with Enginio. First, create an \e object in JSON format and fill it with data as needed.
Then call create on the client with the JSON object as a parameter.
\code
@@ -175,7 +254,7 @@ Component.onCompleted: {
}
\endcode
-Now you can \l{Checking stored objects in the Dashboard}{check the Enginio dashboard} for the newly created object.
+\l{Checking stored objects in the Dashboard}{Check the Enginio dashboard} for the newly created object.
*/
@@ -187,35 +266,36 @@ Now you can \l{Checking stored objects in the Dashboard}{check the Enginio dashb
\title Getting Started with Enginio using C++
\brief Introduction to using Enginio using C++
-\section1 Setup Qt application project
+\section1 Setup Qt Application Project
-You need to link to Enginio. For qmake-based projects simply add
-\code
+To link to Enginio in a qmake-based project, add the line shown below
+to the \c .pro file.
+
+\badcode
QT += enginio
\endcode
-to your \c .pro file.
\section1 Initialize Enginio Client
-To use the Enginio Qt library in your code, you have to include relevant library headers.
+To use the Enginio library, the required library headers must be included.
\code
#include <Enginio/Enginio>
\endcode
-Before making any calls to the Enginio API, the \l EnginioClient needs to be instantiated.
-To do this, you will also need the \c {id} of the backend, which can be copied from the Dashboard.
-Go to the \l{https://dashboard.engin.io/}{Enginio Dashboard} and select a backend.
-Copy the \c {backend id} value.
+Then an \l EnginioClient must be instantiated. The client requires
+a \c{backend id}, which can be copied from the Dashboard. Go to the
+\l{https://dashboard.engin.io/}{Enginio Dashboard} and select a backend.
+Copy the \b {backend id} value.
\code
QByteArray backendId("YOUR_OWN_BACKEND_ID");
EnginioClient *client = new EnginioClient;
client->setBackendId(backendId);
\endcode
-For testing purposes, it is easiest to hardcode the \c {backend id} directly into application code.
+For testing purposes, it is easiest to hardcode the \b {backend id} directly into application code.
However, this might not be always the best choice, and sometimes it might be beneficial
to put the backend configuration in a separate configuration file.
-\section1 Store your first Object
+\section1 Storing the First Object
Create an object in JSON format and fill in the data:
\code
@@ -231,9 +311,9 @@ Create the object in the Enginio database by calling \l {EnginioClient::create()
connect(client, SIGNAL(finished(EnginioReply*)), this, SLOT(uploadFinished(EnginioReply*)));
\endcode
Note that the \l {EnginioClient::create()} {create()} method performs the actual asynchronous network communication.
-You need to wait for its completion by connecting to the \l{EnginioClient::finished()}{finished} and \l{EnginioClient::error()}{error} signals.
+Wait for completion by connecting to the \l{EnginioClient::finished()}{finished} and \l{EnginioClient::error()}{error} signals.
-Now you can \l{Checking stored objects in the Dashboard}{check the Enginio dashboard} for the newly created object.
+\l{Checking stored objects in the Dashboard}{Check the Enginio dashboard} for the newly created object.
*/
@@ -242,8 +322,9 @@ Now you can \l{Checking stored objects in the Dashboard}{check the Enginio dashb
\title Checking Stored Objects in the Dashboard
\previouspage Getting Started with Enginio using C++
-When you have successfully stored objects with Qt C++ or QML code, go to your \l{https://dashboard.engin.io/}{Enginio Dashboard}
-and check the status there.
+When objects have been stored in the database using either the C++ or
+the QML code, go to the \l{https://dashboard.engin.io/}
+{Enginio Dashboard} and check the status there.
\list
\li Select the Objects view from the top navigation bar.
@@ -261,7 +342,7 @@ To get convenient access to objects stored in Enginio, consider using \l Enginio
\title Enginio Tutorials
\list
-\li \l {Enginio Installation and Prerequisites}
+\li \l {Enginio Installation Notes and Prerequisites}
\li \l {Getting Started with Enginio using Qt Quick}
\li \l {Getting Started with Enginio using C++}
\endlist
diff --git a/examples/enginio/quick/image-gallery/doc/src/image-gallery.qdoc b/examples/enginio/quick/image-gallery/doc/src/image-gallery.qdoc
index 923b300..617214a 100644
--- a/examples/enginio/quick/image-gallery/doc/src/image-gallery.qdoc
+++ b/examples/enginio/quick/image-gallery/doc/src/image-gallery.qdoc
@@ -64,17 +64,17 @@
\section1 The example code
- The first step is to set up the \l Enginio::EnginioClient client.
+ The first step is to set up the \l {EnginioClient} {Enginio client}.
\snippet image-gallery/image-gallery.qml client
- The model gets initialized with the client declared above.
+ Then the model is initialized with that client.
\snippet image-gallery/image-gallery.qml model
A delegate is needed to present the images nicely.
The model is used to get the list of image objects, but the images
are only attached to the objects as file references.
Thus the image's thumbnail is fetched by each delegate.
- \note in a real application it might be necessary to cache the images.
+ \note In a real application it might be necessary to cache the images.
The \c Component.onCompleted function is used to fetch the image.
When the delegate is created, it has the JSON image object data.
diff --git a/examples/enginio/quick/todos/doc/src/todos.qdoc b/examples/enginio/quick/todos/doc/src/todos.qdoc
index 7a150be..d31e804 100644
--- a/examples/enginio/quick/todos/doc/src/todos.qdoc
+++ b/examples/enginio/quick/todos/doc/src/todos.qdoc
@@ -31,17 +31,21 @@
\ingroup enginio-qml-examples
\inmodule enginio-qml
- In this example a simple list of objects is displayed in a ListView.
- Each item in the list is a "To Do" object which can be \e done or \e{not yet done}.
- Todos can be added and removed (when hovering with the mouse).
+ In this example a simple list of objects is displayed in a
+ ListView. Each item in the list is a "To Do" object which can be
+ \e done or \e{not yet done}. Todos can be added and removed (when
+ hovering with the mouse).
+
\image todolist.png
- In this simple schema the objects will only have two properties that are added
- to the default properties (such as creation date, which always exists):
- a string \c title and a bool \c completed. The object type will be created
- when a call to create, or, in this case, a call to \l{Enginio::EnginioModel::append()}{EnginioModel::append()} is made.
+ In this simple schema, the objects will only have two properties
+ that are added to the default properties (such as creation date,
+ which always exists): a string \c title and a bool \c completed.
+ The object type will be created when a call to create, or, in this
+ case, a call to \l{EnginioModel::append()}{EnginioModel::append()}
+ is made.
- A todo object will look like this (in JSON):
+ A todo object will look like this in \l {http://json.org} {JSON}:
\code
{
"title": "Buy Milk",
@@ -52,11 +56,12 @@
The example uses Qt Quick Controls, Layouts, and Enginio.
\snippet todos/todo.qml imports
- The first step is to create an \l{Enginio::EnginioModel} and
- the Enginio instance with the backend configuration.
- To get nice debug output in case something goes wrong, the onError signal in
- Enginio is handled. Since the error is a JSON object, JSON.stringify is used
- to format it to a string.
+ The first step is to create an \l{Enginio::EnginioModel} {Enginio model} and
+ its \l {EnginioClient} {Enginio client} with the backend configuration.
+ To get nice debug output in case something goes wrong, the client's
+ \l {EnginioClient::error} {onError} signal handler is implented. Since the
+ error is a \l {http://www.ecma-international.org/ecma-262/5.1/#sec-15.12}
+ {JSON object}, JSON.stringify is used to format it to a string.
\snippet todos/todo.qml model
@@ -64,15 +69,19 @@
properties of the Enginio objects are used.
\snippet todos/todo.qml view
- It is easy to add a new object to the model. By using the \l onAccepted
- signal handler of a \l TextField, the data is appended to the model. After appending
- the new Todo, the text gets cleared so that a new Todo can be entered.
+ It is easy to add a new Todo object to the model using a \l {TextInput}.
+ By implementing the \l {TextInput::accepted} {onAccepted} signal handler,
+ the Todo data is appended to the model. After appending the new Todo, the
+ \l {TextInput::text} {text property} is cleared so that the next Todo can
+ be entered.
\snippet todos/todo.qml append
- Inside the delegate, the data for the index is available by using the property names (\e title and \e completed).
- The \e title property is directly assigned to the text displayed on each list item. The \e completed
- boolean is used to display the item with a strikeout font and a light color.
+ Inside the delegate, the data for the index is available by using
+ the property names (\e title and \e completed). The \e title
+ property is directly assigned to the text displayed on each list
+ item. The \e completed boolean is used to display the item with a
+ strikeout font and a light color.
\snippet todos/todo.qml delegate-properties
diff --git a/examples/enginio/widgets/todos-cpp/doc/src/todos-cpp.qdoc b/examples/enginio/widgets/todos-cpp/doc/src/todos-cpp.qdoc
index 69445d4..114e614 100644
--- a/examples/enginio/widgets/todos-cpp/doc/src/todos-cpp.qdoc
+++ b/examples/enginio/widgets/todos-cpp/doc/src/todos-cpp.qdoc
@@ -27,21 +27,25 @@
/*!
\title Enginio C++ Examples - Todos
\example todos-cpp
- \brief The Todo example shows how to use the \l {EnginioModelCpp}{EnginioModel} with Qt Widgets.
+ \brief The Todo example shows how to use the \l {EnginioModel} with Qt Widgets.
\ingroup enginio-examples
\inmodule enginio-qt
- In this example, a simple list of objects is displayed in a \l QListView.
- Each item in the list is a "To Do" object which can be "done" or "not yet done".
- Todos can be added, removed, or altered.
+ In this example, a list of objects is displayed in a \l QTreeView.
+ Each item in the list is a \c {Todo} object, which can be marked
+ \c {Done} or \c {Not done}. A \c {Todo} can be added, removed,
+ or altered. We will be using the classes and concepts duscussed in
+ \l {Model/View Programming} {Model/View Programming}.
+
\image todo-example.png
- In this simple schema the objects will have two properties that are added
- to the default properties (such as creation date which always exists):
- a string "title" and a bool "completed". The object type will be created
- when a call to create, or in this case EnginoModel::append(), is made.
+ In this simple schema, each \c {ToDo} object will have two properties:
+ a \c {string} named \c {title} and a \c {bool} named \c {completed}.
+ These properties are added to the default properties e.g.: creation date,
+ which always exist.
+
+ A \c {Todo} object will look like this in \l {http://json.org} {JSON}:
- A todo object will look like this (in JSON):
\code
{
"title": "Buy Milk",
@@ -49,34 +53,67 @@
}
\endcode
- The first step is to create a TodosModel which inherits \l [CPP] {EnginioModel},
- and defines the main roles which will be used. As we are interested in the To Do \c title
- and the \c completed information we need to define these two roles.
- \snippet todos-cpp/todosmodel.h definition
-
- By default, views (for example \l QListView) use the \l{Qt::ItemDataRole} role to display or edit the content.
- The newly created \l [CPP] {EnginioModel} is empty and defines basic roles. Most roles are created
- dynamically, based on the JSON datastructure. They have no predefined value in the \l Qt::ItemDataRole enum.
- \l [CPP] {EnginioModel} automatically populates itself as soon as the
- \l{EnginioModel::query}{query} and \l{EnginioModel::client}{client} properties have been set.
- When the data is downloaded, the model resets itself, and sets up the internal data cache and roles names.
- \l [CPP] {EnginioModel} guesses the role names based on heuristics. It may be wrong if not all
- objects received from the backend have exactly the same structure. For example, a property can be missing
- in certain objects. To protect against such cases, we overload \l{EnginioModel::roleNames()}{roleNames()}.
- Overriding \l{EnginioModel::roleNames()}{roleNames()} can also be used to match default Qt roles to the named
- ones.
+ A ToDo object can be created and appended to an EnginioModel using
+ \l {EnginioModel::append()} {append()}, as shown in
+ \l {mainwindow_appenditem} {MainWindow::appendItem()}. Alternatively,
+ if many ToDo objects are to be added to the model all at once, they
+ can be inserted directly into the server database via the model's
+ \l {EnginioClient} {Enginio client}. The client is obtained from
+ the model with \l {EnginioModel::client()} {client()}. Then the
+ ToDo objects are inserted into the server database with the client's
+ \l {EnginioClient::create()} {create()} function. The model can then
+ be reloaded from the server with \l {EnginioModel::reload()} {reload()}.
+
+ But first we must create some infrastructure. Our \c{TodosModel}
+ class is declared in \l{todos-cpp/todosmodel.h}. It inherits
+ \l[CPP]{EnginioModel}, which is a \l{QAbstractListModel}{list
+ model}. We add two roles to the \l {Enginio::Role} {Enginio::Role
+ enum}, chosen for the new properties, one for the ToDo \c title
+ and one for marking a ToDo as \c{completed}. We assign enum values
+ to the new roles, equating \c{TitleRole} to
+ \l{Enginio::CustomPropertyRole}, which is itself equated to
+ \l{Qt::UserRole} + 10. \snippet todos-cpp/todosmodel.h definition
+
+ The new roles can be used for displaying and editing the values of
+ the new properties. Views of the model also use roles from in
+ \l{Qt::ItemDataRole} enum. The example's view is a \l {QTreeView},
+ as shown in the \l{todos-cpp/mainwindow.h} {MainWindow class},
+ which holds a pointer to the view, a pointer to the
+ \l{EnginioClient} {client}, and a pointer to the
+ \l{todos-cpp/todosmodel.h} {model}.
+
+ A new \l [CPP] {EnginioModel} is empty. It automatically populates itself
+ from the server, when its \l{EnginioModel::query}{query} and
+ \l{EnginioModel::client}{client} properties have both been set. In the
+ example, these properties are set in the constructor for the
+ \l {todos-cpp/mainwindow.cpp} {main window}. The \l {EnginioClient} is
+ created first. Then an instance of the \c ToDosModel is created, and its
+ client is set using EnginioModel::setClient(). Then the query is created
+ as a QJsonObject, and the model's query is set using EnginioModel::setQuery().
+
+ Once the ToDo data has been downloaded, the model resets itself, and sets up
+ the internal data cache and roles names. \l [CPP] {EnginioModel} guesses the
+ role names based on heuristics. It may be wrong if not all objects received
+ from the backend have exactly the same structure. For example, a property can
+ be missing in certain objects. To protect against such cases, we overload
+ \l{EnginioModel::roleNames()}{roleNames()}. Overriding
+ \l{EnginioModel::roleNames()}{roleNames()} can also be used to
+ match default Qt roles to the named ones.
\snippet todos-cpp/todosmodel.cpp roleNames
- In this example we map the \l Qt::DisplayRole and \l Qt::EditRole to the \c title property in the JSON.
- This way the right string is shown by default and editing works as expected.
+ In this example, we map the \l Qt::DisplayRole and \l Qt::EditRole
+ to the \c title property in the JSON. This way the right string
+ is shown by default and editing works as expected.
- Remember to always call the base class implementation to avoid situations in which the internal cache is not in sync.
+ Remember to always call the base class implementation to avoid
+ situations in which the internal cache is not in sync.
- By default \l [CPP] {EnginioModel} operates on \l{QJsonValue}, and that is
- what the \l{EnginioModel::data()}{data()} function returns inside the \l QVariant, but standard
- views, such as \l QListView, use predefined roles which do not map directly to our roles.
- That is why we need to write a mapping between them:
+ By default \l [CPP] {EnginioModel} operates on \l{QJsonValue}, and
+ that is what the \l{EnginioModel::data()}{data()} function returns
+ inside the \l QVariant, but standard views, such as \l QListView,
+ use predefined roles which do not map directly to our roles. That
+ is why we need to write a mapping between them:
\snippet todos-cpp/todosmodel.cpp data
@@ -84,19 +121,23 @@
\snippet todos-cpp/mainwindow.cpp client
- It is used by the model to connect to the Enginio backend. Next we need to construct
- and configure our model too. The configuration is based on two steps, assigning
- an \l {EnginioClient} instance and by creating a query.
+ It is used by the model to connect to the Enginio backend. Next we
+ need to construct and configure our model too. The configuration
+ is based on two steps, assigning an \l {EnginioClient} instance
+ and by creating a query.
\snippet todos-cpp/mainwindow.cpp model
- The model has to be assigned to a view. In our case it is a \l QListView.
+ The model has to be assigned to a view. In this example it is a
+ \l QTreeView.
\snippet todos-cpp/mainwindow.cpp assignModel
- To make the application fully functional, a way to add and remove "To Dos" is needed.
- To do so, we need to connect the correct buttons to slots for adding a new item:
+ To make the application fully functional, a way to add and remove
+ a Todo is needed. To do so, we need to connect the correct
+ buttons to slots for adding a new item:
+ \target mainwindow_appenditem
\snippet todos-cpp/mainwindow.cpp appendItem
and for removing it:
diff --git a/src/enginio_plugin/enginioplugin.cpp b/src/enginio_plugin/enginioplugin.cpp
index b1dd50b..db737f2 100644
--- a/src/enginio_plugin/enginioplugin.cpp
+++ b/src/enginio_plugin/enginioplugin.cpp
@@ -48,11 +48,11 @@
QT_BEGIN_NAMESPACE
/*!
- * \qmlmodule Enginio 1.0
- * \title Enginio QML Plugin
- *
- * The Enginio QML plugin provides access to the Enginio service through a set of
- * QML types.
+ \qmlmodule Enginio 1.0
+ \title Enginio QML Plugin
+
+ The Enginio QML plugin provides access to the Enginio service through a set of
+ QML types.
*/
class EnginioNetworkAccessManagerFactory: public QQmlNetworkAccessManagerFactory
@@ -97,4 +97,14 @@ void EnginioPlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<QNetworkReply>(uri, 1, 0, "QNetworkReply", "QNetworkReply is abstract and it can not be constructed");
}
+/*!
+ \qmltype EnginioOAuth2Authentication
+ \since 5.3
+ \instantiates EnginioOAuth2Authentication
+ \inqmlmodule Enginio
+ \ingroup engino-qml
+ \target EnginioOAuth2AuthenticationQml
+
+*/
+
QT_END_NAMESPACE