{
Q_OBJECT
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged);
- /*Q_PROPERTY(QStringList profiles READ profiles)
+ Q_PROPERTY(QStringList profiles READ profiles)
Q_PROPERTY(QString alias READ alias)
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString address READ address)
Q_PROPERTY(QString icon READ icon)
- Q_PROPERTY(QString path READ path)*/
+ Q_PROPERTY(QString path READ path)
public:
explicit BluetoothDevice(QDBusObjectPath path = QDBusObjectPath(), QObject *parent = 0);
QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const
{
- if(index.row() < 0) return QVariant(); ///this is retarded but it has to be done.
+ qDebug()<<"requested role: "<<roleNames()[role];
+
+ if(!index.isValid() || index.row() < 0)
+ {
+ qDebug()<<"index is not valid: "<<index.row()<<","<<index.column();
+ return QVariant(); ///this is retarded but it has to be done.
+ }
if(role == name)
{
connect(device,SIGNAL(propertyChanged(QString,QVariant)),this,SLOT(devicePropertyChanged(QString,QVariant)));
- beginInsertRows(QModelIndex(),m_devices.size()+1,m_devices.size()+1);
+ beginInsertRows(QModelIndex(),m_devices.size(),m_devices.size());
m_devices.append(device);
endInsertRows();
}
void BluetoothDevicesModel::devicePropertyChanged(QString name, QVariant value)
{
+ BluetoothDevice* device = qobject_cast<BluetoothDevice*>(sender());
+
+ qDebug()<<"device property changed for "<<device->address()<<": "<<name<<" "<<value;
+
if(name == "Paired" && value.toBool() == true)
{
- qDebug()<<"device property changed: "<<name<<" "<<value;
- BluetoothDevice* device = qobject_cast<BluetoothDevice*>(sender());
emit devicePaired(device);
}
+
+ int row = m_devices.indexOf(device);
+ if(row == -1) return; ///device doesn't exist.
+
+ dataChanged(createIndex(row, 0),createIndex(row, 0));
}