added rectangles like on dr website for boulder ranking

This commit is contained in:
Dorian Zedler 2019-04-21 12:35:11 +02:00
parent ec4f8a1de5
commit 9dbad425df
7 changed files with 230 additions and 42 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2019-04-20T22:54:55. --> <!-- Written by QtCreator 4.8.2, 2019-04-21T12:34:34. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -8,7 +8,7 @@
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value> <value type="int">1</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.EditorSettings</variable> <variable>ProjectExplorer.Project.EditorSettings</variable>
@ -69,7 +69,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/builds/build-DigitalRockRanking-Android_for_armeabi_v7a_Clang_Qt_5_11_3_for_Android_ARMv7-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/Documents/git/builds/build-DigitalRockRanking-Android_for_armeabi_v7a_Clang_Qt_5_11_3_for_Android_ARMv7-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -355,8 +355,8 @@
<value type="int" key="PE.EnvironmentAspect.Base">0</value> <value type="int" key="PE.EnvironmentAspect.Base">0</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DigitalRockRanking</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DigitalRockRanking</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DigitalRockRanking</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/DigitalRockRanking/DigitalRockRanking.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/Documents/git/digital-rock-ranking/DigitalRockRanking.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value> <value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
@ -378,7 +378,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/builds/build-DigitalRockRanking-Desktop_Qt_5_11_3_GCC_64bit-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/dorian/Documents/git/builds/build-DigitalRockRanking-Desktop_Qt_5_11_3_GCC_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -603,8 +603,8 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DigitalRockRanking</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">DigitalRockRanking</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">DigitalRockRanking2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/DigitalRockRanking/DigitalRockRanking.pro</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/git/digital-rock-ranking/DigitalRockRanking.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DigitalRockRanking.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DigitalRockRanking.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value> <value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
@ -615,7 +615,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value> <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value> <value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/dorian/builds/build-DigitalRockRanking-Desktop_Qt_5_11_3_GCC_64bit-Debug</value> <value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/dorian/Documents/git/builds/build-DigitalRockRanking-Desktop_Qt_5_11_3_GCC_64bit-Debug</value>
</valuemap> </valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value> <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap> </valuemap>

View file

@ -11,6 +11,11 @@ ListView {
anchors.margins: 10 anchors.margins: 10
anchors.rightMargin: 14 anchors.rightMargin: 14
enabled: status === 200
opacity: enabled ? 1:0
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {
parent: control.parent parent: control.parent
@ -24,15 +29,30 @@ ListView {
width: 8 width: 8
visible: control.model > 0
active: true active: true
} }
onContentYChanged: { onContentYChanged: {
if(contentY < -125){ if(contentY < -control.height * 0.3 && control.status !== 905){
contentY = 0
control.refresh() control.refresh()
} }
} }
Behavior on opacity {
NumberAnimation {
duration: 200
}
}
Behavior on contentY {
NumberAnimation {
duration: 200
}
}
InfoArea { InfoArea {
id: infoArea id: infoArea
@ -44,7 +64,7 @@ ListView {
topMargin: control.height*( status === 901 ? 0.6:0.5) - height * 0.8 topMargin: control.height*( status === 901 ? 0.6:0.5) - height * 0.8
} }
excludedCodes: [200, 902] excludedCodes: [200, 902, 905]
errorCode: control.status errorCode: control.status
} }
} }

View file

@ -108,6 +108,25 @@ DataListView {
model: parseInt(listData[ "route_num_problems" ]) model: parseInt(listData[ "route_num_problems" ])
function getDataForIcon(index){
var resultString = listData[ "participants" ][partDel.ind]["boulder"+(index+1)]
var resultList = []
if( resultString !== undefined){
resultString = resultString.replace("t", "")
resultString = resultString.replace("z", "")
resultList = resultString.split(" ")
}
while (resultList.length < 2){
resultList.unshift(0)
}
return resultList
}
delegate: Item { delegate: Item {
id: boulderResItm id: boulderResItm
@ -115,7 +134,7 @@ DataListView {
width: parent.width / ( boulderResRep.model ) width: parent.width / ( boulderResRep.model )
height: parent.height height: parent.height
/*
Rectangle { Rectangle {
anchors { anchors {
left: parent.left left: parent.left
@ -139,20 +158,161 @@ DataListView {
color: "grey" color: "grey"
} }
*/
Canvas {
id: boulderResCv
property var resultData: boulderResRep.getDataForIcon(index)
Label {
anchors.centerIn: parent anchors.centerIn: parent
height: parent.height height: parent.height * 1.1
width: parent.width * 0.9 width: height
fontSizeMode: Text.Fit onPaint: {
font.pixelSize: Math.abs( height * 0.6 ) var width = boulderResCv.width * 0.9
minimumPixelSize: 0 var height = boulderResCv.height * 0.9
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: listData[ "participants" ][partDel.ind]["boulder"+(index+1)] === undefined ? "":listData[ "participants" ][partDel.ind]["boulder"+(index+1)] var radius = width * 0.3
var offsetX = width * 0.05
var offsetY = height * 0.05
var context = getContext("2d");
context.beginPath();
context.moveTo(0 + offsetX + radius, 0 + offsetY);
// top line
context.lineTo(width - radius + offsetX, 0 + offsetY);
// top right corner
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.5 * Math.PI, 0);
// right line
context.lineTo(width + offsetX, height - radius + offsetY);
// bottom right corner
context.arc(width-radius + offsetX, height - radius + offsetY, radius, 0, 0.5 * Math.PI);
// bottom line
context.lineTo(0 + radius + offsetX, height + offsetY);
// bottom left corner
context.arc(radius + offsetY, height - radius + offsetY, radius, 0.5 * Math.PI, Math.PI);
// left line
context.lineTo(0 + offsetX, radius + offsetY);
// top left corner
context.arc(radius + offsetX, radius + offsetY, radius, Math.PI, 1.5 * Math.PI);
// fill
context.fillStyle = "#b7b7b7";
context.fill();
// outline
context.lineWidth = 1;
context.strokeStyle = '#424242';
context.stroke();
if(resultData[1] > 0){
// the first triangle
context.beginPath();
// top right corner
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.75 * Math.PI, 0);
// right line
context.lineTo(width + offsetX, height - radius + offsetY);
// bottom right corner
context.arc(width-radius + offsetX, height - radius + offsetY, radius, 0, 0.5 * Math.PI);
// bottom line
context.lineTo(0 + radius + offsetX, height + offsetY);
// bottom left corner
context.arc(radius + offsetX, height - radius + offsetY, radius, 0.5 * Math.PI, 0.75 * Math.PI);
context.closePath();
context.fillStyle = "#44ed38";
context.fill();
// outline
context.lineWidth = 1;
context.strokeStyle = '#424242';
context.stroke();
if(resultData[0] > 0){
// the second triangle
context.beginPath();
// bottom left corner
context.arc(radius + offsetX, height - radius + offsetY, radius, 0.75 * Math.PI, 1 * Math.PI);
// left line
context.lineTo(0 + offsetX, radius + offsetY);
// top left corner
context.arc(radius + offsetX, radius + offsetY, radius, Math.PI, 1.5 * Math.PI);
// top line
context.lineTo(width - radius + offsetX, 0 + offsetY);
// top right corner
context.arc(width-radius + offsetX, radius + offsetY, radius, 1.5 * Math.PI, 1.75 * Math.PI);
context.closePath();
context.fillStyle = "#44ed38";
context.fill();
// outline
context.lineWidth = 1;
context.strokeStyle = '#424242';
context.stroke();
}
}
}
Label {
id: boulderResZoneLa
anchors {
right: parent.right
bottom: parent.bottom
margins: boulderResCv.height * 0.05
}
height: parent.height / 2
width: parent.width / 2
visible: text !== "0"
fontSizeMode: Text.Fit
font.pixelSize: height
minimumPixelSize: 0
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: boulderResCv.resultData[1]
}
Label {
id: boulderResTopLa
anchors {
left: parent.left
top: parent.top
margins: boulderResCv.height * 0.05
}
height: parent.height / 2
width: parent.width / 2
visible: text !== "0"
fontSizeMode: Text.Fit
font.pixelSize: height
minimumPixelSize: 0
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
text: boulderResCv.resultData[0]
}
} }
} }

View file

@ -13,6 +13,13 @@ Page {
property int status: -1 property int status: -1
Component.onCompleted: { Component.onCompleted: {
loadData(root.nation)
}
function loadData(nation) {
root.status = 905
loadingDl.open()
var ret = serverConn.getCalendar(nation) var ret = serverConn.getCalendar(nation)
if(ret["status"] === 200){ if(ret["status"] === 200){
@ -23,34 +30,26 @@ Page {
root.status = ret["status"] root.status = ret["status"]
calendarList.listData = {} calendarList.listData = {}
} }
loadingDl.close()
} }
InfoArea { DataListView {
id: infoArea
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
}
excludedCodes: [200, 902]
errorCode: root.status
}
ListView {
id: calendarList id: calendarList
property var listData property var listData
anchors.fill: parent anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds //boundsBehavior: Flickable.StopAtBounds
model: listData.length model: listData.length
status: root.status
onRefresh: {
root.loadData(root.nation)
}
delegate: ItemDelegate { delegate: ItemDelegate {
id: competitionDel id: competitionDel

View file

@ -30,6 +30,7 @@ Page {
} }
function loadData(comp, cat, reg, route){ function loadData(comp, cat, reg, route){
root.status = 905
loadingDl.open() loadingDl.open()
console.log("[info][QML] getting ranking data of comp: " + comp + " and cat: " + cat + " reg: " + reg) console.log("[info][QML] getting ranking data of comp: " + comp + " and cat: " + cat + " reg: " + reg)
var ret = serverConn.getRanking(comp, cat, reg, route) var ret = serverConn.getRanking(comp, cat, reg, route)
@ -63,7 +64,7 @@ Page {
} }
if(ret["data"][ root.listKey ] === undefined || ret["data"][ root.listKey ].length < 1){ if((ret["data"][ root.listKey ] === undefined || ret["data"][ root.listKey ].length < 1) && ( root.status === 200 || root.status === 404 ) ){
root.status = 901 root.status = 901
} }
@ -109,6 +110,9 @@ Page {
listData: root.reg ? root.rankingData:({}) listData: root.reg ? root.rankingData:({})
onRefresh: {
root.loadData(root.comId, root.catId, root.reg, root.routeNumber)
}
} }
} }
@ -136,8 +140,8 @@ Page {
listData: root.reg ? ({}):root.rankingData listData: root.reg ? ({}):root.rankingData
onListDataChanged: { onRefresh: {
console.log("list data changed") root.loadData(root.comId, root.catId, root.reg, root.routeNumber)
} }
} }

View file

@ -339,6 +339,11 @@ Window {
errorString = "Incompatible API" errorString = "Incompatible API"
errorDescription = "Please make shure that you are using the latest version of this app and try again." errorDescription = "Please make shure that you are using the latest version of this app and try again."
break break
case 905:
infoLevel = 1
errorString = "Loading..."
errorDescription = "Please wait while we're loading some data"
break
default: default:
infoLevel = 2 infoLevel = 2
errorString = "Unexpected error ("+errorCode+")" errorString = "Unexpected error ("+errorCode+")"

View file

@ -24,7 +24,7 @@ void ServerConn::refreshFoodplan() {
} }
QVariant ServerConn::getCalendar(QString nation){ QVariant ServerConn::getCalendar(QString nation){
QVariantMap ret = this->senddata(QUrl("http://egw.ifsc-climbing.org/egw/ranking/json.php?year=2018&nation=" + nation)); QVariantMap ret = this->senddata(QUrl("http://egw.ifsc-climbing.org/egw/ranking/json.php?year=2019&nation=" + nation));
if(ret["status"] != 200){ if(ret["status"] != 200){
// request was a failure // request was a failure