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-07-04 09:03:39 +02:00
|
|
|
import QtQuick 2.10
|
|
|
|
import QtQuick.Controls 2.4
|
2019-07-07 17:15:30 +02:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-07-04 09:03:39 +02:00
|
|
|
import QtQuick.Controls.Material 2.1
|
2021-06-06 18:34:27 +02:00
|
|
|
import QtGraphicalEffects 1.0
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
import "SpeedFlowChart.js" as SpeedFlowChart
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Item {
|
2019-07-04 09:03:39 +02:00
|
|
|
id: control
|
|
|
|
|
|
|
|
property var flowchartData
|
|
|
|
property var allFlowchartData
|
2019-07-07 17:13:55 +02:00
|
|
|
property int rounds: 0
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2019-07-04 23:00:43 +02:00
|
|
|
property int refreshes: 0
|
|
|
|
property int roundRefreshes: 1
|
|
|
|
|
2019-07-04 09:03:39 +02:00
|
|
|
onFlowchartDataChanged: {
|
|
|
|
prepareData()
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepareData() {
|
2019-07-07 17:13:55 +02:00
|
|
|
|
|
|
|
if(!control.enabled || control.flowchartData === undefined || control.flowchartData['route_names'] === undefined)
|
2019-07-04 23:00:43 +02:00
|
|
|
return
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
var flowchartResult = SpeedFlowChart.convertResultsToSpeedFlowchartResult(control.flowchartData)
|
|
|
|
const l = flowchartResult.rounds.length;
|
|
|
|
const dummy = { dummy: true };
|
|
|
|
flowchartResult.rounds[l - 2].pairs = [
|
|
|
|
dummy,
|
|
|
|
...flowchartResult.rounds[l - 1].pairs,
|
|
|
|
...flowchartResult.rounds[l - 2].pairs,
|
|
|
|
];
|
|
|
|
flowchartResult.rounds[l - 2].roundName = `${
|
|
|
|
flowchartResult.rounds[l - 1].roundName
|
|
|
|
} / ${flowchartResult.rounds[l - 2].roundName}`;
|
|
|
|
flowchartResult.rounds.pop();
|
|
|
|
control.allFlowchartData = flowchartResult
|
2019-07-04 23:00:43 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
ListView {
|
|
|
|
id: roundListView
|
|
|
|
|
2022-08-11 08:47:22 +02:00
|
|
|
property int columnWidth: height * 0.4
|
2021-06-06 18:34:27 +02:00
|
|
|
property int columnHeight: height
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
bottom: parent.bottom
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
2019-07-04 09:03:39 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
width: Math.min((columnWidth + spacing) * model, control.width)
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
spacing: app.height * 0.05
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
orientation: ListView.LeftToRight
|
|
|
|
boundsBehavior: ListView.StopAtBounds
|
2019-07-04 23:00:43 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
model: control.allFlowchartData.rounds.length
|
2019-07-04 23:00:43 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
delegate: Item {
|
|
|
|
id: roundItem
|
2019-07-04 23:00:43 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
property int thisIndex: index
|
2022-08-14 17:43:38 +02:00
|
|
|
property var thisData: control.allFlowchartData.rounds[thisIndex]
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
property bool thisRoundIsValid: true
|
|
|
|
|
|
|
|
property bool thisIsLastRound: thisIndex === roundListView.model - 1
|
|
|
|
property bool thisIsSemiFinal: thisIndex === roundListView.model - 2
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
property int tileSize: (roundItem.height / 8 - roundNameLa.height) * 1.45
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
width: roundListView.columnWidth
|
|
|
|
height: roundListView.columnHeight
|
2019-07-07 17:13:55 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Column {
|
|
|
|
id: roundCol
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: roundNameLa
|
|
|
|
width: parent.width
|
|
|
|
height: control.height * 0.05
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.pixelSize: height * 0.6
|
|
|
|
minimumPixelSize: 1
|
|
|
|
font.bold: true
|
2022-08-14 17:43:38 +02:00
|
|
|
text: roundItem.thisData.roundName ?
|
|
|
|
roundItem.thisData.roundName :
|
2021-06-06 18:34:27 +02:00
|
|
|
"-"
|
2019-07-07 17:13:55 +02:00
|
|
|
}
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Repeater {
|
|
|
|
id: rectRep
|
2022-08-14 17:43:38 +02:00
|
|
|
model: roundItem.thisData.pairs.length
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
delegate: Item {
|
|
|
|
id: matchItm
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
property bool lowerPart: (index%2 > 0)
|
2022-08-14 17:43:38 +02:00
|
|
|
property var thisData: roundItem.thisData.pairs[index]
|
2021-06-06 18:34:27 +02:00
|
|
|
property int thisIndex: index
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
height: (roundItem.height - roundNameLa.height) / rectRep.model - roundCol.spacing
|
2021-06-06 18:34:27 +02:00
|
|
|
width: roundItem.width
|
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
onThisDataChanged: {
|
2021-06-06 18:34:27 +02:00
|
|
|
fadeInPa.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: fadeInPa
|
|
|
|
NumberAnimation { target: matchItm; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
|
|
|
NumberAnimation { target: matchItm; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas {
|
|
|
|
id: lineCanvas
|
|
|
|
width: app.width; height: app.height
|
|
|
|
contextType: "2d"
|
|
|
|
|
|
|
|
visible: !roundItem.thisIsLastRound
|
|
|
|
|
|
|
|
property int targetYFactor: matchItm.lowerPart ? -1:1
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Path {
|
|
|
|
id: firstPartPath
|
|
|
|
startX: matchItm.width
|
|
|
|
startY: matchItm.height * 0.5
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
PathQuad {
|
|
|
|
id: firstPartPathQuad
|
|
|
|
relativeX: roundListView.spacing * 0.5
|
|
|
|
relativeY: matchItm.height * 0.25 * lineCanvas.targetYFactor
|
|
|
|
relativeControlX: relativeX
|
|
|
|
relativeControlY: 0
|
|
|
|
}
|
2019-07-05 13:31:54 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
PathQuad {
|
|
|
|
relativeX: roundListView.spacing * 0.5
|
|
|
|
relativeY: matchItm.height * 0.25 * lineCanvas.targetYFactor
|
|
|
|
relativeControlX: 0
|
|
|
|
relativeControlY: relativeY
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
onPaint: {
|
|
|
|
context.strokeStyle = "lightgrey"
|
|
|
|
context.lineWidth = matchRect.height * 0.05
|
|
|
|
context.path = firstPartPath;
|
|
|
|
context.stroke();
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
RectangularGlow {
|
|
|
|
id: effect
|
2022-08-14 17:43:38 +02:00
|
|
|
visible: matchRect.visible
|
2021-06-06 18:34:27 +02:00
|
|
|
anchors.fill: matchRect
|
|
|
|
glowRadius: 0
|
|
|
|
spread: 0
|
|
|
|
opacity: 0.3
|
|
|
|
color: "black"
|
|
|
|
cornerRadius: matchRect.radius
|
|
|
|
}
|
2019-07-04 23:00:43 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Rectangle {
|
|
|
|
id: matchRect
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
anchors {
|
|
|
|
centerIn: !matchItm.thisIsFinal ? parent:undefined
|
|
|
|
bottom: matchItm.thisIsFinal ? parent.bottom:undefined
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
visible: !matchItm.thisData.dummy
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
width: parent.width
|
|
|
|
height: roundItem.tileSize
|
2022-08-14 17:43:38 +02:00
|
|
|
|
2021-06-08 19:23:55 +02:00
|
|
|
color: Material.dialogColor
|
2021-06-06 18:34:27 +02:00
|
|
|
radius: height * 0.2
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Column {
|
|
|
|
spacing: 0
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: matchRect.radius * 0.5
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Repeater {
|
|
|
|
// for the two athletes
|
|
|
|
model: 2
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
delegate: RowLayout {
|
2022-08-14 17:43:38 +02:00
|
|
|
id: laneRow
|
|
|
|
|
|
|
|
property var thisData: index === 0 ? matchItm.thisData.laneA : matchItm.thisData.laneB
|
|
|
|
property var participant: thisData ? thisData.participant : undefined
|
|
|
|
property var result: thisData ? thisData.result : undefined
|
|
|
|
property var lane: index === 0 ? "A":"B"
|
|
|
|
property bool isWinner: matchItm.thisData.winner === laneRow.lane
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
height: parent.height / 2 - parent.spacing
|
|
|
|
width: parent.width
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
spacing: height * 0.1
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Label {
|
|
|
|
Layout.preferredHeight: parent.height
|
2022-08-11 08:47:22 +02:00
|
|
|
Layout.preferredWidth: parent.width * 0.08
|
|
|
|
|
|
|
|
height: parent.height
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
2022-08-11 08:47:22 +02:00
|
|
|
font.pixelSize: height * 0.4
|
|
|
|
font.bold: true
|
|
|
|
opacity: 0.7
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
text: laneRow.participant ?
|
2021-06-06 18:34:27 +02:00
|
|
|
(
|
2022-08-14 17:43:38 +02:00
|
|
|
laneRow.participant.results[0].rank < 10 ?
|
|
|
|
laneRow.participant.results[0].rank + " ":
|
|
|
|
laneRow.participant.results[0].rank
|
2021-06-06 18:34:27 +02:00
|
|
|
):
|
|
|
|
""
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Label {
|
|
|
|
Layout.preferredHeight: parent.height
|
2022-08-11 08:47:22 +02:00
|
|
|
Layout.maximumWidth: parent.width * 0.6
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
font.pixelSize: height * 0.5
|
2022-08-14 17:43:38 +02:00
|
|
|
font.bold: laneRow.isWinner
|
2021-06-06 18:34:27 +02:00
|
|
|
elide: "ElideRight"
|
2019-07-04 09:03:39 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
color: laneRow.isWinner ? Material.color(Material.Green):Material.primaryTextColor
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
text: laneRow.participant ? laneRow.participant.firstName + " " + laneRow.participant.lastName :"-"
|
2021-06-06 18:34:27 +02:00
|
|
|
}
|
2019-07-05 13:31:54 +02:00
|
|
|
|
2022-08-11 08:47:22 +02:00
|
|
|
Rectangle {
|
|
|
|
Layout.preferredHeight: parent.height * 0.8
|
|
|
|
Layout.preferredWidth: parent.width * 0.13
|
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
visible: laneRow.participant && laneRow.participant.startNumber ? true:false
|
2022-08-11 08:47:22 +02:00
|
|
|
radius: height / 2
|
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
border.width: parent.height * 0.03
|
2022-08-11 08:47:22 +02:00
|
|
|
border.color: Material.frameColor
|
|
|
|
color: "transparent"
|
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
padding: parent.parent.height * 0.1
|
|
|
|
leftPadding: padding * 2
|
|
|
|
rightPadding: leftPadding
|
|
|
|
|
|
|
|
font.pixelSize: parent.height * 0.5
|
|
|
|
font.bold: true
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
text: laneRow.participant ? laneRow.participant.startNumber:""
|
2022-08-11 08:47:22 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
Label {
|
|
|
|
Layout.preferredHeight: parent.height
|
2022-08-11 08:47:22 +02:00
|
|
|
Layout.preferredWidth: parent.width * 0.15
|
2019-07-05 14:06:09 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
height: parent.height
|
2019-07-05 13:31:54 +02:00
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2022-08-11 08:47:22 +02:00
|
|
|
horizontalAlignment: Text.AlignRight
|
2021-06-06 18:34:27 +02:00
|
|
|
font.pixelSize: height * 0.5
|
2022-08-14 17:43:38 +02:00
|
|
|
font.bold: laneRow.isWinner
|
2022-08-11 08:47:22 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
color: laneRow.isWinner ? Material.color(Material.Green):Material.primaryTextColor
|
2021-06-06 18:34:27 +02:00
|
|
|
|
2022-08-14 17:43:38 +02:00
|
|
|
text: laneRow.result ? laneRow.result.result : ""
|
2021-06-06 18:34:27 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-05 13:31:54 +02:00
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-06 18:34:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: blueRockBadgeLoader
|
|
|
|
|
|
|
|
x: (parent.width - width) / 2
|
|
|
|
y: (parent.height - roundNameLa.height - height) / 2 + roundNameLa.height
|
|
|
|
|
|
|
|
sourceComponent: roundItem.thisIsSemiFinal ? blueRockBadgeComponent:undefined
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: blueRockBadgeComponent
|
|
|
|
|
|
|
|
BlueRockBadge {
|
2022-08-14 17:43:38 +02:00
|
|
|
width: roundItem.width * 0.8
|
2021-06-06 18:34:27 +02:00
|
|
|
height: width * 0.25
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|