Initial Import
[profile/ivi/bluetooth-qt.git] / patches / bmc20660.patch
1 diff --git a/bluetooth-qt/bluetoothdevicemodel.cpp b/bluetooth-qt/bluetoothdevicemodel.cpp
2 index 24015a5..4fdd2b4 100644
3 --- a/bluetooth-qt/bluetoothdevicemodel.cpp
4 +++ b/bluetooth-qt/bluetoothdevicemodel.cpp
5 @@ -31,6 +31,8 @@ BluetoothDevicesModel::BluetoothDevicesModel(QObject *parent) :
6                 roles[i]=properties.property(i).name();
7         }
8  
9 +       roles[roles.keys().count()+1] = "bluetoothDevice";
10 +
11         setRoleNames(roles);
12  }
13  
14 @@ -49,6 +51,11 @@ QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const
15                 return QVariant(); ///this is retarded but it has to be done.
16         }
17  
18 +       if(roleNames()[role] == "bluetoothDevice")
19 +       {
20 +               return QVariant::fromValue<QObject*>((QObject*)m_devices[index.row()]);
21 +       }
22 +
23         QString roleName = roleNames()[role];
24         QMetaObject object = BluetoothDevice::staticMetaObject;
25  
26 @@ -131,8 +138,15 @@ void BluetoothDevicesModel::setDiscoverableTimeout(int timeout)
27  {
28         if(adapter)
29         {
30 -               bool success = adapter->setProperty("DiscoverableTimeout", timeout);
31 -               qDebug()<<"Setting discoverable timeout to "<<timeout<<": "<<success;
32 +               QDBusReply<void> reply = adapter->SetProperty("DiscoverableTimeout", QDBusVariant((uint)timeout));
33 +               if(!reply.isValid())
34 +               {
35 +                       qDebug()<<"error setting discoverable timeout: "<<reply.error().message();
36 +               }
37 +               else
38 +               {
39 +                       qDebug()<<"Setting discoverable timeout to "<<timeout;
40 +               }
41         }
42  }
43  
44 diff --git a/bluetooth-qt/nearbydevicesmodel.cpp b/bluetooth-qt/nearbydevicesmodel.cpp
45 index 455c78c..1e6d4fc 100644
46 --- a/bluetooth-qt/nearbydevicesmodel.cpp
47 +++ b/bluetooth-qt/nearbydevicesmodel.cpp
48 @@ -121,9 +121,13 @@ void NearbyDevicesModel::deviceCreated(QString hwaddy, QVariantMap properties)
49         {
50                 if(path->address() == hwaddy)
51                 {
52 +                       bool nameUpdated = false;
53 +                       if((path->name() == "") && (properties["Name"].toString() != "")) nameUpdated = true;
54                         path->setName(properties["Name"].toString());
55                         path->setAlias(properties["Alias"].toString());
56                         path->setIcon(properties["Icon"].toString());
57 +
58 +                       emit dataChanged(createIndex(devices.indexOf(path),0),createIndex(devices.indexOf(path),0));
59                         return;
60                 }
61         }