Introduce a device Role
REVIEW: 124067
This commit is contained in:
parent
b592dc99a0
commit
6ddac08978
2 changed files with 7 additions and 2 deletions
|
@ -62,6 +62,7 @@ QHash< int, QByteArray > DevicesModel::roleNames() const
|
||||||
QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
|
QHash<int, QByteArray> names = QAbstractItemModel::roleNames();
|
||||||
names.insert(IdModelRole, "deviceId");
|
names.insert(IdModelRole, "deviceId");
|
||||||
names.insert(IconNameRole, "iconName");
|
names.insert(IconNameRole, "iconName");
|
||||||
|
names.insert(DeviceRole, "device");
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DeviceDbusInterface* device = m_deviceList[index.row()];
|
DeviceDbusInterface* device = m_deviceList[index.row()];
|
||||||
|
|
||||||
//This function gets called lots of times, producing lots of dbus calls. Add a cache?
|
//This function gets called lots of times, producing lots of dbus calls. Add a cache?
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
@ -228,6 +229,8 @@ QVariant DevicesModel::data(const QModelIndex& index, int role) const
|
||||||
}
|
}
|
||||||
case IconNameRole:
|
case IconNameRole:
|
||||||
return device->statusIconName();
|
return device->statusIconName();
|
||||||
|
case DeviceRole:
|
||||||
|
return QVariant::fromValue<QObject*>(device);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,10 @@ public:
|
||||||
IconModelRole = Qt::DecorationRole,
|
IconModelRole = Qt::DecorationRole,
|
||||||
StatusModelRole = Qt::InitialSortOrderRole,
|
StatusModelRole = Qt::InitialSortOrderRole,
|
||||||
IdModelRole = Qt::UserRole,
|
IdModelRole = Qt::UserRole,
|
||||||
IconNameRole
|
IconNameRole,
|
||||||
|
DeviceRole
|
||||||
};
|
};
|
||||||
|
Q_ENUMS(ModelRoles);
|
||||||
enum StatusFlag {
|
enum StatusFlag {
|
||||||
StatusUnknown = 0x00,
|
StatusUnknown = 0x00,
|
||||||
StatusPaired = 0x01,
|
StatusPaired = 0x01,
|
||||||
|
|
Loading…
Reference in a new issue