141 lines
4.1 KiB
QML
141 lines
4.1 KiB
QML
/*
|
|
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
|
|
property alias selector: selectorPopup
|
|
|
|
property string subTitle
|
|
property bool titleIsPageTitle: true
|
|
|
|
property int status: -1
|
|
property bool ready: false
|
|
|
|
signal loadingFinished()
|
|
signal selectionFinished(int index, var data)
|
|
|
|
|
|
Component.onCompleted: {
|
|
console.log("TRYING TO LOAD")
|
|
var status = data.load()
|
|
console.log(data)
|
|
if(status !== BRWidget.Success)
|
|
ready = false
|
|
else
|
|
ready = true
|
|
loadingFinished()
|
|
}
|
|
|
|
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
|
|
|
|
}
|
|
|
|
SelectorPopup {
|
|
id: selectorPopup
|
|
|
|
contentItem: ListView {
|
|
id: selectorLv
|
|
|
|
property int delegateHeight: 50
|
|
spacing: 10
|
|
|
|
clip: true
|
|
|
|
implicitWidth: selectorPopup.width
|
|
implicitHeight: model === undefined ? 0:(delegateHeight + spacing) * model.length
|
|
|
|
model: selectorPopup.dataObj !== undefined ? selectorPopup.dataObj:undefined
|
|
|
|
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: selectorPopup.dataObj[index].text
|
|
|
|
onClicked: {
|
|
selectorPopup.close()
|
|
control.selectionFinished(index, selectorPopup.dataObj[index].data)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|