summaryrefslogtreecommitdiffstats
path: root/examples/demos/addressbook/doc
diff options
context:
space:
mode:
authorKonrad Kujawa <konrad.kujawa@qt.io>2022-08-24 16:00:11 +0200
committerKonrad Kujawa <konrad.kujawa@qt.io>2022-09-08 09:31:10 +0200
commitce3ba5df2a011033f366fcc7279198f732ae311a (patch)
tree0393116e8b0f8a89a1bd2b8fb2878c9aa51da27a /examples/demos/addressbook/doc
parentd87e31ab366a8d99ca2af3dcdd85eb87d2a20ccb (diff)
Qt Quick UI for the RESTful Address Book
Add UI and client side extension for the RESTful Address Book example Fixes: QTBUG-105199 Change-Id: I01c5e2ac44838f01ccbb73d5b6e1d1e578c67618 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit 91e567ba53bf8c7be9aff8feb00e46f978937290) Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples/demos/addressbook/doc')
-rw-r--r--examples/demos/addressbook/doc/images/addressbookclient.pngbin0 -> 39190 bytes
-rw-r--r--examples/demos/addressbook/doc/images/authorize.pngbin0 -> 33509 bytes
-rw-r--r--examples/demos/addressbook/doc/images/newcontact.pngbin0 -> 46340 bytes
-rw-r--r--examples/demos/addressbook/doc/src/addressbook-client-example.qdoc70
4 files changed, 70 insertions, 0 deletions
diff --git a/examples/demos/addressbook/doc/images/addressbookclient.png b/examples/demos/addressbook/doc/images/addressbookclient.png
new file mode 100644
index 000000000..9ed284464
--- /dev/null
+++ b/examples/demos/addressbook/doc/images/addressbookclient.png
Binary files differ
diff --git a/examples/demos/addressbook/doc/images/authorize.png b/examples/demos/addressbook/doc/images/authorize.png
new file mode 100644
index 000000000..16ad5e709
--- /dev/null
+++ b/examples/demos/addressbook/doc/images/authorize.png
Binary files differ
diff --git a/examples/demos/addressbook/doc/images/newcontact.png b/examples/demos/addressbook/doc/images/newcontact.png
new file mode 100644
index 000000000..df351c371
--- /dev/null
+++ b/examples/demos/addressbook/doc/images/newcontact.png
Binary files differ
diff --git a/examples/demos/addressbook/doc/src/addressbook-client-example.qdoc b/examples/demos/addressbook/doc/src/addressbook-client-example.qdoc
new file mode 100644
index 000000000..23bcfe37f
--- /dev/null
+++ b/examples/demos/addressbook/doc/src/addressbook-client-example.qdoc
@@ -0,0 +1,70 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
+
+/*!
+\ingroup qtquickdemos
+\example demos/addressbook
+\title Qt Quick Demo - RESTful API client Address Book
+\brief Example of how to create a RESTful API client.
+\image addressbookclient.png
+
+This example shows how to create a basic QML application with address book
+functionality.
+The application uses RESTful communication with a given server to send
+requests and retrieve data.
+
+The application allows users to add new contacts by clicking the
+'Add Contact' button and then entering the data for the record and
+clicking the 'Add' button (see image below).
+\image newcontact.png
+
+The Address Book application gives you the ability to delete an entry,
+by clicking the 'Delete' button next to the entry, and update by updating
+the data in the table.
+
+In order to use the modification features, users must authorize themselves
+by providing a key and value, which will be used in communication
+with the RESTful API.
+\image authorize.png
+
+To run the client application, first run the
+\l {RESTful server Address Book Example} {Address Book server example}
+in the background or use an already running server that provides used API.
+Then run the client application, to run it host and port arguments must be provided,
+for example:
+\code
+./addressbookclient --host http://127.0.0.1 --port 62122
+\endcode
+
+This example application uses QNetworkAccessManager
+which is wrapped in the \c RestAccessManager class.
+
+\snippet demos/addressbook/restaccessmanager.cpp Connect QNetworkAccessManager example
+The code snippet above shows how to connect QNetworkAccessManager to this wrapper.
+First, a connection to the server is established
+and the QNetworkAccessManager::setAutoDeleteReplies method is called to simplify
+the QNetworkReply deletion.
+Then QObject::connect is used to call the internal \c RestAccessManager::readContacts
+after the QNetworkReply is ready to be processed.
+
+\snippet demos/addressbook/restaccessmanager.cpp Update contacts signal example
+This method asynchronously processes each QNetworkReply
+for each request sent via QNetworkAccessManager.
+When the response is an array, that practically means that RestAccessManage
+got a new list of the contacts, so it has to update it.
+When the response is different, it means that the corresponding request
+has changed the list of contacts and it needs to be retrieved from the server.
+
+\snippet demos/addressbook/restaccessmanager.cpp GET contacts example
+To send a \c GET request, the QNetworkAccessManager::get method is used
+with the prepared QNetworkRequest.
+QNetworkRequest::setHeader is used to ensure correct encoding of the content.
+
+\snippet demos/addressbook/restaccessmanager.cpp POST contacts example
+To send the \c POST request, a similar approach can be used.
+In addition, to set the authorization header
+QNetworkRequest::setRawHeader was used.
+
+
+\sa {RESTful server Address Book Example}
+*/