summaryrefslogtreecommitdiffstats
path: root/examples/nfc
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2012-09-25 15:20:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 14:43:52 +0200
commitd8a179128c0fa8e9cc482df58b9334c696602be6 (patch)
treedd5032440aa87dfd63c973265adc9947db0918f6 /examples/nfc
parent9d89c661395347bdda9362a77d38c86ad60f486b (diff)
Qt Bluetooth: Modularized documentation
-moved documentation to src/bluetooth/doc -added a qdocconf file for Qt Bluetooth -fixed relative paths for snippets -moved examples to examples/bluetooth Change-Id: Id41bac50dca628400568d191f1c3ccfbaac790a1 Reviewed-by: Alex <ablasche@gmail.com>
Diffstat (limited to 'examples/nfc')
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.cpp119
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.h73
-rw-r--r--examples/nfc/annotatedurl/annotatedurl.pro15
-rw-r--r--examples/nfc/annotatedurl/doc/images/annotatedurl.pngbin0 -> 34341 bytes
-rw-r--r--examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc37
-rw-r--r--examples/nfc/annotatedurl/main.cpp80
-rw-r--r--examples/nfc/annotatedurl/mainwindow.cpp72
-rw-r--r--examples/nfc/annotatedurl/mainwindow.h70
-rw-r--r--examples/nfc/annotatedurl/mainwindow.ui61
-rw-r--r--examples/nfc/ndefeditor/doc/images/ndefeditor.pngbin0 -> 24500 bytes
-rw-r--r--examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc36
-rw-r--r--examples/nfc/ndefeditor/main.cpp56
-rw-r--r--examples/nfc/ndefeditor/mainwindow.cpp361
-rw-r--r--examples/nfc/ndefeditor/mainwindow.h107
-rw-r--r--examples/nfc/ndefeditor/mainwindow.ui225
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.cpp139
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.h76
-rw-r--r--examples/nfc/ndefeditor/mimeimagerecordeditor.ui83
-rw-r--r--examples/nfc/ndefeditor/ndefeditor.pro23
-rw-r--r--examples/nfc/ndefeditor/textrecord.ui21
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.cpp83
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.h69
-rw-r--r--examples/nfc/ndefeditor/textrecordeditor.ui101
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.cpp70
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.h70
-rw-r--r--examples/nfc/ndefeditor/urirecordeditor.ui45
-rw-r--r--examples/nfc/poster/doc/images/qml-poster-example.pngbin0 -> 54257 bytes
-rw-r--r--examples/nfc/poster/doc/src/poster.qdoc38
-rw-r--r--examples/nfc/poster/poster.pro13
-rw-r--r--examples/nfc/poster/poster.qml186
-rw-r--r--examples/nfc/poster/poster.qrc6
-rw-r--r--examples/nfc/poster/qmlposter.cpp62
32 files changed, 2397 insertions, 0 deletions
diff --git a/examples/nfc/annotatedurl/annotatedurl.cpp b/examples/nfc/annotatedurl/annotatedurl.cpp
new file mode 100644
index 00000000..f13f3235
--- /dev/null
+++ b/examples/nfc/annotatedurl/annotatedurl.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "annotatedurl.h"
+
+#include <qnearfieldtarget.h>
+#include <qndefmessage.h>
+#include <qndefrecord.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+
+#include <QtCore/QUrl>
+#include <QtCore/QLocale>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QDesktopServices>
+
+AnnotatedUrl::AnnotatedUrl(QObject *parent)
+: QObject(parent)
+{
+}
+
+AnnotatedUrl::~AnnotatedUrl()
+{
+}
+
+void AnnotatedUrl::handleMessage(const QNdefMessage &message, QNearFieldTarget *target)
+{
+ Q_UNUSED(target);
+
+ enum {
+ MatchedNone,
+ MatchedFirst,
+ MatchedEnglish,
+ MatchedLanguage,
+ MatchedLanguageAndCountry
+ } bestMatch = MatchedNone;
+
+ QLocale defaultLocale;
+
+ QString title;
+ QUrl url;
+ QPixmap pixmap;
+
+ foreach (const QNdefRecord &record, message) {
+ if (record.isRecordType<QNdefNfcTextRecord>()) {
+ QNdefNfcTextRecord textRecord(record);
+
+ QLocale locale(textRecord.locale());
+
+ // already found best match
+ if (bestMatch == MatchedLanguageAndCountry) {
+ // do nothing
+ } else if (bestMatch <= MatchedLanguage && locale == defaultLocale) {
+ title = textRecord.text();
+ bestMatch = MatchedLanguageAndCountry;
+ } else if (bestMatch <= MatchedEnglish &&
+ locale.language() == defaultLocale.language()) {
+ title = textRecord.text();
+ bestMatch = MatchedLanguage;
+ } else if (bestMatch <= MatchedFirst && locale.language() == QLocale::English) {
+ title = textRecord.text();
+ bestMatch = MatchedEnglish;
+ } else if (bestMatch == MatchedNone) {
+ title = textRecord.text();
+ bestMatch = MatchedFirst;
+ }
+ } else if (record.isRecordType<QNdefNfcUriRecord>()) {
+ QNdefNfcUriRecord uriRecord(record);
+
+ url = uriRecord.uri();
+ } else if (record.typeNameFormat() == QNdefRecord::Mime &&
+ record.type().startsWith("image/")) {
+ pixmap = QPixmap::fromImage(QImage::fromData(record.payload()));
+ }
+ }
+
+ emit annotatedUrl(url, title, pixmap);
+}
+
diff --git a/examples/nfc/annotatedurl/annotatedurl.h b/examples/nfc/annotatedurl/annotatedurl.h
new file mode 100644
index 00000000..490539a2
--- /dev/null
+++ b/examples/nfc/annotatedurl/annotatedurl.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANNOTATEDURL_H
+#define ANNOTATEDURL_H
+
+#include <qnfcglobal.h>
+
+#include <QtCore/QObject>
+
+QT_FORWARD_DECLARE_CLASS(QUrl)
+QT_FORWARD_DECLARE_CLASS(QPixmap)
+
+QTNFC_BEGIN_NAMESPACE
+class QNearFieldTarget;
+class QNdefMessage;
+QTNFC_END_NAMESPACE
+
+QTNFC_USE_NAMESPACE
+
+class AnnotatedUrl : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AnnotatedUrl(QObject *parent = 0);
+ ~AnnotatedUrl();
+
+signals:
+ void annotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap);
+
+public slots:
+ void handleMessage(const QNdefMessage &message, QNearFieldTarget *target);
+};
+
+#endif // ANNOTATEDURL_H
diff --git a/examples/nfc/annotatedurl/annotatedurl.pro b/examples/nfc/annotatedurl/annotatedurl.pro
new file mode 100644
index 00000000..65ed7c8d
--- /dev/null
+++ b/examples/nfc/annotatedurl/annotatedurl.pro
@@ -0,0 +1,15 @@
+QT += nfc widgets
+
+CONFIG += strict_flags
+
+TARGET = annotatedurl
+
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ annotatedurl.cpp
+
+HEADERS += mainwindow.h \
+ annotatedurl.h
+
+FORMS += mainwindow.ui
+
diff --git a/examples/nfc/annotatedurl/doc/images/annotatedurl.png b/examples/nfc/annotatedurl/doc/images/annotatedurl.png
new file mode 100644
index 00000000..71739f50
--- /dev/null
+++ b/examples/nfc/annotatedurl/doc/images/annotatedurl.png
Binary files differ
diff --git a/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
new file mode 100644
index 00000000..7aa706b6
--- /dev/null
+++ b/examples/nfc/annotatedurl/doc/src/annotatedurl.qdoc
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example annotatedurl
+\title Annotated URL Example
+
+The Annotated URL example displays the contents of specifically formated NDEF messages read from
+an NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+or more localized Text records.
+
+\image annotatedurl.png
+*/
diff --git a/examples/nfc/annotatedurl/main.cpp b/examples/nfc/annotatedurl/main.cpp
new file mode 100644
index 00000000..65be03c5
--- /dev/null
+++ b/examples/nfc/annotatedurl/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "annotatedurl.h"
+#include "mainwindow.h"
+
+#include <qnearfieldmanager.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+
+#include <QtCore/QLocale>
+
+#include <QApplication>
+
+
+int main(int argc, char *argv[])
+{
+ //QLocale::setDefault(QLocale(QLocale::Japanese));
+
+ QApplication a(argc, argv);
+ MainWindow mainWindow;
+
+ QNearFieldManager manager;
+ AnnotatedUrl annotatedUrl;
+
+ QNdefFilter filter;
+ filter.setOrderMatch(false);
+ filter.appendRecord<QNdefNfcTextRecord>(1, UINT_MAX);
+ filter.appendRecord<QNdefNfcUriRecord>();
+ manager.registerNdefMessageHandler(filter, &annotatedUrl,
+ SLOT(handleMessage(QNdefMessage,QNearFieldTarget*)));
+
+ QObject::connect(&annotatedUrl, SIGNAL(annotatedUrl(QUrl,QString,QPixmap)),
+ &mainWindow, SLOT(displayAnnotatedUrl(QUrl,QString,QPixmap)));
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
+ mainWindow.showFullScreen();
+#else
+ mainWindow.show();
+#endif
+
+ return a.exec();
+}
diff --git a/examples/nfc/annotatedurl/mainwindow.cpp b/examples/nfc/annotatedurl/mainwindow.cpp
new file mode 100644
index 00000000..7045a5dc
--- /dev/null
+++ b/examples/nfc/annotatedurl/mainwindow.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QtCore/QUrl>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QDesktopServices>
+
+MainWindow::MainWindow(QWidget *parent)
+: QMainWindow(parent), ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::displayAnnotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap)
+{
+ ui->m_help->setHidden(true);
+
+ ui->m_url->setText(url.toString());
+ ui->m_title->setText(title);
+ ui->m_image->setPixmap(pixmap);
+}
+
+void MainWindow::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (ui->centralWidget->rect().contains(event->pos()))
+ QDesktopServices::openUrl(QUrl(ui->m_url->text()));
+}
diff --git a/examples/nfc/annotatedurl/mainwindow.h b/examples/nfc/annotatedurl/mainwindow.h
new file mode 100644
index 00000000..0786f8aa
--- /dev/null
+++ b/examples/nfc/annotatedurl/mainwindow.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_FORWARD_DECLARE_CLASS(QUrl)
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+public slots:
+ void displayAnnotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap);
+
+protected:
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/nfc/annotatedurl/mainwindow.ui b/examples/nfc/annotatedurl/mainwindow.ui
new file mode 100644
index 00000000..26e3b302
--- /dev/null
+++ b/examples/nfc/annotatedurl/mainwindow.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>590</width>
+ <height>420</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout" rowstretch="1,0,1" columnstretch="0,0,0">
+ <item row="0" column="1" colspan="2">
+ <widget class="QLabel" name="m_title">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" rowspan="3">
+ <widget class="QLabel" name="m_image">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="m_help">
+ <property name="text">
+ <string>Touch a tag</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2">
+ <widget class="QLabel" name="m_url">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/nfc/ndefeditor/doc/images/ndefeditor.png b/examples/nfc/ndefeditor/doc/images/ndefeditor.png
new file mode 100644
index 00000000..0334dadf
--- /dev/null
+++ b/examples/nfc/ndefeditor/doc/images/ndefeditor.png
Binary files differ
diff --git a/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
new file mode 100644
index 00000000..c2f1fcaf
--- /dev/null
+++ b/examples/nfc/ndefeditor/doc/src/ndefeditor.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example ndefeditor
+\title NDEF Editor Example
+
+The NDEF Editor example reads and writes NDEF messages to NFC Forum Tags. NDEF messages can be
+composed by adding records of supported types.
+
+\image ndefeditor.png
+*/
diff --git a/examples/nfc/ndefeditor/main.cpp b/examples/nfc/ndefeditor/main.cpp
new file mode 100644
index 00000000..800b6cd3
--- /dev/null
+++ b/examples/nfc/ndefeditor/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
+ w.showFullScreen();
+#else
+ w.show();
+#endif
+
+ return a.exec();
+}
diff --git a/examples/nfc/ndefeditor/mainwindow.cpp b/examples/nfc/ndefeditor/mainwindow.cpp
new file mode 100644
index 00000000..e847416b
--- /dev/null
+++ b/examples/nfc/ndefeditor/mainwindow.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include "textrecordeditor.h"
+#include "urirecordeditor.h"
+#include "mimeimagerecordeditor.h"
+
+#include <QtCore/QTime>
+#include <QMenu>
+#include <QVBoxLayout>
+#include <QFrame>
+#include <QLabel>
+#include <QFileDialog>
+
+#include <qnearfieldmanager.h>
+#include <qnearfieldtarget.h>
+#include <qndefrecord.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+#include <qndefmessage.h>
+
+#include <QtCore/QDebug>
+
+class EmptyRecordLabel : public QLabel
+{
+ Q_OBJECT
+
+public:
+ EmptyRecordLabel() : QLabel(tr("Empty Record")) { }
+ ~EmptyRecordLabel() { }
+
+ void setRecord(const QNdefRecord &record)
+ {
+ Q_UNUSED(record);
+ }
+
+ QNdefRecord record() const
+ {
+ return QNdefRecord();
+ }
+};
+
+class UnknownRecordLabel : public QLabel
+{
+ Q_OBJECT
+
+public:
+ UnknownRecordLabel() : QLabel(tr("Unknown Record Type")) { }
+ ~UnknownRecordLabel() { }
+
+ void setRecord(const QNdefRecord &record) { m_record = record; }
+ QNdefRecord record() const { return m_record; }
+
+private:
+ QNdefRecord m_record;
+};
+
+template <typename T>
+void addRecord(Ui::MainWindow *ui, const QNdefRecord &record = QNdefRecord())
+{
+ QVBoxLayout *vbox = qobject_cast<QVBoxLayout *>(ui->scrollAreaWidgetContents->layout());
+ if (!vbox)
+ return;
+
+ if (!vbox->isEmpty()) {
+ QFrame *hline = new QFrame;
+ hline->setFrameShape(QFrame::HLine);
+ hline->setObjectName(QLatin1String("line-spacer"));
+
+ vbox->addWidget(hline);
+ }
+
+ T *recordEditor = new T;
+ recordEditor->setObjectName(QLatin1String("record-editor"));
+
+ if (!record.isEmpty())
+ recordEditor->setRecord(record);
+
+ vbox->addWidget(recordEditor);
+}
+
+MainWindow::MainWindow(QWidget *parent)
+: QMainWindow(parent), ui(new Ui::MainWindow), m_manager(new QNearFieldManager(this)),
+ m_touchAction(NoAction)
+{
+ ui->setupUi(this);
+
+ QMenu *addRecordMenu = new QMenu(this);
+ addRecordMenu->addAction(tr("NFC Text Record"), this, SLOT(addNfcTextRecord()));
+ addRecordMenu->addAction(tr("NFC URI Record"), this, SLOT(addNfcUriRecord()));
+ addRecordMenu->addAction(tr("MIME Image Record"), this, SLOT(addMimeImageRecord()));
+ addRecordMenu->addAction(tr("Empty Record"), this, SLOT(addEmptyRecord()));
+ ui->addRecord->setMenu(addRecordMenu);
+
+ QVBoxLayout *vbox = new QVBoxLayout;
+ ui->scrollAreaWidgetContents->setLayout(vbox);
+
+ connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
+ this, SLOT(targetDetected(QNearFieldTarget*)));
+ connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
+ this, SLOT(targetLost(QNearFieldTarget*)));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::addNfcTextRecord()
+{
+ addRecord<TextRecordEditor>(ui);
+}
+
+void MainWindow::addNfcUriRecord()
+{
+ addRecord<UriRecordEditor>(ui);
+}
+
+void MainWindow::addMimeImageRecord()
+{
+ addRecord<MimeImageRecordEditor>(ui);
+}
+
+void MainWindow::addEmptyRecord()
+{
+ addRecord<EmptyRecordLabel>(ui);
+}
+
+void MainWindow::loadMessage()
+{
+ QString filename = QFileDialog::getOpenFileName(this, tr("Select NDEF Message"));
+ if (filename.isEmpty())
+ return;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly))
+ return;
+
+ QByteArray ndef = file.readAll();
+
+ ndefMessageRead(QNdefMessage::fromByteArray(ndef));
+
+ file.close();
+}
+
+void MainWindow::saveMessage()
+{
+ QString filename = QFileDialog::getSaveFileName(this, tr("Select NDEF Message"));
+ if (filename.isEmpty())
+ return;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::WriteOnly))
+ return;
+
+ file.write(ndefMessage().toByteArray());
+
+ file.close();
+}
+
+void MainWindow::touchReceive()
+{
+ ui->status->setStyleSheet(QLatin1String("background: blue"));
+
+ m_touchAction = ReadNdef;
+
+ m_manager->setTargetAccessModes(QNearFieldManager::NdefReadTargetAccess);
+ m_manager->startTargetDetection();
+}
+
+void MainWindow::touchStore()
+{
+ ui->status->setStyleSheet(QLatin1String("background: yellow"));
+
+ m_touchAction = WriteNdef;
+
+ m_manager->setTargetAccessModes(QNearFieldManager::NdefWriteTargetAccess);
+ m_manager->startTargetDetection();
+}
+
+void MainWindow::targetDetected(QNearFieldTarget *target)
+{
+ switch (m_touchAction) {
+ case NoAction:
+ break;
+ case ReadNdef:
+ connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
+ this, SLOT(ndefMessageRead(QNdefMessage)));
+ connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
+ this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+
+ m_request = target->readNdefMessages();
+ break;
+ case WriteNdef:
+ connect(target, SIGNAL(ndefMessagesWritten()), this, SLOT(ndefMessageWritten()));
+ connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
+ this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+
+ m_request = target->writeNdefMessages(QList<QNdefMessage>() << ndefMessage());
+ break;
+ }
+}
+
+void MainWindow::targetLost(QNearFieldTarget *target)
+{
+ target->deleteLater();
+}
+
+void MainWindow::ndefMessageRead(const QNdefMessage &message)
+{
+ clearMessage();
+
+ foreach (const QNdefRecord &record, message) {
+ if (record.isRecordType<QNdefNfcTextRecord>()) {
+ addRecord<TextRecordEditor>(ui, record);
+ } else if (record.isRecordType<QNdefNfcUriRecord>()) {
+ addRecord<UriRecordEditor>(ui, record);
+ } else if (record.typeNameFormat() == QNdefRecord::Mime &&
+ record.type().startsWith("image/")) {
+ addRecord<MimeImageRecordEditor>(ui, record);
+ } else if (record.isEmpty()) {
+ addRecord<EmptyRecordLabel>(ui);
+ } else {
+ addRecord<UnknownRecordLabel>(ui, record);
+ }
+ }
+
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ ui->statusBar->clearMessage();
+}
+
+void MainWindow::ndefMessageWritten()
+{
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ ui->statusBar->clearMessage();
+}
+
+void MainWindow::targetError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id)
+{
+ Q_UNUSED(error);
+ Q_UNUSED(id);
+
+ if (m_request == id) {
+ switch (error) {
+ case QNearFieldTarget::NoError:
+ ui->statusBar->clearMessage();
+ break;
+ case QNearFieldTarget::UnsupportedError:
+ ui->statusBar->showMessage(tr("Unsupported tag"));
+ break;
+ case QNearFieldTarget::TargetOutOfRangeError:
+ ui->statusBar->showMessage(tr("Tag removed from field"));
+ break;
+ case QNearFieldTarget::NoResponseError:
+ ui->statusBar->showMessage(tr("No response from tag"));
+ break;
+ case QNearFieldTarget::ChecksumMismatchError:
+ ui->statusBar->showMessage(tr("Checksum mismatch"));
+ break;
+ case QNearFieldTarget::InvalidParametersError:
+ ui->statusBar->showMessage(tr("Invalid parameters"));
+ break;
+ case QNearFieldTarget::NdefReadError:
+ ui->statusBar->showMessage(tr("NDEF read error"));
+ break;
+ case QNearFieldTarget::NdefWriteError:
+ ui->statusBar->showMessage(tr("NDEF write error"));
+ break;
+ default:
+ ui->statusBar->showMessage(tr("Unknown error"));
+ }
+
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ }
+}
+
+void MainWindow::clearMessage()
+{
+ QWidget *scrollArea = ui->scrollAreaWidgetContents;
+
+ qDeleteAll(scrollArea->findChildren<QWidget *>(QLatin1String("line-spacer")));
+ qDeleteAll(scrollArea->findChildren<QWidget *>(QLatin1String("record-editor")));
+}
+
+QNdefMessage MainWindow::ndefMessage() const
+{
+ QVBoxLayout *vbox = qobject_cast<QVBoxLayout *>(ui->scrollAreaWidgetContents->layout());
+ if (!vbox)
+ return QNdefMessage();
+
+ QNdefMessage message;
+
+ for (int i = 0; i < vbox->count(); ++i) {
+ QWidget *widget = vbox->itemAt(i)->widget();
+
+ if (TextRecordEditor *editor = qobject_cast<TextRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (UriRecordEditor *editor = qobject_cast<UriRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (MimeImageRecordEditor *editor = qobject_cast<MimeImageRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (qobject_cast<EmptyRecordLabel *>(widget)) {
+ message.append(QNdefRecord());
+ } else if (UnknownRecordLabel *label = qobject_cast<UnknownRecordLabel *>(widget)) {
+ message.append(label->record());
+ }
+ }
+
+ return message;
+}
+
+#include "mainwindow.moc"
diff --git a/examples/nfc/ndefeditor/mainwindow.h b/examples/nfc/ndefeditor/mainwindow.h
new file mode 100644
index 00000000..6be6be25
--- /dev/null
+++ b/examples/nfc/ndefeditor/mainwindow.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include <qnfcglobal.h>
+
+#include <qnearfieldtarget.h>
+
+QTNFC_BEGIN_NAMESPACE
+class QNearFieldManager;
+class QNdefMessage;
+QTNFC_END_NAMESPACE
+
+QTNFC_USE_NAMESPACE
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private slots:
+ void addNfcTextRecord();
+ void addNfcUriRecord();
+ void addMimeImageRecord();
+ void addEmptyRecord();
+
+ void clearMessage();
+
+ void loadMessage();
+ void saveMessage();
+
+ void touchReceive();
+ void touchStore();
+
+ void targetDetected(QNearFieldTarget *target);
+ void targetLost(QNearFieldTarget *target);
+
+ void ndefMessageRead(const QNdefMessage &message);
+ void ndefMessageWritten();
+ void targetError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id);
+
+private:
+ enum TouchAction {
+ NoAction,
+ ReadNdef,
+ WriteNdef
+ };
+
+ QNdefMessage ndefMessage() const;
+
+private:
+ Ui::MainWindow *ui;
+
+ QNearFieldManager *m_manager;
+ TouchAction m_touchAction;
+ QNearFieldTarget::RequestId m_request;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/nfc/ndefeditor/mainwindow.ui b/examples/nfc/ndefeditor/mainwindow.ui
new file mode 100644
index 00000000..adffa331
--- /dev/null
+++ b/examples/nfc/ndefeditor/mainwindow.ui
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>553</width>
+ <height>397</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>NDEF Message Editor</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>9</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <item>
+ <widget class="QWidget" name="status" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="touchRetrieve">
+ <property name="text">
+ <string>Retrieve</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="touchStore">
+ <property name="text">
+ <string>Store</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="loadMessage">
+ <property name="text">
+ <string>Load</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="saveMessage">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearMessage">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="addRecord">
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>553</width>
+ <height>335</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>saveMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>saveMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>419</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>touchRetrieve</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>touchReceive()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>142</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>touchStore</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>touchStore()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>244</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>loadMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>loadMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>334</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>clearMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>clearMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>419</x>
+ <y>22</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>saveMessage()</slot>
+ <slot>loadMessage()</slot>
+ <slot>touchReceive()</slot>
+ <slot>touchStore()</slot>
+ <slot>clearMessage()</slot>
+ </slots>
+</ui>
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
new file mode 100644
index 00000000..beb1bb41
--- /dev/null
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mimeimagerecordeditor.h"
+#include "ui_mimeimagerecordeditor.h"
+
+#include <QBuffer>
+#include <QFileDialog>
+#include <QImageReader>
+
+static QString imageFormatToMimeType(const QByteArray &format)
+{
+ if (format == "bmp")
+ return QLatin1String("image/bmp");
+ else if (format == "gif")
+ return QLatin1String("image/gif");
+ else if (format == "jpg" || format == "jpeg")
+ return QLatin1String("image/jpeg");
+ else if (format == "mng")
+ return QLatin1String("video/x-mng");
+ else if (format == "png")
+ return QLatin1String("image/png");
+ else if (format == "pbm")
+ return QLatin1String("image/x-portable-bitmap");
+ else if (format == "pgm")
+ return QLatin1String("image/x-portable-graymap");
+ else if (format == "ppm")
+ return QLatin1String("image/x-portable-pixmap");
+ else if (format == "tiff")
+ return QLatin1String("image/tiff");
+ else if (format == "xbm")
+ return QLatin1String("image/x-xbitmap");
+ else if (format == "xpm")
+ return QLatin1String("image/x-xpixmap");
+ else if (format == "svg")
+ return QLatin1String("image/svg+xml");
+ else
+ return QString();
+}
+
+MimeImageRecordEditor::MimeImageRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::MimeImageRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+MimeImageRecordEditor::~MimeImageRecordEditor()
+{
+ delete ui;
+}
+
+void MimeImageRecordEditor::setRecord(const QNdefRecord &record)
+{
+ m_record = record;
+
+ QByteArray data = record.payload();
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::ReadOnly);
+
+ QImageReader reader(&buffer);
+
+ ui->mimeImageType->setText(imageFormatToMimeType(reader.format()));
+
+ ui->mimeImageImage->setPixmap(QPixmap::fromImage(reader.read()));
+ ui->mimeImageFile->clear();
+}
+
+QNdefRecord MimeImageRecordEditor::record() const
+{
+ return m_record;
+}
+
+void MimeImageRecordEditor::on_mimeImageOpen_clicked()
+{
+ QString mimeDataFile = QFileDialog::getOpenFileName(this, tr("Select Image File"));
+ if (mimeDataFile.isEmpty())
+ return;
+
+ QFile imageFile(mimeDataFile);
+ if (!imageFile.open(QIODevice::ReadOnly)) {
+ ui->mimeImageFile->clear();
+ ui->mimeImageImage->clear();
+ }
+
+ QByteArray imageData = imageFile.readAll();
+
+ QBuffer buffer(&imageData);
+ buffer.open(QIODevice::ReadOnly);
+
+ QImageReader reader(&buffer);
+ QString mimeType = imageFormatToMimeType(reader.format());
+ ui->mimeImageType->setText(mimeType);
+
+ QImage image = reader.read();
+
+ ui->mimeImageFile->setText(mimeDataFile);
+ ui->mimeImageImage->setPixmap(QPixmap::fromImage(image));
+
+ m_record.setType(mimeType.toLatin1());
+ m_record.setPayload(imageData);
+}
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.h b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
new file mode 100644
index 00000000..62330f2f
--- /dev/null
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef MIMEIMAGERECORDEDITOR_H
+#define MIMEIMAGERECORDEDITOR_H
+
+#include <qnfcglobal.h>
+
+#include <QWidget>
+
+#include <qndefrecord.h>
+
+QTNFC_USE_NAMESPACE
+
+namespace Ui {
+ class MimeImageRecordEditor;
+}
+
+class MimeImageRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MimeImageRecordEditor(QWidget *parent = 0);
+ ~MimeImageRecordEditor();
+
+ void setRecord(const QNdefRecord &record);
+ QNdefRecord record() const;
+
+private:
+ Ui::MimeImageRecordEditor *ui;
+ QNdefRecord m_record;
+
+private slots:
+ void on_mimeImageOpen_clicked();
+};
+
+#endif // MIMEIMAGERECORDEDITOR_H
diff --git a/examples/nfc/ndefeditor/mimeimagerecordeditor.ui b/examples/nfc/ndefeditor/mimeimagerecordeditor.ui
new file mode 100644
index 00000000..4cde216f
--- /dev/null
+++ b/examples/nfc/ndefeditor/mimeimagerecordeditor.ui
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MimeImageRecordEditor</class>
+ <widget class="QWidget" name="MimeImageRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>106</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>MIME Record &lt;image/*&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="mimeImageType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>image/</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>File:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="mimeImageFile">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="mimeImageOpen">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="mimeImageImage">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/nfc/ndefeditor/ndefeditor.pro b/examples/nfc/ndefeditor/ndefeditor.pro
new file mode 100644
index 00000000..47971fdb
--- /dev/null
+++ b/examples/nfc/ndefeditor/ndefeditor.pro
@@ -0,0 +1,23 @@
+QT += nfc widgets
+
+TARGET = ndefeditor
+TEMPLATE = app
+
+SOURCES += \
+ main.cpp \
+ mainwindow.cpp \
+ textrecordeditor.cpp \
+ urirecordeditor.cpp \
+ mimeimagerecordeditor.cpp
+
+HEADERS += \
+ mainwindow.h \
+ textrecordeditor.h \
+ urirecordeditor.h \
+ mimeimagerecordeditor.h
+
+FORMS += \
+ mainwindow.ui \
+ textrecordeditor.ui \
+ urirecordeditor.ui \
+ mimeimagerecordeditor.ui
diff --git a/examples/nfc/ndefeditor/textrecord.ui b/examples/nfc/ndefeditor/textrecord.ui
new file mode 100644
index 00000000..eedd2d83
--- /dev/null
+++ b/examples/nfc/ndefeditor/textrecord.ui
@@ -0,0 +1,21 @@
+<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>TextRecord</class>
+ <widget class="QWidget" name="TextRecord">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
diff --git a/examples/nfc/ndefeditor/textrecordeditor.cpp b/examples/nfc/ndefeditor/textrecordeditor.cpp
new file mode 100644
index 00000000..9b82476a
--- /dev/null
+++ b/examples/nfc/ndefeditor/textrecordeditor.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textrecordeditor.h"
+#include "ui_textrecordeditor.h"
+
+#include <QtCore/QDebug>
+
+TextRecordEditor::TextRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::TextRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+TextRecordEditor::~TextRecordEditor()
+{
+ delete ui;
+}
+
+void TextRecordEditor::setRecord(const QNdefNfcTextRecord &textRecord)
+{
+ ui->text->setText(textRecord.text());
+ ui->locale->setText(textRecord.locale());
+
+ if (textRecord.encoding() == QNdefNfcTextRecord::Utf8)
+ ui->encoding->setCurrentIndex(0);
+ else if (textRecord.encoding() == QNdefNfcTextRecord::Utf16)
+ ui->encoding->setCurrentIndex(1);
+}
+
+QNdefNfcTextRecord TextRecordEditor::record() const
+{
+ QNdefNfcTextRecord record;
+
+ if (ui->encoding->currentIndex() == 0)
+ record.setEncoding(QNdefNfcTextRecord::Utf8);
+ else if (ui->encoding->currentIndex() == 1)
+ record.setEncoding(QNdefNfcTextRecord::Utf16);
+
+ record.setLocale(ui->locale->text());
+
+ record.setText(ui->text->text());
+
+ return record;
+}
diff --git a/examples/nfc/ndefeditor/textrecordeditor.h b/examples/nfc/ndefeditor/textrecordeditor.h
new file mode 100644
index 00000000..f692d0b7
--- /dev/null
+++ b/examples/nfc/ndefeditor/textrecordeditor.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTRECORDEDITOR_H
+#define TEXTRECORDEDITOR_H
+
+#include <QWidget>
+
+#include <qndefnfctextrecord.h>
+
+namespace Ui {
+ class TextRecordEditor;
+}
+
+QTNFC_USE_NAMESPACE
+
+class TextRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit TextRecordEditor(QWidget *parent = 0);
+ ~TextRecordEditor();
+
+ void setRecord(const QNdefNfcTextRecord &textRecord);
+ QNdefNfcTextRecord record() const;
+
+private:
+ Ui::TextRecordEditor *ui;
+};
+
+#endif // TEXTRECORDEDITOR_H
diff --git a/examples/nfc/ndefeditor/textrecordeditor.ui b/examples/nfc/ndefeditor/textrecordeditor.ui
new file mode 100644
index 00000000..41950e7d
--- /dev/null
+++ b/examples/nfc/ndefeditor/textrecordeditor.ui
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TextRecordEditor</class>
+ <widget class="QWidget" name="TextRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>344</width>
+ <height>115</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="rowWrapPolicy">
+ <enum>QFormLayout::WrapLongRows</enum>
+ </property>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>NFC Text Record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Text:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="text">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Locale:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="locale">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Encoding:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="encoding">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>UTF-8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>UTF-16</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/nfc/ndefeditor/urirecordeditor.cpp b/examples/nfc/ndefeditor/urirecordeditor.cpp
new file mode 100644
index 00000000..08bf9b47
--- /dev/null
+++ b/examples/nfc/ndefeditor/urirecordeditor.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "urirecordeditor.h"
+#include "ui_urirecordeditor.h"
+
+#include <QtCore/QUrl>
+
+UriRecordEditor::UriRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::UriRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+UriRecordEditor::~UriRecordEditor()
+{
+ delete ui;
+}
+
+void UriRecordEditor::setRecord(const QNdefNfcUriRecord &uriRecord)
+{
+ ui->uri->setText(uriRecord.uri().toString());
+}
+
+QNdefNfcUriRecord UriRecordEditor::record() const
+{
+ QNdefNfcUriRecord record;
+
+ record.setUri(ui->uri->text());
+
+ return record;
+}
diff --git a/examples/nfc/ndefeditor/urirecordeditor.h b/examples/nfc/ndefeditor/urirecordeditor.h
new file mode 100644
index 00000000..cf7af023
--- /dev/null
+++ b/examples/nfc/ndefeditor/urirecordeditor.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef URIRECORDEDITOR_H
+#define URIRECORDEDITOR_H
+
+#include <QWidget>
+
+#include <qndefnfcurirecord.h>
+
+namespace Ui {
+ class UriRecordEditor;
+}
+
+QTNFC_USE_NAMESPACE
+
+class UriRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit UriRecordEditor(QWidget *parent = 0);
+ ~UriRecordEditor();
+
+ void setRecord(const QNdefNfcUriRecord &uriRecord);
+ QNdefNfcUriRecord record() const;
+
+private:
+ Ui::UriRecordEditor *ui;
+};
+
+#endif // URIRECORDEDITOR_H
diff --git a/examples/nfc/ndefeditor/urirecordeditor.ui b/examples/nfc/ndefeditor/urirecordeditor.ui
new file mode 100644
index 00000000..929c1eb4
--- /dev/null
+++ b/examples/nfc/ndefeditor/urirecordeditor.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UriRecordEditor</class>
+ <widget class="QWidget" name="UriRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>439</width>
+ <height>59</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>NFC URI Record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Uri:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="uri">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/nfc/poster/doc/images/qml-poster-example.png b/examples/nfc/poster/doc/images/qml-poster-example.png
new file mode 100644
index 00000000..ab01a31f
--- /dev/null
+++ b/examples/nfc/poster/doc/images/qml-poster-example.png
Binary files differ
diff --git a/examples/nfc/poster/doc/src/poster.qdoc b/examples/nfc/poster/doc/src/poster.qdoc
new file mode 100644
index 00000000..109938d2
--- /dev/null
+++ b/examples/nfc/poster/doc/src/poster.qdoc
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example poster
+\title QML Poster Example
+
+The QML Poster example displays the contents of specifically formated NDEF messages read from an
+NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+or more localized Text records.
+
+\image qml-poster-example.png
+
+*/
diff --git a/examples/nfc/poster/poster.pro b/examples/nfc/poster/poster.pro
new file mode 100644
index 00000000..de2e1a05
--- /dev/null
+++ b/examples/nfc/poster/poster.pro
@@ -0,0 +1,13 @@
+QT += declarative quick network nfc widgets
+
+SOURCES += \
+ qmlposter.cpp
+
+TARGET = qml_poster
+TEMPLATE = app
+
+RESOURCES += \
+ poster.qrc
+
+OTHER_FILES += \
+ poster.qml
diff --git a/examples/nfc/poster/poster.qml b/examples/nfc/poster/poster.qml
new file mode 100644
index 00000000..6cd181cd
--- /dev/null
+++ b/examples/nfc/poster/poster.qml
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+import QtNfc 5.0
+
+Rectangle {
+ id: root
+ width: 640
+ height: 360
+
+ NearField {
+ id: nearfield
+
+ filter: [
+ NdefFilter { type: "urn:nfc:wkt:U"; minimum: 1; maximum: 1 },
+ NdefFilter { type: "urn:nfc:wkt:T"; minimum: 1 }
+ ]
+
+ onMessageRecordsChanged: {
+ posterText.text = "";
+ posterImage.source = "";
+ posterUrl.text = "";
+
+ var currentLocaleMatch = NdefTextRecord.LocaleMatchedNone;
+ var i;
+ for (i = 0; i < messageRecords.length; ++i) {
+ if (messageRecords[i].recordType == "urn:nfc:wkt:T") {
+ if (messageRecords[i].localeMatch > currentLocaleMatch) {
+ currentLocaleMatch = messageRecords[i].localeMatch;
+ posterText.text = messageRecords[i].text;
+ }
+ } else if (messageRecords[i].recordType == "urn:nfc:wkt:U") {
+ posterUrl.text = messageRecords[i].uri;
+ } else if (messageRecords[i].recordType.substr(0, 19) == "urn:nfc:mime:image/") {
+ posterImage.source = messageRecords[i].uri;
+ }
+ }
+
+ root.state = "show";
+ }
+ }
+
+ Text {
+ id: touchText
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Touch an NFC tag"
+ font.bold: true
+ font.pointSize: 18
+ }
+
+ Text {
+ id: posterText
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: - parent.width / 4
+ y: -height
+ font.bold: true
+ font.pointSize: 18
+ }
+
+ Image {
+ id: posterImage
+ scale: Image.PreserveAspectFit
+ height: parent.height * 0.8
+ width: height * sourceSize.width / sourceSize.height
+ anchors.verticalCenter: parent.verticalCenter
+ x: -width
+ smooth: true
+ }
+
+ Text {
+ id: posterUrl
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: - parent.width / 4
+ y: parent.height
+ font.italic: true
+ font.pointSize: 14
+ }
+
+ MouseArea {
+ id: openMouseArea
+ anchors.fill: parent
+ enabled: root.state == "show"
+
+ onClicked: Qt.openUrlExternally(posterUrl.text)
+
+ Rectangle {
+ id: testTouch
+ width: 50
+ height: 50
+ color: "lightsteelblue"
+ opacity: 0.3
+ anchors.top: parent.top
+ anchors.right: close.left
+ anchors.rightMargin: 10
+
+ MouseArea {
+ id: touchMouseArea
+ anchors.fill: parent
+
+ onClicked: {
+ if (root.state == "") {
+ root.state = "show";
+ } else {
+ root.state = "";
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: close
+ width: 50
+ height: 50
+ color: "black"
+ radius: 0
+ opacity: 0.3
+ anchors.top: parent.top
+ anchors.topMargin: 0
+ anchors.right: parent.right
+ anchors.rightMargin: 0
+
+ MouseArea {
+ id: closeMouseArea
+ anchors.fill: parent
+
+ onClicked: Qt.quit();
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "show"
+ PropertyChanges { target: posterText; y: root.height / 3 }
+ PropertyChanges { target: posterUrl; y: 2 * root.height / 3 }
+ PropertyChanges { target: posterImage; x: root.width / 20 }
+ PropertyChanges { target: touchText; opacity: 0 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ PropertyAnimation { easing.type: Easing.OutQuad; properties: "x,y" }
+ PropertyAnimation { property: "opacity"; duration: 125 }
+ }
+ ]
+}
diff --git a/examples/nfc/poster/poster.qrc b/examples/nfc/poster/poster.qrc
new file mode 100644
index 00000000..d8286e71
--- /dev/null
+++ b/examples/nfc/poster/poster.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>poster.qml</file>
+ </qresource>
+ <qresource prefix="/icons"/>
+</RCC>
diff --git a/examples/nfc/poster/qmlposter.cpp b/examples/nfc/poster/qmlposter.cpp
new file mode 100644
index 00000000..606a96f8
--- /dev/null
+++ b/examples/nfc/poster/qmlposter.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtDeclarative/QDeclarativeEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+ const QString mainQmlApp = QLatin1String("qrc:/poster.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+#if defined(Q_WS_MAEMO_6) || defined(Q_WS_SIMULATOR)
+ view.showFullScreen();
+#else
+ view.setGeometry(QRect(100, 100, 640, 360));
+ view.show();
+#endif
+ return application.exec();
+}