2019-05-24 14:15:07 +02: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
|
2019-05-29 20:59:01 +02:00
|
|
|
import QtGraphicalEffects 1.0
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
import "../Components"
|
|
|
|
|
|
|
|
DataListView {
|
|
|
|
id: control
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
property bool ready
|
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
property string title: control.widgetData['comp_name']
|
2021-06-20 20:11:19 +02:00
|
|
|
property string subTitle: getSubtitle()
|
2019-05-24 14:15:07 +02:00
|
|
|
property bool titleIsPageTitle: true
|
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
property Component headerComponent: ToolButton {
|
2019-05-29 20:59:01 +02:00
|
|
|
id: moreToolBt
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
control.changeCat()
|
|
|
|
}
|
|
|
|
|
2021-06-17 13:50:18 +02:00
|
|
|
text: "\uf142"
|
|
|
|
font.family: fa5solid.name
|
2019-05-24 14:15:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSubtitle() {
|
|
|
|
var titleString
|
|
|
|
|
|
|
|
for(var i = 0; i < control.widgetData["categorys"].length; i ++ ){
|
|
|
|
//console.log("checking " + i + ": cat: " + parseInt(control.widgetData["categorys"][i]["GrpId"]) + " searched cat: " + params.cat)
|
|
|
|
if(parseInt(control.widgetData["categorys"][i]["GrpId"]) === parseInt(params.cat)){
|
|
|
|
titleString = control.widgetData["categorys"][i]["name"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-20 20:11:19 +02:00
|
|
|
//% "(Startlist)"
|
2021-06-20 21:08:59 +02:00
|
|
|
var addition = qsTrId("#startlistHeadline")
|
2019-05-24 14:15:07 +02:00
|
|
|
return addition + " " + titleString
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
function changeRoute(route) {
|
|
|
|
updateData({route:route}, true)
|
|
|
|
}
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
function changeCat(){
|
|
|
|
var cats = control.widgetData["categorys"]
|
|
|
|
|
|
|
|
cats.sort(function(a, b) {
|
|
|
|
return parseInt(a["GrpId"]) - parseInt(b["GrpId"]);
|
|
|
|
});
|
|
|
|
|
|
|
|
var selectOptions = []
|
|
|
|
|
|
|
|
for(var prop in cats){
|
2019-06-09 13:32:52 +02:00
|
|
|
if (cats.hasOwnProperty(prop) && parseInt(cats[prop]["GrpId"]) !== parseInt(params.cat)) {
|
2019-05-24 14:15:07 +02:00
|
|
|
// append all cats and ignore the current one
|
2019-06-09 13:32:52 +02:00
|
|
|
//console.log("found cat: ", cats[prop]['name'])
|
2019-05-24 14:15:07 +02:00
|
|
|
selectOptions.push({text: cats[prop]['name'], data:{cat: cats[prop]['GrpId']}})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-20 21:08:59 +02:00
|
|
|
selector.appear(selectOptions, qsTrId("#startlistHeadline"))
|
2019-05-24 14:15:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: selector
|
2021-06-06 18:34:27 +02:00
|
|
|
function onSelectionFinished(index, data) {
|
2019-05-24 14:15:07 +02:00
|
|
|
if(data.cat !== undefined){
|
|
|
|
updateData({cat: data.cat}, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
property var widgetData: currentWidgetData
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
model: widgetData[ "participants" ] === undefined ? 0:widgetData[ "participants" ].length
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
Component.onCompleted: {
|
|
|
|
if(model > 0){
|
|
|
|
control.ready = true
|
|
|
|
control.status = 200
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
control.ready = false
|
|
|
|
control.status = 901
|
|
|
|
}
|
|
|
|
|
|
|
|
routeSelectTb.setCurrentIndex(routeSelectTb.getIndex(parseInt(control.widgetData['route_order'])))
|
|
|
|
}
|
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
onRefresh: {
|
|
|
|
updateData({}, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
id: partDel
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
property int thisIndex: index
|
2019-05-24 14:15:07 +02:00
|
|
|
property var thisData: widgetData[ "participants" ][index]
|
|
|
|
|
|
|
|
width: parent.width
|
2021-06-06 18:34:27 +02:00
|
|
|
height: 50
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
opacity: 0
|
|
|
|
scale: 0.9
|
|
|
|
|
|
|
|
onThisDataChanged: {
|
|
|
|
fadeInPa.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
app.openWidget({person:thisData["PerId"]})
|
|
|
|
}
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: fadeInPa
|
|
|
|
NumberAnimation { target: partDel; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
|
|
|
NumberAnimation { target: partDel; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
|
|
|
}
|
|
|
|
|
|
|
|
text: ""
|
|
|
|
|
2021-06-08 19:23:55 +02:00
|
|
|
highlighted: partDel.thisIndex % 2 == 0
|
2021-06-06 18:34:27 +02:00
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
Row {
|
|
|
|
id: partDelFirstRow
|
|
|
|
|
2019-05-31 12:18:35 +02:00
|
|
|
anchors {
|
|
|
|
fill: parent
|
|
|
|
leftMargin: parent.width * 0.05
|
|
|
|
rightMargin: parent.width * 0.05
|
|
|
|
}
|
|
|
|
|
2021-06-06 18:34:27 +02:00
|
|
|
spacing: width * 0.05
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
Label {
|
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.1
|
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: true
|
2021-06-06 18:34:27 +02:00
|
|
|
font.pixelSize: Math.abs( height * 0.4 )
|
2019-05-24 14:15:07 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
|
|
|
text: widgetData[ "participants" ][index]["start_order"]
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
height: parent.height
|
2021-06-06 18:34:27 +02:00
|
|
|
width: parent.width * 0.45
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
font.bold: true
|
2019-06-23 10:55:08 +02:00
|
|
|
font.pixelSize: Math.abs( height * 0.35 )
|
2019-05-24 14:15:07 +02:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
minimumPixelSize: 1
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
text: widgetData[ "participants" ][index]["firstname"] + " " + widgetData[ "participants" ][index]["lastname"] + (partDel.thisData["start_number"] !== undefined ? (" (" + partDel.thisData["start_number"] + ")"):"")
|
2019-05-24 14:15:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
height: parent.height
|
|
|
|
width: parent.width * 0.3
|
|
|
|
|
|
|
|
font.bold: false
|
2021-06-06 18:34:27 +02:00
|
|
|
font.pixelSize: height * 0.3
|
2019-05-24 14:15:07 +02:00
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
|
|
|
text: "<html>(<a href=\"" + (widgetData[ "participants" ][index]["url"] === undefined ? "":widgetData[ "participants" ][index]["url"]).toString() + "\">" + (widgetData[ "display_athlete" ] === "nation" ? widgetData[ "participants" ][index]["nation"] : widgetData[ "participants" ][index]["federation"]) + "</a>)</html>"
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2019-05-29 20:59:01 +02:00
|
|
|
|
|
|
|
footer: ItemDelegate {
|
|
|
|
height: routeSelectTb.height
|
|
|
|
}
|
|
|
|
|
|
|
|
RectangularGlow {
|
|
|
|
id: toolBarEffect
|
|
|
|
glowRadius: 3
|
|
|
|
spread: 0.2
|
|
|
|
color: "black"
|
|
|
|
opacity: 0.3
|
|
|
|
anchors.fill: routeSelectTb
|
|
|
|
}
|
|
|
|
|
|
|
|
TabBar {
|
|
|
|
id: routeSelectTb
|
|
|
|
|
|
|
|
property var tabs: getTabs()
|
|
|
|
property var tabIndexes: []
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
height: tabs.length > 1 ? 50:0
|
|
|
|
|
|
|
|
position: TabBar.Footer
|
|
|
|
|
|
|
|
function getTabs() {
|
|
|
|
|
|
|
|
var obj = control.widgetData["route_names"]
|
|
|
|
var buttonData = []
|
|
|
|
|
|
|
|
for(var prop in obj) {
|
|
|
|
// go through the whole array and search for data keys
|
|
|
|
if (obj.hasOwnProperty(prop)) {
|
|
|
|
buttonData.push([prop, obj[prop]])
|
|
|
|
console.log("found " + obj[prop] + " at index " + prop)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonData.sort(function(a, b) {
|
|
|
|
return a[0] - b[0];
|
|
|
|
});
|
|
|
|
|
|
|
|
return buttonData
|
|
|
|
}
|
|
|
|
|
|
|
|
function getIndex(routeNumber) {
|
|
|
|
console.log("getting index for route number: " + routeNumber)
|
|
|
|
|
|
|
|
for(var i = 0; i < tabs.length; i++){
|
|
|
|
//console.log(tabs[i])
|
|
|
|
if(parseInt(tabs[i][0]) === routeNumber){
|
|
|
|
console.log("found index: " + i)
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: routeSelectButtonRep
|
|
|
|
|
|
|
|
model: routeSelectTb.tabs.length
|
|
|
|
|
|
|
|
onModelChanged: {
|
|
|
|
routeSelectTb.setCurrentIndex(routeSelectTb.getIndex(parseInt(control.widgetData['route_order'])))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
delegate: TabButton {
|
|
|
|
text: routeSelectTb.tabs[index][1]
|
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
width: Math.max(150, root.width / routeSelectButtonRep.model) //text.length * font.pixelSize
|
2019-05-29 20:59:01 +02:00
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
//console.log("changing to index: " + index + " (" + routeSelectTb.tabs[index][0] + ", " + routeSelectTb.tabs[index][1] + ")")
|
2019-05-31 12:18:35 +02:00
|
|
|
if(routeSelectTb.getIndex(parseInt(control.widgetData['route_order'])) !== index){
|
|
|
|
control.changeRoute(routeSelectTb.tabs[index][0])
|
|
|
|
routeSelectTb.setCurrentIndex(routeSelectTb.getIndex(parseInt(control.widgetData['route_order'])))
|
|
|
|
}
|
2019-05-29 20:59:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
}
|