Исправлена структура каталогов

This commit is contained in:
2024-05-16 16:26:38 +02:00
parent 53659cea38
commit fe298f0631
17 changed files with 22 additions and 66 deletions

View File

@@ -0,0 +1,56 @@
import QtQml.Models 2.1
ListModel {
id: root
readonly property var client: NooLiteClient {
id: nooLiteClient
onError: (text) => {
root.error(text)
root.isLoading = false
}
onModelLoad: (data) => {
root.populateModel(data)
root.isLoading = false
}
}
property alias serviceUrl: nooLiteClient.serviceUrl
property bool isLoading: false
property int channelsCount: 0
signal error(string text)
onServiceUrlChanged: reload()
function reload() {
root.client.loadModel()
root.isLoading = true
}
function populateModel(data) {
root.clear()
root.channelsCount = 0
data.groups.forEach(function (group) {
root.append(group)
root.channelsCount += group.channels.length
})
}
function switchChannel(channelId) {
root.client.sendCommand("switch", channelId)
}
function bindChannel(channelId) {
root.client.sendCommand("bind", channelId)
}
function unbindChannel(channelId) {
root.client.sendCommand("unbind", channelId)
}
}