/**************************************************************************** ** ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the QtNfc module. ** ** $QT_BEGIN_LICENSE:FDL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free ** Documentation License version 1.3 as published by the Free Software ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements ** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ /*! \example corkboard \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. \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} */