finished the implementation of speed final flowcharts, everything seems to work fine
This commit is contained in:
parent
bd185ad28b
commit
bbcd468ec3
4 changed files with 144 additions and 39 deletions
|
@ -26,6 +26,7 @@ ListView {
|
||||||
property bool loading: false
|
property bool loading: false
|
||||||
property var listData
|
property var listData
|
||||||
property var emptyProperties: []
|
property var emptyProperties: []
|
||||||
|
property bool useBuiltInPullRefresher: true
|
||||||
|
|
||||||
signal refresh()
|
signal refresh()
|
||||||
|
|
||||||
|
@ -81,13 +82,17 @@ ListView {
|
||||||
PullRefresher {
|
PullRefresher {
|
||||||
target: control
|
target: control
|
||||||
|
|
||||||
|
visible: control.useBuiltInPullRefresher
|
||||||
|
|
||||||
postRefreshDelay: 0
|
postRefreshDelay: 0
|
||||||
|
|
||||||
busyIndicator: FancyBusyIndicator {}
|
busyIndicator: FancyBusyIndicator {}
|
||||||
refreshPosition: height * 1.3
|
refreshPosition: height * 1.3
|
||||||
|
|
||||||
onRefreshRequested: {
|
onRefreshRequested: {
|
||||||
|
if(control.useBuiltInPullRefresher) {
|
||||||
control.refresh()
|
control.refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ ListView {
|
||||||
property int rounds
|
property int rounds
|
||||||
property int tileSize: app.height / 8 * 0.8
|
property int tileSize: app.height / 8 * 0.8
|
||||||
|
|
||||||
|
property int refreshes: 0
|
||||||
|
property int roundRefreshes: 1
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 10
|
anchors.margins: 10
|
||||||
model: rounds + 2
|
model: rounds + 2
|
||||||
|
@ -24,18 +27,55 @@ ListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareData() {
|
function prepareData() {
|
||||||
|
if(!control.enabled)
|
||||||
|
return
|
||||||
|
/*refreshes += 1
|
||||||
|
|
||||||
|
if(refreshes > 2){
|
||||||
|
roundRefreshes += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("refreshes: " + refreshes + " rounds: " + roundRefreshes)
|
||||||
|
|
||||||
|
// create competition like data (just testing)
|
||||||
|
for(var part in flowchartData['participants']){
|
||||||
|
if(flowchartData['participants'].hasOwnProperty(part)){
|
||||||
|
|
||||||
|
for(var r = 2 + roundRefreshes; r < 7; r++){
|
||||||
|
delete flowchartData['participants'][part]["result"+r]
|
||||||
|
delete flowchartData['participants'][part]["result_rank"+r]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parseInt(flowchartData['participants'][part]["result_rank0"]) > 14 + refreshes) {
|
||||||
|
delete flowchartData['participants'][part]["result_rank2"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
delete flowchartData['route_names'][2]
|
||||||
|
delete flowchartData['route_names'][3]
|
||||||
|
delete flowchartData['route_names'][4]
|
||||||
|
delete flowchartData['route_names'][5]
|
||||||
|
delete flowchartData['route_names'][6]
|
||||||
|
*/
|
||||||
|
|
||||||
|
//flowchartData['route_names'] = flowchartData['route_names'].slice(0,)
|
||||||
|
|
||||||
// array to store the restructured data
|
// array to store the restructured data
|
||||||
var allData = []
|
var allData = []
|
||||||
|
|
||||||
for(var round in flowchartData['route_names']){
|
//console.log(JSON.stringify(flowchartData['route_names']))
|
||||||
if(flowchartData['route_names'].hasOwnProperty(round) && parseInt(round) >= 0){
|
|
||||||
console.log(round)
|
|
||||||
|
|
||||||
if(allData.length > 0){
|
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(round)
|
||||||
allData[allData.length-1].push(flowchartData['route_names'][round])
|
allData[allData.length-1].push(flowchartData['route_names'][round])
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if(parseInt(round) === 0){
|
if(parseInt(round) === 0){
|
||||||
// this is the first round
|
// this is the first round
|
||||||
|
@ -86,7 +126,8 @@ ListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
// push the first round to all data
|
// push the first round to all data
|
||||||
|
finalFirstRoundPairs.push(2)
|
||||||
|
finalFirstRoundPairs.push(flowchartData['route_names'][2])
|
||||||
allData.push(finalFirstRoundPairs)
|
allData.push(finalFirstRoundPairs)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -106,6 +147,10 @@ ListView {
|
||||||
var thisLooser
|
var thisLooser
|
||||||
var thisWinnerIsFirstOfNewPair = i%2 === 0
|
var thisWinnerIsFirstOfNewPair = i%2 === 0
|
||||||
|
|
||||||
|
if(thisPair[0] === undefined || thisPair[1] === undefined){
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if(thisWinnerIsFirstOfNewPair){
|
if(thisWinnerIsFirstOfNewPair){
|
||||||
nextRound.push([])
|
nextRound.push([])
|
||||||
}
|
}
|
||||||
|
@ -117,14 +162,18 @@ ListView {
|
||||||
thisWinner = thisPair[0]
|
thisWinner = thisPair[0]
|
||||||
thisLooser = thisPair[1]
|
thisLooser = thisPair[1]
|
||||||
}
|
}
|
||||||
else {
|
else if(parseInt(thisPair[0]["result_rank"+round]) > parseInt(thisPair[1]["result_rank"+round])) {
|
||||||
thisWinner = thisPair[1]
|
thisWinner = thisPair[1]
|
||||||
thisLooser = thisPair[0]
|
thisLooser = thisPair[0]
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// no result yet!!
|
||||||
|
thisPair[1]["win"] = thisPair[0]["win"] = false
|
||||||
|
//console.log("got no winner yet")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
console.log(thisWinner['firstname']+" has won in round " + round)
|
//console.log(thisWinner['firstname']+" has won in round " + round)
|
||||||
//thisWinner.win = false
|
|
||||||
//thisLooser.win = true
|
|
||||||
|
|
||||||
if(round - control.rounds === 2){
|
if(round - control.rounds === 2){
|
||||||
// if we are in the 1/2 final
|
// if we are in the 1/2 final
|
||||||
|
@ -144,24 +193,30 @@ ListView {
|
||||||
// small Final
|
// small Final
|
||||||
allData.push([smallFinal, parseInt(round)+1])
|
allData.push([smallFinal, parseInt(round)+1])
|
||||||
|
|
||||||
break
|
//break
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//nextRound.push(round)
|
nextRound.push(parseInt(round) + 1 )
|
||||||
//nextRound.push(flowchartData['route_names'][round])
|
nextRound.push(flowchartData['route_names'][parseInt(round) + 1])
|
||||||
allData.push(nextRound)
|
allData.push(nextRound)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
control.allFlowchartData = allData
|
control.allFlowchartData = allData
|
||||||
|
//console.log(JSON.stringify(allData))
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWinner(part1, part2){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: Column {
|
delegate: Column {
|
||||||
id: roundCol
|
id: roundCol
|
||||||
|
|
||||||
property int thisIndex: index
|
property int thisIndex: index
|
||||||
property int thisRound: control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-2]
|
property int thisRound: thisRoundIsValid ? control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-2]:-1
|
||||||
|
property bool thisRoundIsValid: control.allFlowchartData !== undefined && control.allFlowchartData[roundCol.thisIndex] !== undefined && control.allFlowchartData[roundCol.thisIndex].length > 2
|
||||||
property bool thisIsLastRound: thisIndex === control.model - 1
|
property bool thisIsLastRound: thisIndex === control.model - 1
|
||||||
|
|
||||||
width: app.width * 0.5
|
width: app.width * 0.5
|
||||||
|
@ -172,9 +227,13 @@ ListView {
|
||||||
Label {
|
Label {
|
||||||
id: roundNameLa
|
id: roundNameLa
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
height: control.height * 0.05
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
fontSizeMode: Text.Fit
|
||||||
|
font.pixelSize: height * 0.6
|
||||||
font.bold: true
|
font.bold: true
|
||||||
text: control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-1]
|
text: roundCol.thisRoundIsValid && control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-1] !== undefined ? control.allFlowchartData[roundCol.thisIndex][control.allFlowchartData[roundCol.thisIndex].length-1] : "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -185,18 +244,19 @@ ListView {
|
||||||
|
|
||||||
property bool lowerPart: (index%2 > 0)
|
property bool lowerPart: (index%2 > 0)
|
||||||
|
|
||||||
property int thisIndex: index
|
property var matchData: roundCol.thisRoundIsValid ? control.allFlowchartData[ thisIsSmallFinal ? roundCol.thisIndex+1 : roundCol.thisIndex][ thisIsSmallFinal ? 0:matchItm.thisIndex]:undefined
|
||||||
property var thisMatchData: control.allFlowchartData[ thisIsSemifinal ? roundCol.thisIndex+1 : roundCol.thisIndex][matchItm.thisIndex]
|
|
||||||
property bool thisIsFinal: roundCol.thisIsLastRound && thisIndex === rectRep.model - 2
|
|
||||||
property bool thisIsSemifinal: roundCol.thisIsLastRound && thisIndex === rectRep.model - 1
|
|
||||||
|
|
||||||
Component.onCompleted: {
|
property int thisIndex: index
|
||||||
if(thisIsSemifinal){
|
property int thisRound: parseInt(roundCol.thisRound) - (thisIsSmallFinal ? 1:0)
|
||||||
console.log("this is semi final")
|
property var thisMatchData: thisMatchDataIsValid ? matchData:[]
|
||||||
console.log(thisMatchData)
|
|
||||||
}
|
property bool thisMatchDataIsValid: (matchData !== undefined && matchData !== null && typeof matchData === "object" && matchData.length > 0)
|
||||||
console.log(thisMatchData)
|
property bool thisMatchIsOver: thisMatchDataIsValid && thisMatchData[0]['result_rank'+thisRound] !== undefined && thisMatchData[1]['result_rank'+thisRound] !== undefined
|
||||||
}
|
|
||||||
|
property bool thisIsFinal: roundCol.thisIsLastRound && thisIndex === rectRep.model - 2
|
||||||
|
property bool thisIsSmallFinal: roundCol.thisIsLastRound && thisIndex === rectRep.model - 1
|
||||||
|
|
||||||
|
property int winnerIndex: thisMatchIsOver ? (parseInt(thisMatchData[0]['result_rank'+thisRound]) < parseInt(thisMatchData[1]['result_rank'+thisRound]) ? 0:1) : -1
|
||||||
|
|
||||||
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 )
|
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
|
width: parent.width
|
||||||
|
@ -255,6 +315,7 @@ ListView {
|
||||||
model: 2
|
model: 2
|
||||||
|
|
||||||
delegate: Row {
|
delegate: Row {
|
||||||
|
|
||||||
height: app.landscape() ? parent.height:parent.height / 2
|
height: app.landscape() ? parent.height:parent.height / 2
|
||||||
width: app.landscape() ? parent.width / 2 : parent.width
|
width: app.landscape() ? parent.width / 2 : parent.width
|
||||||
|
|
||||||
|
@ -262,28 +323,29 @@ ListView {
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width * 0.2
|
width: parent.width * (app.landscape() ? 0.1 : 0.2)
|
||||||
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
font.pixelSize: height * 0.6
|
font.pixelSize: height * 0.6
|
||||||
fontSizeMode: Text.Fit
|
fontSizeMode: Text.Fit
|
||||||
minimumPixelSize: 1
|
minimumPixelSize: 1
|
||||||
|
|
||||||
text: matchItm.thisMatchData[index]['result_rank0']
|
text: matchItm.thisMatchData[index] !== undefined ? matchItm.thisMatchData[index]['result_rank0']: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: parent.width * 0.5
|
width: parent.width * 0.6
|
||||||
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: app.landscape() ? Text.AlignLeft : Text.AlignHCenter
|
||||||
font.pixelSize: height * 0.6
|
font.pixelSize: height * 0.6
|
||||||
fontSizeMode: Text.Fit
|
fontSizeMode: Text.Fit
|
||||||
minimumPixelSize: 1
|
minimumPixelSize: 1
|
||||||
|
|
||||||
color: (parseInt(matchItm.thisMatchData[0]["result_rank" + roundCol.thisRound ]) < parseInt(matchItm.thisMatchData[1]["result_rank" + roundCol.thisRound])) === (index === 0 ? true:false) ? "green":"black"
|
color: matchItm.winnerIndex === index ? "green":"black"
|
||||||
|
|
||||||
text: matchItm.thisMatchData[index]['firstname'] + " " + matchItm.thisMatchData[index]['lastname']
|
text: matchItm.thisMatchData[index] !== undefined ? matchItm.thisMatchData[index]['firstname'] + " " + matchItm.thisMatchData[index]['lastname'] :"-"
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Rectangle {
|
/*Rectangle {
|
||||||
|
@ -302,7 +364,6 @@ ListView {
|
||||||
|
|
||||||
visible: (parseInt(matchItm.thisMatchData[0]["result_rank" + roundCol.thisRound ]) < parseInt(matchItm.thisMatchData[1]["result_rank" + roundCol.thisRound])) === (index === 0 ? true:false)
|
visible: (parseInt(matchItm.thisMatchData[0]["result_rank" + roundCol.thisRound ]) < parseInt(matchItm.thisMatchData[1]["result_rank" + roundCol.thisRound])) === (index === 0 ? true:false)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,9 @@ DataListView {
|
||||||
ToolButton {
|
ToolButton {
|
||||||
id: flowToolBt
|
id: flowToolBt
|
||||||
|
|
||||||
visible: control.widgetData['discipline'] === 'speed'
|
visible: speedFlowChart.enabled
|
||||||
|
|
||||||
|
enabled: control.widgetData['route_order'] === "-1" && Object.keys(control.widgetData['route_names']).length > 2
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if(speedFlowChartBackgroundRect.state === "hidden"){
|
if(speedFlowChartBackgroundRect.state === "hidden"){
|
||||||
|
@ -154,6 +156,8 @@ DataListView {
|
||||||
property int ind: index
|
property int ind: index
|
||||||
property var thisData: widgetData[ "participants" ][partDel.ind]
|
property var thisData: widgetData[ "participants" ][partDel.ind]
|
||||||
|
|
||||||
|
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 70
|
height: 70
|
||||||
|
|
||||||
|
@ -250,13 +254,15 @@ DataListView {
|
||||||
id: partDelSecondRow
|
id: partDelSecondRow
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: multiResRow.enabled || multiGenResRow.enabled || resultLa.enabled ? parent.height / 2 : 0
|
height: multiResRow.active || multiGenResRow.active || resultLa.acitve ? parent.height / 2 : 0
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
id: multiResRow
|
id: multiResRow
|
||||||
|
|
||||||
|
property bool active: parseInt(widgetData[ "route_order" ]) > -1 && boulderResRep.model > 0
|
||||||
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: enabled ? parent.width * 0.75:0
|
width: active ? parent.width * 0.75:0
|
||||||
|
|
||||||
enabled: parseInt(widgetData[ "route_order" ]) > -1 && boulderResRep.model > 0
|
enabled: parseInt(widgetData[ "route_order" ]) > -1 && boulderResRep.model > 0
|
||||||
|
|
||||||
|
@ -464,8 +470,10 @@ DataListView {
|
||||||
Row {
|
Row {
|
||||||
id: multiGenResRow
|
id: multiGenResRow
|
||||||
|
|
||||||
|
property bool active: ((parseInt(widgetData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false
|
||||||
|
|
||||||
height: parent.height
|
height: parent.height
|
||||||
width: enabled ? parent.width - resultLa.width:0
|
width: active ? parent.width - resultLa.width:0
|
||||||
|
|
||||||
enabled: ((parseInt(widgetData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false
|
enabled: ((parseInt(widgetData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false
|
||||||
|
|
||||||
|
@ -554,6 +562,8 @@ DataListView {
|
||||||
Label {
|
Label {
|
||||||
id: resultLa
|
id: resultLa
|
||||||
|
|
||||||
|
property bool acitve: ( boulderResRep.model > 0 || widgetData["discipline"] !== "boulder" ) && parseInt(widgetData[ "route_order" ]) > -1
|
||||||
|
|
||||||
width: enabled ? parent.width * 0.25:0
|
width: enabled ? parent.width * 0.25:0
|
||||||
height: enabled ? parent.height:0
|
height: enabled ? parent.height:0
|
||||||
|
|
||||||
|
@ -591,6 +601,8 @@ DataListView {
|
||||||
property var tabs: getTabs()
|
property var tabs: getTabs()
|
||||||
property var tabIndexes: []
|
property var tabIndexes: []
|
||||||
|
|
||||||
|
enabled: speedFlowChartBackgroundRect.state === "hidden"
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
right: parent.right
|
right: parent.right
|
||||||
|
@ -678,14 +690,18 @@ DataListView {
|
||||||
color: Material.background
|
color: Material.background
|
||||||
|
|
||||||
SpeedFlowChart {
|
SpeedFlowChart {
|
||||||
|
id: speedFlowChart
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
flowchartData: control.widgetData;
|
enabled: control.widgetData['discipline'] === 'speed'
|
||||||
|
|
||||||
|
flowchartData: control.widgetData
|
||||||
|
|
||||||
//participants: control.widgetData['participants'].slice()
|
//participants: control.widgetData['participants'].slice()
|
||||||
//route_names: control.widgetData['route_names']
|
//route_names: control.widgetData['route_names']
|
||||||
|
|
||||||
rounds: control.widgetData['route_names'][2].includes("8") ? 2:1
|
rounds: Object.keys(control.widgetData['route_names']).length > 2 ? control.widgetData['route_names']["2"].includes("8") ? 2:1 : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
states: [
|
states: [
|
||||||
|
@ -719,4 +735,18 @@ DataListView {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PullRefresher {
|
||||||
|
target: control
|
||||||
|
|
||||||
|
postRefreshDelay: 0
|
||||||
|
|
||||||
|
busyIndicator: FancyBusyIndicator {}
|
||||||
|
refreshPosition: height * 1.3
|
||||||
|
|
||||||
|
onRefreshRequested: {
|
||||||
|
control.refresh()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,6 +579,15 @@ Window {
|
||||||
loadingDl.close()
|
loadingDl.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function defaultString(string, defaultString){
|
||||||
|
if(string === undefined || string === null){
|
||||||
|
return defaultString
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getErrorInfo(errorCode) {
|
function getErrorInfo(errorCode) {
|
||||||
|
|
||||||
var infoLevel
|
var infoLevel
|
||||||
|
|
Loading…
Reference in a new issue