summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-03-07 15:23:27 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-10 11:24:51 +0100
commit76d5bc087cd80582af9b9a9c8b828bf9efb5cde5 (patch)
tree9549706a0ac5f20f59e13a18b15631d459cf4281
parent92b8a0bb372bbb5a71407965c7c99d60ed441435 (diff)
Build the bluetooth doc snippet.
This ensures that it keeps compiling and is correct. Although it wasn't able to compile due to a partial implementation, the snippet itself had errors which demonstrated wrong API aspects. Change-Id: I24048d968573e260d5b3ba92e38ce1dc9d24e52f Reviewed-by: Nedim Hadzic <nhadzic@blackberry.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp72
-rw-r--r--src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro43
-rw-r--r--src/bluetooth/doc/snippets/snippets.pro8
-rw-r--r--src/bluetooth/doc/src/bluetooth-cpp.qdoc2
-rw-r--r--src/bluetooth/doc/src/bluetooth-index.qdoc2
-rw-r--r--src/src.pro4
6 files changed, 73 insertions, 58 deletions
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
index 56459e72..e6e787f3 100644
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
+++ b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
@@ -39,13 +39,36 @@
****************************************************************************/
//! [include]
-#include <qbluetoothlocaldevice.h>
+#include <QtBluetooth/QBluetoothLocalDevice>
//! [include]
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDebug>
+#include <QtCore/QFile>
+#include <QtCore/QObject>
+#include <QtBluetooth/QBluetoothDeviceDiscoveryAgent>
+#include <QtBluetooth/QBluetoothTransferManager>
+#include <QtBluetooth/QBluetoothTransferRequest>
+#include <QtBluetooth/QBluetoothTransferReply>
//! [namespace]
QT_USE_NAMESPACE
//! [namespace]
+class MyClass : public QObject
+{
+ Q_OBJECT
+public:
+ MyClass() : QObject() {}
+ void localDevice();
+ void startDiscovery();
+ void objectPush();
+
+public slots:
+ void deviceDiscovered(const QBluetoothDeviceInfo &device);
+ void transferFinished(QBluetoothTransferReply* reply);
+};
+
+void MyClass::localDevice() {
//! [turningon]
QBluetoothLocalDevice localDevice;
QString localDeviceName;
@@ -60,20 +83,25 @@ if (localDevice.isValid()) {
localDeviceName = localDevice.name();
// Make it visible to others
- localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable)
+ localDevice.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
}
//! [turningon]
+}
//! [discovery]
-// Create a discovery agent and connect to its signals
-QBluetoothDiscoveryAgent *discoveryAgent = new QBluetoothDiscoveryAgent(this);
-connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
- this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
+void MyClass::startDiscovery()
+{
-// Start a discovery
-discoveryAgent->start();
+ // Create a discovery agent and connect to its signals
+ QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
+ connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
+ this, SLOT(deviceDiscovered(QBluetoothDeviceInfo)));
-...
+ // Start a discovery
+ discoveryAgent->start();
+
+ //...
+}
// In your local slot, read information about the found devices
void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
@@ -82,18 +110,36 @@ void MyClass::deviceDiscovered(const QBluetoothDeviceInfo &device)
}
//! [discovery]
+void MyClass::objectPush()
+{
//! [sendfile]
// Create a transfer manager
QBluetoothTransferManager *transferManager = new QBluetoothTransferManager(this);
// Create the transfer request and file to be sent
-QBluetoothTransferRequest request(device.address());
+QBluetoothAddress remoteAddress("00:11:22:33:44:55:66");
+QBluetoothTransferRequest request(remoteAddress);
QFile *file = new QFile("testfile.txt");
// Ask the transfer manager to send it
QBluetoothTransferReply *reply = transferManager->put(request, file);
// Connect to the reply's signals to be informed about the status and do cleanups when done
-connect(reply, SIGNAL(finished(QBluetoothTransferReply*)),
- this, SLOT(transferFinished(QBluetoothTransferReply*)));
+QObject::connect(reply, SIGNAL(finished(QBluetoothTransferReply*)),
+ this, SLOT(transferFinished(QBluetoothTransferReply*)));
//! [sendfile]
+}
+
+void MyClass::transferFinished(QBluetoothTransferReply* /*reply*/)
+{
+}
+
+int main(int argc, char** argv)
+{
+ QCoreApplication app(argc, argv);
+ MyClass cl;
+
+ return app.exec();
+}
+
+#include "doc_src_qtbluetooth.moc"
diff --git a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro b/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro
deleted file mode 100644
index ca021b72..00000000
--- a/src/bluetooth/doc/snippets/doc_src_qtbluetooth.pro
+++ /dev/null
@@ -1,43 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the documentation 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$
-**
-****************************************************************************/
-
-#! [contacts project modification]
-QT += bluetooth
-#! [contacts project modification]
diff --git a/src/bluetooth/doc/snippets/snippets.pro b/src/bluetooth/doc/snippets/snippets.pro
new file mode 100644
index 00000000..f59983ee
--- /dev/null
+++ b/src/bluetooth/doc/snippets/snippets.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+TARGET = bluetooth_cppsnippet
+QT = core
+#! [contacts project modification]
+QT += bluetooth
+#! [contacts project modification]
+
+SOURCES += doc_src_qtbluetooth.cpp
diff --git a/src/bluetooth/doc/src/bluetooth-cpp.qdoc b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
index 9bef246b..df18cc6a 100644
--- a/src/bluetooth/doc/src/bluetooth-cpp.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-cpp.qdoc
@@ -42,6 +42,6 @@
To use the C++ library in your application, add the following configuration
option to your \c .pro file:
- \snippet doc_src_qtbluetooth.pro contacts project modification
+ \snippet snippets.pro contacts project modification
*/
diff --git a/src/bluetooth/doc/src/bluetooth-index.qdoc b/src/bluetooth/doc/src/bluetooth-index.qdoc
index 77575994..ecc9561c 100644
--- a/src/bluetooth/doc/src/bluetooth-index.qdoc
+++ b/src/bluetooth/doc/src/bluetooth-index.qdoc
@@ -43,7 +43,7 @@ them.
To use the C++ library in your application, add the following configuration
option to your \c .pro file:
-\snippet doc_src_qtbluetooth.pro contacts project modification
+\snippet snippets.pro contacts project modification
To use the classes of the module in your application you need the following
import statement in your \c .qml file:
diff --git a/src/src.pro b/src/src.pro
index 1b937f61..7f37867e 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -3,6 +3,10 @@ TEMPLATE = subdirs
SUBDIRS += bluetooth nfc
android: SUBDIRS += android
+bluetooth_doc_snippets.subdir = bluetooth/doc/snippets
+bluetooth_doc_snippets.depends = bluetooth
+SUBDIRS += bluetooth_doc_snippets
+
qtHaveModule(quick) {
imports.depends += bluetooth nfc
SUBDIRS += imports