summaryrefslogtreecommitdiffstats
path: root/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
diff options
context:
space:
mode:
authorFabian Bumberger <fbumberger@rim.com>2013-09-16 18:01:13 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 17:24:18 +0200
commit8e86bc19f4be7d2d01181ab45a8cadd4320887ec (patch)
tree06ef4b435f0dd6b5b518d4f784bbe4e64ad450db /src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
parent2d8378e49807ef3bf6e6662fbfcec96e95ee328f (diff)
Refactor QBluetoothDiscoveryModel
- Add the option to discover devices - Clear the model when a new discovery is started. In the previous implementation the model was only cleared if new data was available. This can lead to some funny results. - Change some property types to enums - Enhance the qmlscanner example Change-Id: I94f33e3eabd7440b5c0c6c83f3e8158009bd2dbd Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h')
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h56
1 files changed, 39 insertions, 17 deletions
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
index 8cc76817..725f98bf 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2013 BlackBerry Limited. All rights reserved.
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtBluetooth module of the Qt Toolkit.
@@ -48,6 +49,7 @@
#include <qbluetoothserviceinfo.h>
#include <qbluetoothservicediscoveryagent.h>
+#include <qbluetoothdevicediscoveryagent.h>
#include <qbluetoothglobal.h>
@@ -59,9 +61,11 @@ class QDeclarativeBluetoothDiscoveryModelPrivate;
class QDeclarativeBluetoothDiscoveryModel : public QAbstractListModel, public QQmlParserStatus
{
Q_OBJECT
- Q_PROPERTY(QString error READ error NOTIFY errorChanged)
- Q_PROPERTY(bool minimalDiscovery READ minimalDiscovery WRITE setMinimalDiscovery NOTIFY minimalDiscoveryChanged)
- Q_PROPERTY(bool discovery READ discovery WRITE setDiscovery NOTIFY discoveryChanged)
+ Q_ENUMS(DiscoveryMode)
+ Q_ENUMS(Error)
+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
+ Q_PROPERTY(DiscoveryMode discoveryMode READ discoveryMode WRITE setDiscoveryMode NOTIFY discoveryModeChanged)
+ Q_PROPERTY(bool running READ running WRITE setRunning NOTIFY runningChanged)
Q_PROPERTY(QString uuidFilter READ uuidFilter WRITE setUuidFilter NOTIFY uuidFilterChanged)
Q_INTERFACES(QQmlParserStatus)
public:
@@ -69,45 +73,63 @@ public:
virtual ~QDeclarativeBluetoothDiscoveryModel();
enum {
- ServiceRole = Qt::UserRole + 500,
- AddressRole,
- NameRole
+ Name = Qt::UserRole + 1,
+ ServiceRole,
+ DeviceName,
+ RemoteAddress
};
- QString error() const;
+ enum DiscoveryMode {
+ MinimalServiceDiscovery,
+ FullServiceDiscovery,
+ DeviceDiscovery
+ };
+
+ enum Error
+ {
+ NoError,
+ IOFailure,
+ PoweredOffFailure,
+ DeviceDiscoveryError,
+ UnknownError
+ };
+
+ Error error() const;
- // From QDeclarativeParserStatus
- virtual void classBegin() {}
+ void componentComplete();
- virtual void componentComplete();
+ void classBegin() { }
// From QAbstractListModel
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
- bool minimalDiscovery() const;
- void setMinimalDiscovery(bool minimalDiscovery_);
+ DiscoveryMode discoveryMode() const;
+ void setDiscoveryMode(DiscoveryMode discovery);
- bool discovery() const;
- void setDiscovery(bool discovery_);
+ bool running() const;
+ void setRunning(bool running);
QString uuidFilter() const;
void setUuidFilter(QString uuid);
signals:
void errorChanged();
- void minimalDiscoveryChanged();
+ void discoveryModeChanged();
void newServiceDiscovered(QDeclarativeBluetoothService *service);
- void discoveryChanged();
+ void newDeviceDiscovered();
+ void runningChanged();
void uuidFilterChanged();
private slots:
void serviceDiscovered(const QBluetoothServiceInfo &service);
+ void deviceDiscovered(const QBluetoothDeviceInfo &device);
void finishedDiscovery();
void errorDiscovery(QBluetoothServiceDiscoveryAgent::Error error);
+ void errorDeviceDiscovery(QBluetoothDeviceDiscoveryAgent::Error);
private:
- void clearModelIfRequired();
+ void clearModel();
private:
QDeclarativeBluetoothDiscoveryModelPrivate* d;