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