From afe5c6386736fa0b6c24c81aee4cf3310b5c5903 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 15 Feb 2011 08:41:01 -0800 Subject: [PATCH] added debug message for device removal --- bluetoothdevicemodel.cpp | 24 ++++++++++++++++++++++++ bluetoothdevicemodel.h | 4 ++++ nearbydevicesmodel.cpp | 2 +- nearbydevicesmodel.h | 1 - 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/bluetoothdevicemodel.cpp b/bluetoothdevicemodel.cpp index b2e6215..f8a1056 100644 --- a/bluetoothdevicemodel.cpp +++ b/bluetoothdevicemodel.cpp @@ -100,6 +100,26 @@ bool BluetoothDevicesModel::discoverable() return false; } +int BluetoothDevicesModel::discoverableTimeout() +{ + if(adapter) + { + QVariantMap props = adapter->GetProperties(); + return props["DiscoverableTimeout"].toInt(); + } + + return -1; +} + +void BluetoothDevicesModel::setDiscoverableTimeout(int timeout) +{ + if(adapter) + { + bool success = adapter->setProperty("DiscoverableTimeout", timeout); + qDebug()<<"Setting discoverable timeout to "<path() == path.path()) return; @@ -215,4 +235,8 @@ void BluetoothDevicesModel::adapterPropertyChanged(QString name, QDBusVariant va { discoverableChanged(value.variant().toBool()); } + else if(name == "DiscoverableTimeout") + { + discoverableTimeoutChanged(value.variant().toInt()); + } } diff --git a/bluetoothdevicemodel.h b/bluetoothdevicemodel.h index 28a8c05..cd8ae9a 100644 --- a/bluetoothdevicemodel.h +++ b/bluetoothdevicemodel.h @@ -10,6 +10,7 @@ class BluetoothDevicesModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged); + Q_PROPERTY(int discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged) Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged) public: explicit BluetoothDevicesModel(QObject *parent = 0); @@ -29,6 +30,8 @@ public slots: BluetoothDevice* device(QString path); void makeDiscoverable(bool isDiscoverable); bool discoverable(); + int discoverableTimeout(); + void setDiscoverableTimeout(int timeout); private slots: void adapterAdded(QDBusObjectPath); @@ -40,6 +43,7 @@ private slots: void adapterPropertyChanged(QString name, QDBusVariant value); signals: + void discoverableTimeoutChanged(int timeout); void devicePaired(BluetoothDevice* device); void discoverableChanged(bool discoverable); void adapterChanged(bool adapterPresent); diff --git a/nearbydevicesmodel.cpp b/nearbydevicesmodel.cpp index 3171860..57d0341 100644 --- a/nearbydevicesmodel.cpp +++ b/nearbydevicesmodel.cpp @@ -145,8 +145,8 @@ void NearbyDevicesModel::deviceRemoved(QString hwaddy) { if(device->address() == hwaddy) { + qDebug()<<"device "<name()<<" has disappeared"; int i=devices.indexOf(device); - //if(i == -1) continue; beginRemoveRows(QModelIndex(),i,i); devices.removeAt(i); emit nearbyDeviceRemoved(i); diff --git a/nearbydevicesmodel.h b/nearbydevicesmodel.h index 1c3f87e..f029b1b 100644 --- a/nearbydevicesmodel.h +++ b/nearbydevicesmodel.h @@ -52,7 +52,6 @@ class NearbyDevicesModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(BluetoothDevice* pairingDevice READ pairingDevice) - public: NearbyDevicesModel(QObject *parent = 0); -- 2.7.4