2019-07-07 17:15:30 +02:00
|
|
|
/*
|
|
|
|
blueROCK - for digital rock
|
|
|
|
Copyright (C) 2019 Dorian Zedler
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Controls.Material 2.3
|
2021-06-06 18:34:27 +02:00
|
|
|
import QtGraphicalEffects 1.0
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
property var widgetData: currentWidgetData
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
control.ready = true
|
|
|
|
control.status = 200
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: mainSv
|
|
|
|
|
|
|
|
anchors.fill: parent
|
2021-06-06 18:34:27 +02:00
|
|
|
anchors.margins: 20
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
contentWidth: parent.width - anchors.margins * 2
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
Column {
|
|
|
|
id: mainCol
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
Row {
|
|
|
|
height: control.height * 0.3
|
|
|
|
width: parent.width
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
spacing: photoContainerItem.width * 0.1
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Item {
|
|
|
|
id: photoContainerItem
|
2019-05-23 23:17:27 +02:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
height: parent.height * 0.9
|
2021-06-06 18:34:27 +02:00
|
|
|
width: photo.status === Image.Null || photo.status === Image.Error ? 0:parent.width * 0.4
|
|
|
|
|
|
|
|
RectangularGlow {
|
|
|
|
id: effect
|
|
|
|
visible: photo.ready
|
|
|
|
anchors.fill: photo
|
|
|
|
glowRadius: 1
|
|
|
|
opacity: 0.4
|
|
|
|
color: "black"
|
|
|
|
cornerRadius: photo.width * 0.2
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Image {
|
|
|
|
id: photo
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
property bool ready: photo.status === Image.Ready
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
anchors.centerIn: parent
|
2021-06-06 18:34:27 +02:00
|
|
|
height: parent.height * 0.9
|
|
|
|
width: height * 0.7
|
|
|
|
|
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
mipmap: true
|
|
|
|
|
|
|
|
source: widgetData["photo"] === undefined ?
|
|
|
|
"":
|
|
|
|
widgetData["photo"].replace("https", "http")
|
|
|
|
asynchronous: true
|
|
|
|
|
|
|
|
FancyBusyIndicator {
|
|
|
|
height: width
|
|
|
|
anchors.centerIn: parent
|
|
|
|
opacity: photo.status === Image.Loading
|
|
|
|
}
|
|
|
|
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
|
|
|
maskSource: Item {
|
|
|
|
width: photo.width
|
|
|
|
height: photo.height
|
|
|
|
Rectangle {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
width: photo.width
|
|
|
|
height: photo.height
|
|
|
|
radius: photo.width * 0.2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
|
|
|
height: parent.height * 0.9
|
2021-06-06 18:34:27 +02:00
|
|
|
width: parent.width - photoContainerItem.width * 1.1
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-20 20:11:19 +02:00
|
|
|
//% "Age"
|
|
|
|
text: qsTrId("age") + ": " + widgetData["age"]
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-20 20:11:19 +02:00
|
|
|
//% "Year of birth"
|
|
|
|
text: qsTrId("yearOfBirth") + ": " + widgetData["birthdate"]
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-20 20:11:19 +02:00
|
|
|
//% "City"
|
|
|
|
text: qsTrId("city") + ": " + widgetData["city"]
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
visible: bestResultsRep.model > 0
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
text: widgetData["freetext"] === undefined ?
|
|
|
|
"":
|
|
|
|
(widgetData["freetext"] + "<br>")
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: separatorLine
|
|
|
|
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
height: 1
|
2021-06-06 18:34:27 +02:00
|
|
|
width: parent.width
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2021-06-08 19:23:55 +02:00
|
|
|
color: Material.foreground
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
id: toggleAllResultsBt
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
|
|
|
|
visible: bestResultsRep.model > 0
|
|
|
|
|
|
|
|
flat: true
|
|
|
|
|
2021-06-20 20:11:19 +02:00
|
|
|
text: bestResultsRep.showAllResults ?
|
|
|
|
//% "Show best results"
|
|
|
|
qsTrId("showBestResults"):
|
|
|
|
//% "Show all results"
|
|
|
|
qsTrId("showAllResults")
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
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
|
2021-06-06 22:38:30 +02:00
|
|
|
spacing: width * 0.05
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
width: parent.width * 0.1
|
2019-05-23 23:17:27 +02:00
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-06-06 18:34:27 +02:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
minimumPixelSize: 1
|
|
|
|
|
|
|
|
font.pixelSize: height * 0.6
|
|
|
|
|
|
|
|
text: bestResultsRep.bestResults[index]["rank"]
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: bestResultCompLa
|
|
|
|
|
2021-06-06 22:38:30 +02:00
|
|
|
width: parent.width * 0.6
|
2019-05-23 23:17:27 +02:00
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-06-06 18:34:27 +02:00
|
|
|
horizontalAlignment: Text.AlignLeft
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
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: {
|
2019-05-29 20:59:01 +02:00
|
|
|
app.openWidget( { comp: bestResultsRep.bestResults[index]["WetId"], cat: bestResultsRep.bestResults[index]["GrpId"] } )
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: bestResultDateLa
|
|
|
|
|
|
|
|
width: parent.width * 0.2
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
scale: 0.8
|
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2021-06-06 18:34:27 +02:00
|
|
|
horizontalAlignment: Text.AlignRight
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
minimumPixelSize: 1
|
|
|
|
|
|
|
|
font.pixelSize: height * 0.6
|
|
|
|
|
|
|
|
text: bestResultsRep.bestResults[index]["date"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|