native: convert from list to table

This commit is contained in:
Johannes Jöns 2024-07-12 00:10:46 +02:00
parent 6c48ccd73b
commit d2c50fc2e5

View file

@ -1,17 +1,16 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 2.15
Rectangle {
visible: true
id: root
SystemPalette { id: activeColors; colorGroup: SystemPalette.Active }
SystemPalette { id: inactiveColors; colorGroup: SystemPalette.Inactive }
SystemPalette { id: disabledColors; colorGroup: SystemPalette.Disabled }
function getColors() {
return root.active ? activeColors : inactiveColors;
return active ? activeColors : inactiveColors;
}
property string authToken: ""
@ -99,35 +98,28 @@ Rectangle {
spacing: 0
Rectangle {
id: header
height: 50
width: parent.width
color: getColors().midlight
height: 40
Layout.fillWidth: true
RowLayout {
anchors.fill: parent
spacing: 10
anchors.margins: 5
Text { text: qsTr("Name"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("Key"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("Amount"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("Start"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("End"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("Group"); color: getColors().text; Layout.fillWidth: true }
Text { text: qsTr("Name"); color: getColors().text; Layout.preferredWidth: 150; font.bold: true }
Text { text: qsTr("Key"); color: getColors().text; Layout.preferredWidth: 150; font.bold: true }
Text { text: qsTr("Amount"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
Text { text: qsTr("Start"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
Text { text: qsTr("End"); color: getColors().text; Layout.preferredWidth: 100; font.bold: true }
Text { text: qsTr("Group"); color: getColors().text; Layout.preferredWidth: 150; font.bold: true }
}
}
ScrollView {
Layout.fillWidth: true
Layout.fillHeight: true
ListView {
id: listView
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
boundsBehavior: Flickable.StopAtBounds
model: filteredApiDataModel // Use the filtered model
delegate: Rectangle {
@ -140,13 +132,12 @@ Rectangle {
spacing: 10
anchors.margins: 5
Text { text: model.name; color: getColors().text; Layout.fillWidth: true }
Text { text: model.key; color: getColors().text; Layout.fillWidth: true }
Text { text: model.amount; color: getColors().text; Layout.fillWidth: true }
Text { text: model.start; color: getColors().text; Layout.fillWidth: true }
Text { text: model.end; color: getColors().text; Layout.fillWidth: true }
Text { text: model.group; color: getColors().text; Layout.fillWidth: true }
}
Text { text: model.name; color: getColors().text; Layout.preferredWidth: 150; elide: Text.ElideRight }
Text { text: model.key; color: getColors().text; Layout.preferredWidth: 150; elide: Text.ElideRight }
Text { text: model.amount; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
Text { text: model.start; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
Text { text: model.end; color: getColors().text; Layout.preferredWidth: 100; elide: Text.ElideRight }
Text { text: model.group; color: getColors().text; Layout.preferredWidth: 150; elide: Text.ElideRight }
}
}
}
@ -197,7 +188,6 @@ Rectangle {
amount: jsonResponse[i].licenses[ii].amount ? jsonResponse[i].licenses[ii].amount.toString() : "∞",
key: jsonResponse[i].licenses[ii].key
});
}
}
filterModel() // Filter the model after loading data