import QtQuick 2.9 import QtQuick.Controls 2.4 import QtQuick.Controls.Material 2.3 import "../Components" Page { id: root title: perData["firstname"] + " " + perData["lastname"] property bool titleIsPageTitle: true property bool ready property int status: -1 property int perId: -1 property var perData: ({}) Component.onCompleted: { if(root.loadData(root.perId)){ root.ready = true } } function loadData(perId) { console.log("loading athlete: ", perId) root.status = 905 var ret = serverConn.getAthlete(perId) root.status = ret["status"] if(ret["status"] === 200){ root.perData = ret["data"] return true } else { return false } } ScrollView { id: mainSv anchors.fill: parent anchors.margins: 10 anchors.rightMargin: 14 contentWidth: parent.width - anchors.leftMargin - anchors.rightMargin ScrollBar.vertical: ScrollBar { anchors { top: mainSv.top left: mainSv.right margins: 10 leftMargin: 3 bottom: mainSv.bottom } width: 8 active: true } Column { id: mainCol width: parent.width Row { height: root.height * 0.3 width: parent.width Image { id: photo property bool ready: false anchors.verticalCenter: parent.verticalCenter height: parent.height * 0.9 width: status === Image.Null || status === Image.Error ? 0:parent.width * 0.5 fillMode: Image.PreserveAspectFit source: perData["photo"] === undefined ? "":perData["photo"].replace("https", "http").replace("www.digitalrock.de", "egw.ifsc-climbing.org") asynchronous: true FancyBusyIndicator { height: width anchors.centerIn: parent opacity: photo.status === Image.Loading } } Column { anchors.verticalCenter: parent.verticalCenter height: parent.height * 0.9 width: parent.width - photo.width Label { height: parent.height * 0.2 width: parent.width font.pixelSize: height * 0.6 font.bold: true minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: perData["firstname"] + " " + perData["lastname"] } Label { height: parent.height * 0.2 width: parent.width font.pixelSize: height * 0.6 font.bold: false minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: perData["nation"] } Label { height: parent.height * 0.15 width: parent.width font.pixelSize: height * 0.6 font.bold: false minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: "" + perData["federation"] + "" onLinkActivated: { Qt.openUrlExternally(link) } } Label { height: parent.height * 0.15 width: parent.width font.pixelSize: height * 0.6 font.bold: false minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: qsTr("age") + ": " + perData["age"] } Label { height: parent.height * 0.15 width: parent.width font.pixelSize: height * 0.6 font.bold: false minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: qsTr("year of birth") + ": " + perData["birthdate"] } Label { height: parent.height * 0.15 width: parent.width font.pixelSize: height * 0.6 font.bold: false minimumPixelSize: 1 fontSizeMode: Text.Fit verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: qsTr("city") + ": " + perData["city"] } } } Label { anchors.horizontalCenter: parent.horizontalCenter width: parent.width wrapMode: Label.Wrap text: perData["freetext"] } 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"] } } } } } }