Merge PR #253: Fix device lists getting messed up when devices are reordered
This commit is contained in:
commit
32145a4e02
@ -209,6 +209,19 @@ Device *DevicesProxy::get(int index) const
|
|||||||
return getInternal(mapToSource(this->index(index, 0)).row());
|
return getInternal(mapToSource(this->index(index, 0)).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Device *DevicesProxy::getDevice(const QUuid &deviceId) const
|
||||||
|
{
|
||||||
|
Devices *d = qobject_cast<Devices*>(sourceModel());
|
||||||
|
if (d) {
|
||||||
|
return d->getDevice(deviceId);
|
||||||
|
}
|
||||||
|
DevicesProxy *dp = qobject_cast<DevicesProxy*>(sourceModel());
|
||||||
|
if (dp) {
|
||||||
|
return dp->getDevice(deviceId);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
Device *DevicesProxy::getInternal(int source_index) const
|
Device *DevicesProxy::getInternal(int source_index) const
|
||||||
{
|
{
|
||||||
Devices* d = qobject_cast<Devices*>(sourceModel());
|
Devices* d = qobject_cast<Devices*>(sourceModel());
|
||||||
|
|||||||
@ -85,6 +85,7 @@ public:
|
|||||||
void setGroupByInterface(bool groupByInterface);
|
void setGroupByInterface(bool groupByInterface);
|
||||||
|
|
||||||
Q_INVOKABLE Device *get(int index) const;
|
Q_INVOKABLE Device *get(int index) const;
|
||||||
|
Q_INVOKABLE Device *getDevice(const QUuid &deviceId) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void engineChanged();
|
void engineChanged();
|
||||||
|
|||||||
@ -64,8 +64,8 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property Device device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property DeviceClass deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
|
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
|
||||||
property var connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
property var connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
||||||
|
|||||||
@ -51,22 +51,22 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property var device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
|
property StateType connectedStateType: deviceClass.stateTypes.findByName("connected");
|
||||||
property var connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
property State connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
||||||
|
|
||||||
property var powerStateType: deviceClass.stateTypes.findByName("power");
|
property StateType powerStateType: deviceClass.stateTypes.findByName("power");
|
||||||
property var powerActionType: deviceClass.actionTypes.findByName("power");
|
property ActionType powerActionType: deviceClass.actionTypes.findByName("power");
|
||||||
property var powerState: device.states.getState(powerStateType.id)
|
property State powerState: device.states.getState(powerStateType.id)
|
||||||
|
|
||||||
property var brightnessStateType: deviceClass.stateTypes.findByName("brightness");
|
property StateType brightnessStateType: deviceClass.stateTypes.findByName("brightness");
|
||||||
property var brightnessActionType: deviceClass.actionTypes.findByName("brightness");
|
property ActionType brightnessActionType: deviceClass.actionTypes.findByName("brightness");
|
||||||
property var brightnessState: brightnessStateType ? device.states.getState(brightnessStateType.id) : null
|
property State brightnessState: brightnessStateType ? device.states.getState(brightnessStateType.id) : null
|
||||||
|
|
||||||
property var colorStateType: deviceClass.stateTypes.findByName("color");
|
property StateType colorStateType: deviceClass.stateTypes.findByName("color");
|
||||||
property var colorState: colorStateType ? device.states.getState(colorStateType.id) : null
|
property State colorState: colorStateType ? device.states.getState(colorStateType.id) : null
|
||||||
|
|
||||||
Material.elevation: 1
|
Material.elevation: 1
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
|
|||||||
@ -34,7 +34,7 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property Device device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property DeviceClass deviceClass: device.deviceClass
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
readonly property StateType playbackStateType: deviceClass.stateTypes.findByName("playbackStatus")
|
readonly property StateType playbackStateType: deviceClass.stateTypes.findByName("playbackStatus")
|
||||||
|
|||||||
@ -26,8 +26,8 @@ DeviceListPageBase {
|
|||||||
id: itemDelegate
|
id: itemDelegate
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
property var device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
|
property var connectedStateType: deviceClass.stateTypes.findByName("connected");
|
||||||
property var connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
property var connectedState: connectedStateType ? device.states.getState(connectedStateType.id) : null
|
||||||
|
|||||||
@ -23,8 +23,8 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property var device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
||||||
contentItem: Pane {
|
contentItem: Pane {
|
||||||
|
|||||||
@ -23,8 +23,8 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property var device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
||||||
contentItem: Pane {
|
contentItem: Pane {
|
||||||
|
|||||||
@ -24,8 +24,8 @@ DeviceListPageBase {
|
|||||||
|
|
||||||
property bool inline: width > 500
|
property bool inline: width > 500
|
||||||
|
|
||||||
property var device: devicesProxy.get(index);
|
property Device device: devicesProxy.getDevice(model.id)
|
||||||
property var deviceClass: engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
|
property DeviceClass deviceClass: device.deviceClass
|
||||||
|
|
||||||
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
bottomPadding: index === ListView.view.count - 1 ? topPadding : 0
|
||||||
contentItem: Pane {
|
contentItem: Pane {
|
||||||
|
|||||||
@ -73,7 +73,7 @@ Page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate: ThingDelegate {
|
delegate: ThingDelegate {
|
||||||
device: deviceProxy.get(index)
|
device: deviceProxy.getDevice(model.id)
|
||||||
canDelete: true
|
canDelete: true
|
||||||
onClicked: {
|
onClicked: {
|
||||||
print("clicked:", model.id)
|
print("clicked:", model.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user