import QtQuick import QtQuick.Controls import "./common" Item{ property var deviceInfos: [] property var devModel: ListModel{} property var interfaceModel: ListModel{} Component.onCompleted: { refreshDevices() } onVisibleChanged: if (visible) refreshDevices() function refreshDevices() { deviceInfos = getDeviceInfo() devModel.clear() for (var i = 0; i < deviceInfos.length; i++) { devModel.append({ "id": deviceInfos[i].id, "name": deviceInfos[i].name, "dev_model_id": deviceInfos[i].dev_model_id, "interface": JSON.stringify(deviceInfos[i].interface), }) } initJsonModel(funcModel, "funcModel.json") } function getDeviceInfo() { return deviceManager.getInfo("all") } function getInterFaceName(id) { var interFaceInfos = interfaceManager.getInfo(id) if(interFaceInfos.length > 0) return interFaceInfos[0].name return "" } function getInstructionInfo(dev_model_id) { return instructionManager.getDevmodelInstructions(dev_model_id) } Item{ anchors.fill: parent clip: true ListView{ id: funLstView model: funcModel header: table_func_header boundsBehavior: Flickable.StopAtBounds anchors.fill: parent delegate: table_func_delegate } } Component { id: table_func_header Rectangle { width: funLstView.width height: 40 color: "#F7F7F7" z:2 Row { width: parent.width height: parent.height property var childcount: 4 QxHLabel { text: "功能" width: parent.width/4 } QxHLabel { text: "设备" width: parent.width/4 } QxHLabel { text: "接口" width: parent.width/4 } QxHLabel { text: "指令" width: parent.width/4 } } } } Component { id: table_func_delegate Rectangle { width: funLstView.width height: 58 color: index % 2 == 0 ? "#F8FAFF" : "#FFFFFF" z:2 Row { width: parent.width height: parent.height property var childcount: 4 QxLabel { text: name width: parent.width/4 } SetComboBox { id: cvDev text: deviceName cbmodel: devModel width: parent.width/4 onCurrentIndexChanged: { if(currentIndex != -1) { var devName = devModel.get(currentIndex).name var dev_model_id = devModel.get(currentIndex).dev_model_id deviceName = text deviceId = devModel.get(currentIndex).id.toString() var interfaces = JSON.parse(devModel.get(currentIndex).interface) cbInterface.cbmodel.clear() for(var i =0; i