2019-04-27 22:48:06 +02:00
|
|
|
import QtQuick 2.9
|
2019-04-20 22:57:40 +02:00
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
|
|
|
|
DataListView {
|
|
|
|
id: control
|
|
|
|
|
|
|
|
property var listData: ({})
|
2019-04-27 22:48:06 +02:00
|
|
|
signal closeAll()
|
2019-04-20 22:57:40 +02:00
|
|
|
|
|
|
|
onListDataChanged: {
|
|
|
|
model = listData[ root.listKey ] === undefined ? 0:listData[ root.listKey ].length
|
|
|
|
}
|
|
|
|
|
|
|
|
model: listData[ root.listKey ] === undefined ? 0:listData[ root.listKey ].length
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
id: partDel
|
|
|
|
|
|
|
|
property int ind: index
|
2019-05-11 15:16:23 +02:00
|
|
|
property var thisData: listData[ "participants" ][index]
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
state: "closed"
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
width: parent.width
|
|
|
|
height: 70
|
|
|
|
|
2019-05-11 15:16:23 +02:00
|
|
|
opacity: 0
|
|
|
|
scale: 0.9
|
|
|
|
|
|
|
|
onThisDataChanged: {
|
|
|
|
fadeInPa.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: fadeInPa
|
|
|
|
NumberAnimation { target: partDel; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
|
|
|
NumberAnimation { target: partDel; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
|
|
|
}
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
text: ""
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
onClicked: {
|
|
|
|
if(state === "closed"){
|
|
|
|
// close all other delegates
|
|
|
|
control.closeAll()
|
|
|
|
|
|
|
|
state = "opened"
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
state = "closed"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: control
|
|
|
|
onCloseAll: {
|
|
|
|
partDel.state = "closed"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
width: partDel.width
|
|
|
|
|
|
|
|
color: partDel.ind % 2 == 0 ? "white":"lightgrey"
|
|
|
|
|
|
|
|
opacity: 0.2
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: partDelCol
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
margins: 5
|
|
|
|
}
|
|
|
|
|
|
|
|
height: 70 - 2 * anchors.margins
|
2019-04-20 22:57:40 +02:00
|
|
|
|
|
|
|
Row {
|
|
|
|
id: partDelFirstRow
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: parent.height - partDelSecondRow.height
|
|
|
|
|
|
|
|
Label {
|
2019-04-27 22:48:06 +02:00
|
|
|
id: resultRankLa
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.1
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
enabled: text !== ""
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
text: listData[ "participants" ][index]["result_rank"] === undefined ? "":listData[ "participants" ][index]["result_rank"]
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2019-04-27 22:48:06 +02:00
|
|
|
id: nameLa
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.5
|
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
2019-04-27 22:48:06 +02:00
|
|
|
minimumPixelSize: 1
|
2019-04-20 22:57:40 +02:00
|
|
|
|
|
|
|
text: listData[ "participants" ][index]["firstname"] + " " + listData[ "participants" ][index]["lastname"]
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2019-04-27 22:48:06 +02:00
|
|
|
id: fedLa
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.4
|
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: false
|
|
|
|
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.4:height * 0.3 )
|
2019-04-22 12:38:23 +02:00
|
|
|
minimumPixelSize: height * 0.3
|
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
|
|
|
text: "<html>(<a href=\"" + (listData[ "participants" ][index]["fed_url"] === undefined ? "":listData[ "participants" ][index]["fed_url"]).toString() + "\">" + (listData[ "display_athlete" ] === "nation" ? listData[ "participants" ][index]["nation"] : listData[ "participants" ][index]["federation"]) + "</a>)</html>"
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: partDelSecondRow
|
|
|
|
|
|
|
|
width: parent.width
|
2019-04-27 22:48:06 +02:00
|
|
|
height: pointsLa.enabled ? parent.height / 2:0
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Item {
|
|
|
|
id: spacer
|
2019-04-20 22:57:40 +02:00
|
|
|
|
|
|
|
height: parent.height
|
2019-04-27 22:48:06 +02:00
|
|
|
width: resultRankLa.width
|
|
|
|
}
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Label {
|
|
|
|
id: pointsLa
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
width: enabled ? parent.width * 0.25:0
|
|
|
|
height: enabled ? parent.height:0
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.pixelSize: Math.abs( height * 0.6 )
|
|
|
|
minimumPixelSize: 1
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
text: listData[ "participants" ][partDel.ind]["points"] === undefined ? "":"points: "+listData[ "participants" ][partDel.ind]["points"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Column {
|
|
|
|
id: detailResultsCol
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
anchors {
|
|
|
|
top: partDelCol.bottom
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
margins: 5
|
|
|
|
}
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
height: enabled ? ( 20 + spacing ) * detailResultRowRep.model:0
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Repeater {
|
|
|
|
id: detailResultRowRep
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
property var compResults: getCompResults()
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
model: compResults.length
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
function getCompResults() {
|
2019-04-21 12:35:11 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
var obj = control.listData["route_names"]
|
|
|
|
var resultData = []
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
for(var prop in obj) {
|
|
|
|
// go through the whole array and search for data keys
|
|
|
|
if (obj.hasOwnProperty(prop) && control.listData["participants"][partDel.ind]["result" + prop.replace(" ", "")] !== undefined ) {
|
|
|
|
resultData.unshift([prop, obj[prop].replace("\n", " - ")])
|
|
|
|
//console.log("found " + obj[prop] + " at index " + prop)
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
return resultData
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
delegate: Row {
|
|
|
|
width: parent.width
|
|
|
|
height: detailResultsCol.height / detailResultRowRep.model - detailResultsCol.spacing
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
visible: height > 0
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Item {
|
|
|
|
id: spacer_
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.15
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Label {
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width / 2
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
minimumPixelSize: 1
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
text: detailResultRowRep.compResults[index][1]
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Label {
|
|
|
|
id: detailResultListLa
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.35
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 )
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
minimumPixelSize: 1
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
text: control.listData["participants"][partDel.ind]["result"+detailResultRowRep.compResults[index][0].replace(" ", "")] === undefined ? "":control.listData["participants"][partDel.ind]["result"+detailResultRowRep.compResults[index][0].replace(" ", "")].replace("\n", " ")
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
Behavior on height {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "closed"
|
|
|
|
PropertyChanges {
|
|
|
|
target: partDel
|
|
|
|
height: 70
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: detailResultsCol
|
|
|
|
enabled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "opened"
|
|
|
|
PropertyChanges {
|
|
|
|
target: partDel
|
|
|
|
height: 70 + detailResultsCol.height
|
|
|
|
}
|
2019-04-20 22:57:40 +02:00
|
|
|
|
2019-04-27 22:48:06 +02:00
|
|
|
PropertyChanges {
|
|
|
|
target: detailResultsCol
|
|
|
|
enabled: true
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-27 22:48:06 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
transitions: [
|
|
|
|
Transition {
|
|
|
|
from: "*"
|
|
|
|
to: "*"
|
|
|
|
NumberAnimation {
|
|
|
|
properties: "height"
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-04-20 22:57:40 +02:00
|
|
|
}
|
|
|
|
}
|