diff options
author | Andrew O'Doherty <andrew.odoherty@qt.io> | 2018-02-01 12:46:32 +0100 |
---|---|---|
committer | Andrew O'Doherty <andrew.odoherty@qt.io> | 2018-03-05 14:37:54 +0000 |
commit | a0188acf80824e26632b8e008c22a4d2074d909a (patch) | |
tree | aee0c462a35451ea0c555d4f69362442223eb28a /examples/nfc/corkboard/doc/src/corkboard.qdoc | |
parent | 3d93b58fcc36f556a90613750a3150d56379b2a4 (diff) |
Revamp Qt NFC examples: documentation update
Update the documentation of annotatedurl and corkboard examples
Task-number: QTBUG-60644
Change-Id: Ide980dd2573e443bc54553cd2916ac6b209da2c9
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples/nfc/corkboard/doc/src/corkboard.qdoc')
-rw-r--r-- | examples/nfc/corkboard/doc/src/corkboard.qdoc | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/examples/nfc/corkboard/doc/src/corkboard.qdoc b/examples/nfc/corkboard/doc/src/corkboard.qdoc index 29ad8eac..ac21187b 100644 --- a/examples/nfc/corkboard/doc/src/corkboard.qdoc +++ b/examples/nfc/corkboard/doc/src/corkboard.qdoc @@ -30,13 +30,106 @@ \title QML CorkBoard Example \brief A QML example about displaying NFC Data Exchange Format (NDEF) messages. -The QML CorkBoard example displays the contents of NDEF messages read from an -NFC Tag. Each newly detected NDEF message is added to the corkboard and can be -dragged into an arbitrary position on the board. The corkboard has a \e Personal -and \e Work space. The workspace can be changed by sliding left or right. +The QML corkboard example displays the contents of NDEF messages read +from an NFC Tag. Each newly detected NDEF message is added to the +corkboard and can be dragged into an arbitrary position on the +board. The corkboard has a \e Personal and \e Work space. The +workspace can be changed by sliding left or right. + \image corkboard.png +\section1 Implementation details +In the corkboard example, we use the following .qml files: + \list + \li corkboards.qml + \li Mode.qml + \endlist + +The main.cpp holds the application logic to load the main view stored +in the corkboards.qml file. + +\snippet corkboard/main.cpp 0 + +\section1 corkboards.qml details +There are two basic QML components in this file: + \list + \li NearField + \li ListView + \endlist + +The first time the NearField QML type is instantiated, the +Component.onCompleted handler will start the NFC polling process. The +\l [Qml] {NearField} {onMessageRecordsChanged} handler parses NFC +Messages that are detected by the NearField component and builds up a +data model that is passed into the ListView. Additionally, every time the +NearField manager stops the polling process, the onPollingChanged +handler restarts it. + +\quotefromfile corkboard/corkboards.qml +\skipto NearField +\printuntil onMessageRecordsChanged +\dots 8 +\skipuntil } +\skipto onPollingChanged +\printuntil onPollingChanged +\dots 8 +\skipuntil } +\skipto Component +\printuntil Component +\dots 8 +\skipuntil } +\printline } +\skipto ListModel +\printto ListModel + +The ListView component takes a ListModel as parameter (built from the +NFC records). The view of each of the items of the model is defined by +the Mode component (its implementation details can be found in the +file Mode.qml). The data model consists of a list of corkboards. Each +corkboard can display multiple NFC text message records. + +\quotefromfile corkboard/corkboards.qml +\skipto ListView +\printuntil id +\dots 8 +\skipto model +\printuntil model +\dots 8 +\skipto delegate +\printuntil delegate +\skipto } +\printline } + +\section1 Mode.qml details + +A corkboard title is displayed for each of the items that form part +of the data model: + +\quotefromfile corkboard/Mode.qml +\skipto Text +\printuntil } +\printuntil } + +Every text record that was read from an NFC message, is represented by +a sticky note with its own position on the display. Initially the +position is set randomly. The text on the sticky note is set on a +TextField. + +\quotefromfile corkboard/Mode.qml +\skipto Repeater +\printuntil y: +\skipto Item +\dots 16 +\printuntil sticky +\dots 20 +\skipto TextEdit +\printuntil noteText +\dots 24 +\skipto } +\printuntil } +\dots 20 + \include examples-run.qdocinc \sa {Qt NFC} |