added year selector
This commit is contained in:
parent
9dbad425df
commit
5faa8c0617
7 changed files with 210 additions and 108 deletions
|
@ -26,7 +26,7 @@ signals:
|
|||
public slots:
|
||||
void refreshFoodplan();
|
||||
|
||||
QVariant getCalendar(QString nation);
|
||||
QVariant getCalendar(QString nation, int year);
|
||||
QVariant getRanking(int competitionId, int categoryId, bool registrationData = false, const int routeNumber = -2);
|
||||
|
||||
// functions for qml
|
||||
|
|
|
@ -134,31 +134,7 @@ DataListView {
|
|||
|
||||
width: parent.width / ( boulderResRep.model )
|
||||
height: parent.height
|
||||
/*
|
||||
Rectangle {
|
||||
anchors {
|
||||
left: parent.left
|
||||
}
|
||||
|
||||
width: 1
|
||||
height: parent.height
|
||||
|
||||
visible: index === 0
|
||||
|
||||
color: "grey"
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors {
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
width: 1
|
||||
height: parent.height
|
||||
|
||||
color: "grey"
|
||||
}
|
||||
*/
|
||||
Canvas {
|
||||
id: boulderResCv
|
||||
|
||||
|
@ -166,7 +142,7 @@ DataListView {
|
|||
|
||||
anchors.centerIn: parent
|
||||
|
||||
height: parent.height * 1.1
|
||||
height: parent.height > parent.width ? parent.width * 0.9:parent.height * 0.9
|
||||
width: height
|
||||
|
||||
onPaint: {
|
||||
|
|
|
@ -9,26 +9,87 @@ Page {
|
|||
|
||||
title: "calendar"
|
||||
|
||||
property string nation: ""
|
||||
property int status: -1
|
||||
property Component headerComponent: Item {
|
||||
anchors.fill: parent
|
||||
|
||||
Row {
|
||||
anchors.fill: parent
|
||||
|
||||
spacing: width * 0.05
|
||||
|
||||
Label {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
width: parent.width - toolButton.width - parent.spacing
|
||||
height: parent.height * 0.6
|
||||
|
||||
fontSizeMode: Text.Fit
|
||||
font.pixelSize: height
|
||||
minimumPixelSize: 0
|
||||
|
||||
text: root.year
|
||||
|
||||
Component.onCompleted: {
|
||||
loadData(root.nation)
|
||||
}
|
||||
|
||||
function loadData(nation) {
|
||||
Button {
|
||||
id:toolButton
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
height: parent.height * 0.5
|
||||
width: height
|
||||
|
||||
onClicked: {
|
||||
yearSelectPu.open()
|
||||
}
|
||||
|
||||
onPressed: toolButton.scale = 0.9
|
||||
onReleased: toolButton.scale = 1.0
|
||||
|
||||
background: Image {
|
||||
source: "qrc:/icons/calendar.png"
|
||||
|
||||
height: parent.height
|
||||
width: height
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
Behavior on scale {
|
||||
PropertyAnimation {
|
||||
duration: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
property string nation: ""
|
||||
property int year: new Date().getFullYear()
|
||||
property int status: -1
|
||||
property var calendarData
|
||||
|
||||
Component.onCompleted: {
|
||||
loadData(root.nation, root.year)
|
||||
}
|
||||
|
||||
function loadData(nation, year) {
|
||||
root.status = 905
|
||||
loadingDl.open()
|
||||
|
||||
var ret = serverConn.getCalendar(nation)
|
||||
var ret = serverConn.getCalendar(nation, year)
|
||||
|
||||
if(ret["status"] === 200){
|
||||
root.status = 200
|
||||
root.calendarData = ret["data"]
|
||||
calendarList.listData = ret["data"]["competitions"]
|
||||
}
|
||||
else {
|
||||
root.status = ret["status"]
|
||||
root.status = parseInt(ret["status"])
|
||||
calendarList.listData = {}
|
||||
root.calendarData = {}
|
||||
}
|
||||
loadingDl.close()
|
||||
}
|
||||
|
@ -47,7 +108,7 @@ Page {
|
|||
status: root.status
|
||||
|
||||
onRefresh: {
|
||||
root.loadData(root.nation)
|
||||
root.loadData(root.nation, root.year)
|
||||
}
|
||||
|
||||
delegate: ItemDelegate {
|
||||
|
@ -179,4 +240,47 @@ Page {
|
|||
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: yearSelectPu
|
||||
|
||||
property var yearList: root.calendarData["years"]
|
||||
|
||||
x: root.width / 2 - width / 2
|
||||
y: root.height / 2 - height / 2
|
||||
|
||||
width: root.width * 0.8
|
||||
height: root.height * 0.6
|
||||
|
||||
modal: true
|
||||
focus: true
|
||||
|
||||
title: qsTr("select year")
|
||||
|
||||
contentItem: ListView {
|
||||
id: yearsLv
|
||||
|
||||
width: parent.width
|
||||
height: root.height * 0.6
|
||||
|
||||
model: yearSelectPu.yearList.length
|
||||
|
||||
delegate: Button {
|
||||
id: yearBt
|
||||
|
||||
width: parent.width
|
||||
|
||||
flat: true
|
||||
|
||||
text: yearSelectPu.yearList[index]
|
||||
|
||||
onClicked: {
|
||||
yearSelectPu.close()
|
||||
root.year = yearSelectPu.yearList[index]
|
||||
root.loadData(root.nation, root.year)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,15 +112,26 @@ Window {
|
|||
|
||||
height: 50
|
||||
|
||||
Row {
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
spacing: width * 0.02
|
||||
|
||||
Item {
|
||||
id: spacer
|
||||
width: 1
|
||||
height: parent.height
|
||||
}
|
||||
|
||||
Button {
|
||||
id:toolButton
|
||||
enabled: true
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
verticalCenter: parent.verticalCenter
|
||||
leftMargin: parent.width *0.02
|
||||
}
|
||||
height: parent.height - parent.height * 0.5
|
||||
|
||||
height: parent.height * 0.5
|
||||
width: height
|
||||
|
||||
onClicked: {
|
||||
|
@ -134,8 +145,10 @@ Window {
|
|||
|
||||
background: Image {
|
||||
source: "qrc:/icons/backDark.png"
|
||||
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
width: height
|
||||
|
||||
fillMode: Image.PreserveAspectFit
|
||||
Behavior on scale {
|
||||
PropertyAnimation {
|
||||
|
@ -145,18 +158,16 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
height: childrenRect.height
|
||||
width: parent.width * 0.7
|
||||
|
||||
Label {
|
||||
id: toolBarTitleLa
|
||||
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
verticalCenterOffset: -toolBarSubTitleLa.anchors.verticalCenterOffset
|
||||
left: toolButton.right
|
||||
leftMargin: parent.width * 0.02
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
elide: "ElideRight"
|
||||
|
||||
font.bold: true
|
||||
|
@ -188,14 +199,6 @@ Window {
|
|||
Label {
|
||||
id: toolBarSubTitleLa
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
verticalCenterOffset: toolBarSubTitleLa.text !== "" ? height/2:0
|
||||
left: toolButton.right
|
||||
leftMargin: parent.width * 0.02
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
elide: "ElideRight"
|
||||
|
||||
font.bold: false
|
||||
|
@ -215,6 +218,24 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: extraComponentLoader
|
||||
|
||||
height: parent.height
|
||||
width: parent.width * 0.2 - toolButton.width
|
||||
|
||||
anchors {
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
}
|
||||
|
||||
sourceComponent: mainStack.currentItem.headerComponent
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Behavior on anchors.topMargin {
|
||||
NumberAnimation {
|
||||
duration: 500
|
||||
|
|
BIN
resources/shared/icons/calendar.png
Normal file
BIN
resources/shared/icons/calendar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -5,5 +5,6 @@
|
|||
<file>icons/sac.png</file>
|
||||
<file>icons/back.png</file>
|
||||
<file>icons/backDark.png</file>
|
||||
<file>icons/calendar.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -23,8 +23,8 @@ void ServerConn::refreshFoodplan() {
|
|||
emit this->foodplanChanged();
|
||||
}
|
||||
|
||||
QVariant ServerConn::getCalendar(QString nation){
|
||||
QVariantMap ret = this->senddata(QUrl("http://egw.ifsc-climbing.org/egw/ranking/json.php?year=2019&nation=" + nation));
|
||||
QVariant ServerConn::getCalendar(QString nation, int year){
|
||||
QVariantMap ret = this->senddata(QUrl("http://egw.ifsc-climbing.org/egw/ranking/json.php?year=" + QString::number(year) + "&nation=" + nation));
|
||||
|
||||
if(ret["status"] != 200){
|
||||
// request was a failure
|
||||
|
|
Loading…
Reference in a new issue