This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-app/nymea-app/ui/devicelistpages/GenericDeviceListPage.qml
Michael Zanetti 113963a77b add support for tagging
rework the main page completely by using the new features available for tagging
2018-07-02 01:10:31 +02:00

63 lines
1.8 KiB
QML

import QtQuick 2.5
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1
import Nymea 1.0
import "../components"
import "../delegates"
Page {
id: subPage
property alias shownInterfaces: devicesProxy.shownInterfaces
property alias hiddenInterfaces: devicesProxy.hiddenInterfaces
Component.onCompleted: {
if (devicesProxy.count == 1) {
enterPage(0, true)
}
}
header: GuhHeader {
text: {
if (subPage.shownInterfaces.length === 1) {
return qsTr("My %1 things").arg(interfaceToString(subPage.filterInterface))
} else if (subPage.shownInterfaces.length > 1) {
return qsTr("My things")
}
return qsTr("All my things")
}
onBackPressed: {
print("popping")
pageStack.pop()
}
}
function enterPage(index, replace) {
var device = devicesProxy.get(index);
var deviceClass = Engine.deviceManager.deviceClasses.getDeviceClass(device.deviceClassId);
var page = app.interfaceListToDevicePage(deviceClass.interfaces);
if (replace) {
pageStack.replace(Qt.resolvedUrl("../devicepages/" + page), {device: devicesProxy.get(index)})
} else {
pageStack.push(Qt.resolvedUrl("../devicepages/" + page), {device: devicesProxy.get(index)})
}
}
ListView {
anchors.fill: parent
model: DevicesProxy {
id: devicesProxy
devices: Engine.deviceManager.devices
}
delegate: ThingDelegate {
width: parent.width
name: model.name
interfaces: Engine.deviceManager.deviceClasses.getDeviceClass(model.deviceClassId).interfaces
onClicked: {
enterPage(index, false)
}
}
}
}