best results are now coosen in the same way as on digitalrock.de

This commit is contained in:
Dorian Zedler 2019-05-14 18:19:40 +02:00
parent 1c0e6aaca8
commit 40d56c184c

View file

@ -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: "<html><a href='#'>" + bestResultsRep.bestResults[index]["name"] + "</a></html>"
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"]
}
}
}
} }
} }
} }