fixed BMC #20662, exposing device as a role on the model
authorKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 14 Jul 2011 22:09:21 +0000 (15:09 -0700)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Thu, 14 Jul 2011 22:09:21 +0000 (15:09 -0700)
bluetooth-qt/bluetoothdevicemodel.cpp

index f765168..670e7c2 100644 (file)
@@ -31,6 +31,8 @@ BluetoothDevicesModel::BluetoothDevicesModel(QObject *parent) :
                roles[i]=properties.property(i).name();
        }
 
+       roles[roles.keys().count()+1] = "bluetoothDevice";
+
        setRoleNames(roles);
 }
 
@@ -49,6 +51,11 @@ QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const
                return QVariant(); ///this is retarded but it has to be done.
        }
 
+       if(roleNames()[role] == "bluetoothDevice")
+       {
+               return QVariant::fromValue<QObject*>((QObject*)m_devices[index.row()]);
+       }
+
        QString roleName = roleNames()[role];
        QMetaObject object = BluetoothDevice::staticMetaObject;