2020-10-31 15:16:06 +01: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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
//import QtGraphicalEffects 1.0
|
|
|
|
//import QtQuick.Templates 2.04 as T
|
|
|
|
//import QtQuick.Controls.impl 2.04
|
|
|
|
import QtQuick.Controls.Material 2.3
|
|
|
|
import de.itsblue.blueRock 2.0
|
|
|
|
|
|
|
|
import "../Components"
|
|
|
|
|
|
|
|
Page {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property BRWidget data
|
|
|
|
property Component headerComponent
|
2020-11-03 15:56:43 +01:00
|
|
|
property alias selector: selectorPu
|
2020-10-31 15:16:06 +01:00
|
|
|
|
|
|
|
property string subTitle
|
|
|
|
property bool titleIsPageTitle: true
|
|
|
|
|
|
|
|
property int status: -1
|
|
|
|
property bool ready: false
|
|
|
|
|
2020-11-03 15:56:43 +01:00
|
|
|
signal loadingFinished()
|
|
|
|
signal selectionFinished(int index, var data)
|
|
|
|
|
2020-10-31 15:16:06 +01:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
2020-11-03 15:56:43 +01:00
|
|
|
var status = data.load()
|
|
|
|
if(status !== BRWidget.Success)
|
|
|
|
ready = false
|
|
|
|
else
|
|
|
|
ready = true
|
|
|
|
loadingFinished()
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadData(params) {
|
|
|
|
// params is an object and can contain: {
|
|
|
|
// comp: competitionId,
|
|
|
|
// person: personId,
|
|
|
|
// cat: categoryId,
|
|
|
|
// nation: nationString ('', 'GER', 'SUI')
|
|
|
|
// route: (int) round
|
|
|
|
// type: ('','starters', 'nat_team_ranking', 'sektionenwertung', 'regionalzentren'),
|
|
|
|
//}
|
|
|
|
|
|
|
|
var ret = serverConn.getWidgetData(params)
|
|
|
|
|
|
|
|
root.status = ret["status"]
|
|
|
|
|
|
|
|
if(ret["status"] === 200){
|
|
|
|
root.widgetData = ret["data"]
|
|
|
|
root.widgetType = checkWidgetType(params, root.widgetData)
|
|
|
|
if(widgetLd.load()){
|
|
|
|
root.ready = true
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//root.status = 901
|
|
|
|
root.ready = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(ret["status"] === 404 && [WidgetPage.WidgetType.Registration, WidgetPage.WidgetType.Startlist, WidgetPage.WidgetType.Result].includes(root.widgetType) && root.params["route"] !== "") {
|
|
|
|
// if we get a 404 and have startlist, results or registration, the route was not found -> remove route and try again
|
|
|
|
root.params["route"] = ""
|
|
|
|
loadData(root.params)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
root.ready = false
|
|
|
|
}
|
|
|
|
|
|
|
|
app.errorCode = root.status
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: selectorPu
|
|
|
|
|
|
|
|
property var dataObj
|
|
|
|
property string subTitle: ""
|
|
|
|
|
|
|
|
x: 0 //root.width / 2 - width / 2
|
|
|
|
y: root.height - selectorPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
|
|
|
|
|
|
|
opacity: 0
|
|
|
|
|
|
|
|
width: root.width
|
|
|
|
height: selectorLv.implicitHeight
|
|
|
|
|
|
|
|
modal: true
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
title: ""
|
|
|
|
|
|
|
|
header: Column {
|
|
|
|
id: selectorPuHeaderCol
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: headerLa
|
|
|
|
|
|
|
|
visible: selectorPu.title
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
padding: 24
|
|
|
|
bottomPadding: 0
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 16
|
|
|
|
background: Rectangle {
|
|
|
|
radius: 2
|
|
|
|
color: selectorPu.Material.dialogColor
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
text: selectorPu.title
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: headerSubLa
|
|
|
|
|
|
|
|
visible: selectorPu.subTitle
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
padding: 24
|
|
|
|
topPadding: 5
|
|
|
|
bottomPadding: 0
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 16
|
|
|
|
background: Rectangle {
|
|
|
|
radius: 2
|
|
|
|
color: selectorPu.Material.dialogColor
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
text: selectorPu.subTitle
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function appear(dataObj, title, subTitle) {
|
|
|
|
if(dataObj.length > 0){
|
|
|
|
selectorPu.dataObj = dataObj
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
selectorPu.dataObj = undefined
|
|
|
|
}
|
|
|
|
selectorPu.title = title
|
|
|
|
selectorPu.subTitle = subTitle === undefined ? "":subTitle
|
|
|
|
selectorPu.open()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: selectorLv
|
|
|
|
|
|
|
|
property int delegateHeight: 50
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
implicitWidth: parent.width
|
|
|
|
implicitHeight: root.height * 0.7 < ( (delegateHeight + spacing) * model ) ? root.height * 0.7 : (delegateHeight + spacing) * model + 100
|
|
|
|
|
|
|
|
model: selectorPu.dataObj !== undefined ? selectorPu.dataObj.length:0
|
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator {
|
|
|
|
parent: selectorLv.parent
|
|
|
|
anchors {
|
|
|
|
top: selectorLv.top
|
|
|
|
left: selectorLv.right
|
|
|
|
margins: 10
|
|
|
|
leftMargin: 3
|
|
|
|
bottom: selectorLv.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: Button {
|
|
|
|
id: catBt
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: text !== "" ? selectorLv.delegateHeight:0
|
|
|
|
|
|
|
|
flat: true
|
|
|
|
|
|
|
|
text: selectorPu.dataObj[index].text
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
selectorPu.close()
|
2020-11-03 15:56:43 +01:00
|
|
|
control.selectionFinished(index, selectorPu.dataObj[index].data)
|
2020-10-31 15:16:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enter: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity";
|
|
|
|
//from: 0.0;
|
|
|
|
to: 1.0
|
|
|
|
}
|
|
|
|
NumberAnimation {
|
|
|
|
property: "y"
|
|
|
|
//from: root.height - selectorPu.height * 0.7
|
|
|
|
to: root.height - selectorPu.height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity";
|
|
|
|
//from: 1.0;
|
|
|
|
to: 0.0
|
|
|
|
}
|
|
|
|
NumberAnimation {
|
|
|
|
property: "y"
|
|
|
|
//from: root.height - selectorPu.height
|
|
|
|
to: root.height - selectorPu.height * 0.7
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|