From 14bbd77e71b21e94c5abb977d2812503f85c291c Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Thu, 17 Jun 2021 15:36:57 +0200 Subject: [PATCH] Fix highlighting bug on registration --- resources/qml/Widgets/RegistrationWidget.qml | 27 +++++++++++++------- resources/qml/main.qml | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/resources/qml/Widgets/RegistrationWidget.qml b/resources/qml/Widgets/RegistrationWidget.qml index 59576f8..68642c5 100644 --- a/resources/qml/Widgets/RegistrationWidget.qml +++ b/resources/qml/Widgets/RegistrationWidget.qml @@ -42,6 +42,7 @@ DataListView { } property var widgetData: currentWidgetData + property var athletes function getSubtitle() { var titleString @@ -90,7 +91,7 @@ DataListView { return widgetData[ "athletes" ][index]["firstname"] + " " + widgetData[ "athletes" ][index]["lastname"] + " (" + fedName + ")" } - function changeCat(){ + function changeCat() { var cats = control.widgetData["categorys"] cats.sort(function(a, b) { @@ -110,6 +111,14 @@ DataListView { selector.appear(selectOptions, qsTr("select cat")) } + function filterAthletes(athletes) { + var filtered = athletes.filter(function(athlete){ + return parseInt(athlete.cat) === parseInt(params.cat) + }) + + return filtered + } + Connections { target: selector function onSelectionFinished(index, data) { @@ -119,12 +128,9 @@ DataListView { } } - status: model === 0 ? 901:200 - - model: widgetData[ 'athletes' ] === undefined ? 0:widgetData[ 'athletes' ].length - Component.onCompleted: { - if(model > 0){ + athletes = filterAthletes(widgetData["athletes"]) + if(athletes.length > 0){ control.ready = true control.status = 200 } @@ -136,16 +142,19 @@ DataListView { onRefresh: { updateData({}, false) + athletes = [] + athletes = filterAthletes(widgetData["athletes"]) } + model: athletes + delegate: ItemDelegate { id: partDel property int thisIndex: index - property var thisData: widgetData[ "athletes" ][index] + property var thisData: modelData - width: parent.width - height: parseInt(thisData.cat) === parseInt(params.cat) ? 50:0 + width: parseInt(thisData.cat) === parseInt(params.cat) ? control.width:control.width * 0.2 opacity: 0 scale: 0.9 diff --git a/resources/qml/main.qml b/resources/qml/main.qml index c43b6f7..063b5fa 100644 --- a/resources/qml/main.qml +++ b/resources/qml/main.qml @@ -134,6 +134,7 @@ Window { //mainStack.push("Pages/AthleteSearchPage.qml") //openWidget({comp: 11651, cat: 26}) //openWidget({person: 6623}) + openWidget({cat: 35, comp: 11181, type: "starters"}) } FontLoader {