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 "<<timeout<<": "<<success;
+ }
+}
+
void BluetoothDevicesModel::adapterAdded(QDBusObjectPath path)
{
if(adapter && adapter->path() == path.path()) return;
{
discoverableChanged(value.variant().toBool());
}
+ else if(name == "DiscoverableTimeout")
+ {
+ discoverableTimeoutChanged(value.variant().toInt());
+ }
}
{
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);
BluetoothDevice* device(QString path);
void makeDiscoverable(bool isDiscoverable);
bool discoverable();
+ int discoverableTimeout();
+ void setDiscoverableTimeout(int timeout);
private slots:
void adapterAdded(QDBusObjectPath);
void adapterPropertyChanged(QString name, QDBusVariant value);
signals:
+ void discoverableTimeoutChanged(int timeout);
void devicePaired(BluetoothDevice* device);
void discoverableChanged(bool discoverable);
void adapterChanged(bool adapterPresent);
{
if(device->address() == hwaddy)
{
+ qDebug()<<"device "<<device->name()<<" has disappeared";
int i=devices.indexOf(device);
- //if(i == -1) continue;
beginRemoveRows(QModelIndex(),i,i);
devices.removeAt(i);
emit nearbyDeviceRemoved(i);
{
Q_OBJECT
Q_PROPERTY(BluetoothDevice* pairingDevice READ pairingDevice)
-
public:
NearbyDevicesModel(QObject *parent = 0);