From 40d56c184c48b89cd77ed0b0a613eca8d9172dbd Mon Sep 17 00:00:00 2001 From: dorian Date: Tue, 14 May 2019 18:19:40 +0200 Subject: [PATCH] best results are now coosen in the same way as on digitalrock.de --- resources/qml/Pages/AthleteProfilePage.qml | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/resources/qml/Pages/AthleteProfilePage.qml b/resources/qml/Pages/AthleteProfilePage.qml index 2b1faf6..9d35531 100644 --- a/resources/qml/Pages/AthleteProfilePage.qml +++ b/resources/qml/Pages/AthleteProfilePage.qml @@ -217,6 +217,120 @@ Page { } + Rectangle { + id: separatorLine + + anchors.horizontalCenter: parent.horizontalCenter + + height: 1 + width: parent.width * 0.9 + + color: "black" + + } + + + + Repeater { + id: bestResultsRep + + property var bestResults: getBestResults() + + function getBestResults(){ + + var allResults = root.perData["results"] + + allResults.sort(function(a, b) { + // sort results by weight + var year = new Date().getFullYear(); + var weightA = a.rank/2 + (year-parseInt(a.date)) + 4*!a.nation; + var weightB = b.rank/2 + (year-parseInt(b.date)) + 4*!b.nation; + return weightA - weightB; + }); + + var bestResults = allResults.slice(0,12) + + bestResults.sort(function(a, b) { + // sort results by date + var aTs = Date.fromLocaleString(Qt.locale(), a["date"], "yyyy-MM-dd").getTime() + var bTs = Date.fromLocaleString(Qt.locale(), b["date"], "yyyy-MM-dd").getTime() + return bTs - aTs; + }); + + return bestResults + } + + width: parent.width + + model: bestResults.length > 12 ? 12:bestResults.length + + delegate: Row { + id: bestResultRow + + width: parent.width + height: 50 + + Label { + id: bestResultRankLa + + width: parent.width * 0.2 + height: parent.height + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + fontSizeMode: Text.Fit + minimumPixelSize: 1 + + font.pixelSize: height * 0.6 + + text: bestResultsRep.bestResults[index]["rank"] + } + + Label { + id: bestResultCompLa + + width: parent.width * 0.6 + height: parent.height + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + fontSizeMode: Text.Fit + minimumPixelSize: height * 0.3 + + font.pixelSize: height * 0.3 + + elide: "ElideRight" + + text: "" + bestResultsRep.bestResults[index]["name"] + "" + + onLinkActivated: { + app.openResults( bestResultsRep.bestResults[index]["WetId"], bestResultsRep.bestResults[index]["GrpId"], 1 ) + } + } + + Label { + id: bestResultDateLa + + width: parent.width * 0.2 + height: parent.height + + scale: 0.8 + + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + + fontSizeMode: Text.Fit + minimumPixelSize: 1 + + font.pixelSize: height * 0.6 + + text: bestResultsRep.bestResults[index]["date"] + } + } + } + } } }