369 lines
11 KiB
QML
369 lines
11 KiB
QML
import QtQuick 2.9
|
|
import QtQuick.Controls 2.4
|
|
import QtQuick.Controls.Material 2.3
|
|
|
|
import "../Components"
|
|
|
|
Page {
|
|
id: control
|
|
|
|
title: widgetData["firstname"] + " " + widgetData["lastname"]
|
|
property bool titleIsPageTitle: true
|
|
property bool ready
|
|
property int status: -1
|
|
|
|
property int perId: -1
|
|
|
|
property var widgetData: currentWidgetData
|
|
|
|
Component.onCompleted: {
|
|
control.ready = true
|
|
control.status = 200
|
|
}
|
|
|
|
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: control.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: widgetData["photo"] === undefined ? "":widgetData["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: widgetData["firstname"] + " " + widgetData["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: widgetData["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: "<html><a href='" + widgetData["fed_url"] + "'>" + widgetData["federation"] + "</a>"
|
|
|
|
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") + ": " + widgetData["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") + ": " + widgetData["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") + ": " + widgetData["city"]
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Label {
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: bestResultsRep.model > 0
|
|
|
|
width: parent.width
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
text: widgetData["freetext"] === undefined ? "":widgetData["freetext"]
|
|
|
|
}
|
|
|
|
Rectangle {
|
|
id: separatorLine
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
height: 1
|
|
width: parent.width * 0.9
|
|
|
|
color: "black"
|
|
|
|
}
|
|
|
|
Button {
|
|
id: toggleAllResultsBt
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
visible: bestResultsRep.model > 0
|
|
|
|
flat: true
|
|
|
|
text: bestResultsRep.showAllResults ? qsTr("show best results"):qsTr("show all results")
|
|
|
|
onClicked: {
|
|
bestResultsRep.showAllResults = !bestResultsRep.showAllResults
|
|
}
|
|
|
|
Behavior on text {
|
|
FadeAnimation {
|
|
target: toggleAllResultsBt
|
|
fadeDuration: 150
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Repeater {
|
|
id: bestResultsRep
|
|
|
|
property var bestResults: showAllResults ? getAllResults() : getBestResults()
|
|
property bool showAllResults: false
|
|
|
|
function getBestResults(){
|
|
|
|
var allResults = control.widgetData["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
|
|
}
|
|
|
|
function getAllResults() {
|
|
var allResults = control.widgetData["results"]
|
|
|
|
allResults.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 allResults
|
|
}
|
|
|
|
width: parent.width
|
|
|
|
model: bestResults.length
|
|
|
|
delegate: Row {
|
|
id: bestResultRow
|
|
|
|
property var thisData: bestResultsRep.bestResults[index]
|
|
|
|
width: parent.width
|
|
height: 50
|
|
|
|
opacity: 0
|
|
scale: 0.9
|
|
|
|
onThisDataChanged: {
|
|
fadeInPa.start()
|
|
}
|
|
|
|
ParallelAnimation {
|
|
id: fadeInPa
|
|
NumberAnimation { target: bestResultRow; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
|
NumberAnimation { target: bestResultRow; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
|
}
|
|
|
|
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.openWidget( { comp: bestResultsRep.bestResults[index]["WetId"], cat: bestResultsRep.bestResults[index]["GrpId"] } )
|
|
}
|
|
}
|
|
|
|
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"]
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|