fixed some bugs that occured when cats of one comp cover multiple disciplines

This commit is contained in:
Dorian Zedler 2019-07-07 17:13:55 +02:00
parent 3e1f8c4bec
commit 5421266bc8
4 changed files with 72 additions and 46 deletions

View file

@ -8,7 +8,7 @@ ListView {
property var flowchartData
property var allFlowchartData
property int rounds
property int rounds: 0
property int tileSize: app.height / 8 * 0.8
property int refreshes: 0
@ -16,7 +16,6 @@ ListView {
anchors.fill: parent
anchors.margins: 10
model: rounds + 2
spacing: app.width * 0.1
@ -27,8 +26,11 @@ ListView {
prepareData()
}
model: 0
function prepareData() {
if(!control.enabled)
if(!control.enabled || control.flowchartData === undefined || control.flowchartData['route_names'] === undefined)
return
/*refreshes += 1
@ -65,19 +67,16 @@ ListView {
// array to store the restructured data
var allData = []
control.allFlowchartData = []
control.rounds = Object.keys(control.flowchartData['route_names']).length > 2 ? control.flowchartData['route_names']["2"].includes("8") ? 2:1 : 0
//console.log(JSON.stringify(flowchartData['route_names']))
for(var round in flowchartData['route_names']){
//console.log(round)
if(flowchartData['route_names'].hasOwnProperty(round) && parseInt(round) >= 0){
//console.log(round)
/*if(allData.length > 0){
allData[allData.length-1].push(round)
allData[allData.length-1].push(flowchartData['route_names'][round])
}*/
if(parseInt(round) === 0){
// this is the first round
@ -94,7 +93,8 @@ ListView {
});
var nextRoundPairs = []
var nextRoundMatches = Math.pow(2, control.model-1)
var totalMatches = (parseInt(Object.keys(control.flowchartData['route_names']).length > 2 ? control.flowchartData['route_names']["2"].includes("8") ? 2:1 : 0) + 2)
var nextRoundMatches = Math.pow(2, totalMatches-1)
for(var i = 0; i < nextRoundMatches; i++){
nextRoundPairs.push([qualificationResults[i], qualificationResults[nextRoundMatches*2-i-1]])
@ -203,14 +203,12 @@ ListView {
}
}
}
control.allFlowchartData = allData
control.model = (parseInt(Object.keys(control.flowchartData['route_names']).length > 2 ? control.flowchartData['route_names']["2"].includes("8") ? 2:1 : 0) + 2)
//console.log(JSON.stringify(allData))
}
function getWinner(part1, part2){
}
delegate: Column {
id: roundCol
@ -232,6 +230,7 @@ ListView {
verticalAlignment: Text.AlignVCenter
fontSizeMode: Text.Fit
font.pixelSize: height * 0.6
minimumPixelSize: 1
font.bold: true
text: roundCol.thisRoundIsValid && control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-1] !== undefined ? control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-1] : "-"
}
@ -261,6 +260,16 @@ ListView {
height: !roundCol.thisIsLastRound ? (roundCol.height - roundNameLa.height) / rectRep.model - roundCol.spacing : (thisIsFinal ? (roundCol.height - roundNameLa.height) * 0.5 + control.tileSize * 0.5 : (roundCol.height - roundNameLa.height) - (roundCol.height - roundNameLa.height) * 0.5 + control.tileSize * 0.5 )
width: parent.width
onMatchDataChanged: {
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
@ -325,7 +334,6 @@ ListView {
Label {
Layout.preferredHeight: parent.height
//Layout.preferredWidth: parent.width * 0.1
height: parent.height
@ -348,7 +356,7 @@ ListView {
horizontalAlignment: Text.AlignHCenter
//horizontalAlignment: app.landscape() ? Text.AlignLeft : Text.AlignLeft
font.pixelSize: app.landscape() ? height * 0.4 : height * 0.6
minimumPixelSize: app.landscape() ? height * 0.35 : height * 0.5
minimumPixelSize: (app.landscape() ? height * 0.35 : height * 0.5) < 1 ? 1 : (app.landscape() ? height * 0.35 : height * 0.5)
fontSizeMode: Text.Fit
font.bold: matchItm.winnerIndex === index
elide: "ElideRight"
@ -362,7 +370,6 @@ ListView {
Label {
Layout.preferredHeight: parent.height
//Layout.preferredWidth: parent.width * 0.2
height: parent.height
@ -371,25 +378,12 @@ ListView {
Layout.alignment: Layout.Right
text: matchItm.thisMatchData[index] !== undefined ? ( parseFloat(matchItm.thisMatchData[index]['result'+matchItm.thisRound]) ? (parseFloat(matchItm.thisMatchData[index]['result'+matchItm.thisRound]).toFixed(2)) : matchItm.thisMatchData[index]['result'+matchItm.thisRound] ): "-"
text: matchItm.thisMatchData[index] !== undefined && matchItm.thisMatchData[index]['result'+matchItm.thisRound] !== undefined ?
( parseFloat(matchItm.thisMatchData[index]['result'+matchItm.thisRound]) ?
(parseFloat(matchItm.thisMatchData[index]['result'+matchItm.thisRound]).toFixed(2))
: matchItm.thisMatchData[index]['result'+matchItm.thisRound] )
: "-"
}
/*Rectangle {
id: hasWonRect
anchors.verticalCenter: parent.verticalCenter
height: width
width: parent.width * 0.1
scale: 0.7
radius: width * 0.5
color: "green"
visible: (parseInt(matchItm.thisMatchData[0]["result_rank" + roundCol.thisRound ]) < parseInt(matchItm.thisMatchData[1]["result_rank" + roundCol.thisRound])) === (index === 0 ? true:false)
}*/
}
}
}

View file

@ -31,7 +31,7 @@ DataListView {
property Component headerComponent: RowLayout {
height: parent.height
width: 100//childrenRect.width
//width: 10//childrenRect.width
spacing: 0

View file

@ -34,9 +34,9 @@ DataListView {
property bool titleIsPageTitle: true
property Component headerComponent: RowLayout {
id: headerComponent
height: parent.height
width: 100//childrenRect.width
spacing: 0
@ -63,6 +63,8 @@ DataListView {
ToolButton {
id: moreToolBt
Layout.alignment: Layout.Right
onClicked: {
control.changeCat()
}
@ -96,6 +98,20 @@ DataListView {
updateData({}, false)
}
onWidgetDataChanged: {
console.log("widget data changed")
if(control.widgetData['discipline'] === 'speed'){
speedFlowChart.flowchartData = ({})
speedFlowChart.enabled = true
speedFlowChart.flowchartData = control.widgetData
}
else {
speedFlowChart.enabled = false
speedFlowChart.flowchartData = ({})
}
}
function getSubtitle() {
var titleString
@ -151,6 +167,12 @@ DataListView {
}
}
onContentYChanged: {
if(contentY > 0 && speedFlowChartBackgroundRect.state === "visible"){
control.positionViewAtBeginning()
}
}
delegate: ItemDelegate {
id: partDel
@ -236,7 +258,7 @@ DataListView {
fontSizeMode: Text.Fit
font.bold: false
font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.4:height * 0.3 )
minimumPixelSize: height * 0.3
minimumPixelSize: height * 0.3 < 1 ? 1:height * 0.3
elide: "ElideRight"
@ -703,14 +725,15 @@ DataListView {
anchors.fill: parent
enabled: control.widgetData['discipline'] === 'speed'
enabled: false
flowchartData: control.widgetData
flowchartData: ({})
//participants: control.widgetData['participants'].slice()
//route_names: control.widgetData['route_names']
rounds: Object.keys(control.widgetData['route_names']).length > 2 ? control.widgetData['route_names']["2"].includes("8") ? 2:1 : 0
onEnabledChanged: {
if(!enabled){
speedFlowChartBackgroundRect.state = 'hidden'
}
}
}
states: [

View file

@ -410,6 +410,8 @@ Window {
height: parent.height
Layout.alignment: Layout.Right
onStatusChanged: {
//console.log("loader status changed: " + status)
@ -419,10 +421,9 @@ Window {
else {
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.width
widthChangedCon.target = extraComponentLoader.item
}
//console.log("set loader width to: " + extraComponentLoader.Layout.preferredWidth + " for a item width of: " + extraComponentLoader.item.implicitWidth)
}
@ -443,6 +444,14 @@ Window {
}
}
Connections {
id: widthChangedCon
onImplicitWidthChanged:{
extraComponentLoader.item.width = extraComponentLoader.item.implicitWidth
extraComponentLoader.Layout.preferredWidth = extraComponentLoader.item.implicitWidth
}
}
ParallelAnimation {
id: appearNa