From beaca75d17de2c1b0cfe1c70a1f3d37a3f8ac669 Mon Sep 17 00:00:00 2001 From: Andrew O'Doherty Date: Thu, 1 Feb 2018 13:27:28 +0100 Subject: Revamp Qt NFC examples: documentation update Update the documentation of the ndefeditor example Task-number: QTBUG-60644 Change-Id: Id74ee10565dd812fcf51db151f641549d3d60682 Reviewed-by: Maurice Kalinowski Reviewed-by: Alex Blasche --- examples/nfc/ndefeditor/doc/images/ndefeditor.png | Bin 24397 -> 13445 bytes examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc | 78 ++++++++++++++++++++-- examples/nfc/ndefeditor/mainwindow.cpp | 8 +-- examples/nfc/ndefeditor/mainwindow.h | 3 +- examples/nfc/ndefeditor/mimeimagerecordeditor.h | 4 +- examples/nfc/ndefeditor/textrecordeditor.h | 4 +- examples/nfc/ndefeditor/urirecordeditor.h | 5 +- 7 files changed, 86 insertions(+), 16 deletions(-) (limited to 'examples') diff --git a/examples/nfc/ndefeditor/doc/images/ndefeditor.png b/examples/nfc/ndefeditor/doc/images/ndefeditor.png index 9a5fbba7..d203e474 100644 Binary files a/examples/nfc/ndefeditor/doc/images/ndefeditor.png and b/examples/nfc/ndefeditor/doc/images/ndefeditor.png differ diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc index ed7d2bba..eb638200 100644 --- a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc +++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc @@ -3,7 +3,7 @@ ** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the documentation of the Qt local connectivty modules. +** This file is part of the documentation of the Qt local connectivity modules. ** ** $QT_BEGIN_LICENSE:FDL$ ** Commercial License Usage @@ -30,12 +30,82 @@ \title NDEF Editor Example \brief An example about reading and writing NFC Data Exchange Format (NDEF) messages to NFC Forum Tags. -The NDEF Editor example reads and writes NFC Data Exchange Format (NDEF) -messages to NFC Forum Tags. NDEF messages can be composed by adding records of -supported types. +The NDEF Editor example reads and writes NFC Data Exchange Format +(NDEF) messages to NFC Forum Tags. NDEF messages can be composed by +adding records of supported types. Additionally, NDEF messages can be +loaded/saved from/into a file located in the file system of the +machine where the application is running. \image ndefeditor.png +\section1 NFC Tag detection + +The MainWindow class is able to detect if a NFC Tag is in the range +for read/write operations. It can also detect if connectivity has been +lost. This is achieved by connecting the MainWindow class private +handlers to the signals QNearFieldManager::targetDetected and +QNearFieldManager::targetLost. + +\snippet ndefeditor/mainwindow.cpp QNearFieldManager init + +Through the UI a user requests when to start the detection of a NFC +Tag by calling the method QNearFieldManager::startTargetDetection. + +\snippet ndefeditor/mainwindow.cpp QNearFieldManager start detection + +Once the target is detected the MainWindow connects the following +signals to its internal private slots: +QNearFieldTarget::ndefMessageRead, QNearFieldTarget::NdefReadError, +QNearFieldTarget::ndefMessagesWritten, +QNearFieldTarget::NdefWriteError and QNearFieldTarget::error + +\snippet ndefeditor/mainwindow.cpp QNearFieldTarget detected + +If during the process of reading or writing to a NFC Tag the +connection is lost, the MainWindow reacts to this event by +scheduling the target deletion (QObject::deleteLater). + +\snippet ndefeditor/mainwindow.cpp QNearFieldTarget lost + +\section1 Record creation + +The main window of the ndefeditor example manages the composition and +creation of NFC records. The UI contains a QScrollArea where +RecordEditors are added dynamically on a user requests basis. The +following methods of the MainWindow class provide an interface towards +each of the record editing classes managing the different types of +records. + +\snippet ndefeditor/mainwindow.h 0 + +The following sections explain each of the record editing classes. +\section1 Record editing classes + +\section2 TextRecordEditor + +The TextRecordEditor is a QWidget that can handle editing the values +of text record that has been requested by the user. For each text +record, there is a new instance of this class. + +\snippet ndefeditor/textrecordeditor.h 0 + +\section2 UriRecordEditor + +The UriRecordEditor is a QWidget that can handle editing the values of +Uri record that has been requested by the user. For each new Uri +record there is a new instance of this class. + +\snippet ndefeditor/urirecordeditor.h 0 + +\section2 MimeImageRecordEditor + +The UriRecordEditor is a QWidget that can handle editing the values of +a Mime Image record that has been requested by the user. For each Mime +Image record there is a new instance of this class. + +\snippet ndefeditor/mimeimagerecordeditor.h 0 + + \include examples-run.qdocinc \sa {Qt NFC} diff --git a/examples/nfc/ndefeditor/mainwindow.cpp b/examples/nfc/ndefeditor/mainwindow.cpp index 41077c2d..38865b88 100644 --- a/examples/nfc/ndefeditor/mainwindow.cpp +++ b/examples/nfc/ndefeditor/mainwindow.cpp @@ -143,10 +143,10 @@ MainWindow::MainWindow(QWidget *parent) //! [QNearFieldManager init] m_manager = new QNearFieldManager(this); - connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)), - this, SLOT(targetDetected(QNearFieldTarget*))); - connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)), - this, SLOT(targetLost(QNearFieldTarget*))); + connect(m_manager, &QNearFieldManager::targetDetected, + this, &MainWindow::targetDetected); + connect(m_manager, &QNearFieldManager::targetLost, + this, &MainWindow::targetLost); //! [QNearFieldManager init] } diff --git a/examples/nfc/ndefeditor/mainwindow.h b/examples/nfc/ndefeditor/mainwindow.h index 9018cbfb..234efcd2 100644 --- a/examples/nfc/ndefeditor/mainwindow.h +++ b/examples/nfc/ndefeditor/mainwindow.h @@ -73,11 +73,12 @@ public: ~MainWindow(); private slots: + //! [0] void addNfcTextRecord(); void addNfcUriRecord(); void addMimeImageRecord(); void addEmptyRecord(); - + //! [0] void clearMessage(); void loadMessage(); diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.h b/examples/nfc/ndefeditor/mimeimagerecordeditor.h index 1e810f64..44cd084b 100644 --- a/examples/nfc/ndefeditor/mimeimagerecordeditor.h +++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.h @@ -64,7 +64,7 @@ namespace Ui { } QT_END_NAMESPACE - +//! [0] class MimeImageRecordEditor : public QWidget { Q_OBJECT @@ -83,5 +83,5 @@ private: private slots: void on_mimeImageOpen_clicked(); }; - +//! [0] #endif // MIMEIMAGERECORDEDITOR_H diff --git a/examples/nfc/ndefeditor/textrecordeditor.h b/examples/nfc/ndefeditor/textrecordeditor.h index d7bf4d2e..df3a872c 100644 --- a/examples/nfc/ndefeditor/textrecordeditor.h +++ b/examples/nfc/ndefeditor/textrecordeditor.h @@ -61,8 +61,7 @@ namespace Ui { } QT_END_NAMESPACE -QT_USE_NAMESPACE - +//! [0] class TextRecordEditor : public QWidget { Q_OBJECT @@ -77,5 +76,6 @@ public: private: Ui::TextRecordEditor *ui; }; +//! [0] #endif // TEXTRECORDEDITOR_H diff --git a/examples/nfc/ndefeditor/urirecordeditor.h b/examples/nfc/ndefeditor/urirecordeditor.h index 7eee55eb..aa3f4dfc 100644 --- a/examples/nfc/ndefeditor/urirecordeditor.h +++ b/examples/nfc/ndefeditor/urirecordeditor.h @@ -61,8 +61,7 @@ namespace Ui { } QT_END_NAMESPACE -QT_USE_NAMESPACE - +//! [0] class UriRecordEditor : public QWidget { Q_OBJECT @@ -77,5 +76,5 @@ public: private: Ui::UriRecordEditor *ui; }; - +//! [0] #endif // URIRECORDEDITOR_H -- cgit v1.2.3