2019-05-23 23:17:27 +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-06-09 13:32:52 +02:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
import "../Components"
|
|
|
|
|
|
|
|
DataListView {
|
|
|
|
id: control
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
property bool ready
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
property string title: (params.nation === "ICC" ? "IFSC":params.nation === "GER" ? "DAV":"SAC") + " " + qsTr("calendar") + " " + control.year
|
2019-06-09 13:32:52 +02:00
|
|
|
property Component headerComponent: RowLayout {
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
height: parent.height
|
2019-06-23 10:55:08 +02:00
|
|
|
width: 100//childrenRect.width
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
spacing: 0
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
ToolButton {
|
2019-05-29 20:59:01 +02:00
|
|
|
id:yearToolBt
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
onClicked: {
|
|
|
|
control.changeYear()
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
icon.name: "year"
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolButton {
|
|
|
|
id: filterToolBt
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
var obj = app.compCats
|
|
|
|
var compCats = new Array
|
|
|
|
|
|
|
|
for(var prop in obj) {
|
|
|
|
// go through the whole array and search for data keys
|
|
|
|
if (obj.hasOwnProperty(prop) && obj[prop]["nation"] === params.nation) {
|
|
|
|
//console.log("found cat: " + obj[prop]['label'])
|
|
|
|
|
|
|
|
compCats.push( {"text": obj[prop]['label'], "data": obj[prop]} )
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
compCats.sort(function(a, b) {
|
|
|
|
return a['data']['sort_rank'] - b['data']['sort_rank'];
|
|
|
|
});
|
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
filterSelectPu.appear(compCats, qsTr("Select Filters"), "")
|
|
|
|
}
|
|
|
|
|
|
|
|
icon.name: "filter"
|
2019-05-29 20:59:01 +02:00
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
ToolButton {
|
2019-05-29 20:59:01 +02:00
|
|
|
id: cupToolBt
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
onClicked: {
|
|
|
|
control.openCup()
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-09 13:32:52 +02:00
|
|
|
icon.name: "cup"
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
property var widgetData: currentWidgetData
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
property int year: new Date().getFullYear()
|
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
property var displayedCompCats: []
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
//boundsBehavior: Flickable.StopAtBounds
|
|
|
|
|
|
|
|
model: widgetData["competitions"].length
|
2019-07-04 09:03:39 +02:00
|
|
|
//listData: widgetData['competitions']
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
onRefresh: {
|
|
|
|
updateData({}, false)
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:59:01 +02:00
|
|
|
Component.onCompleted: {
|
2019-06-23 10:55:08 +02:00
|
|
|
initFilters()
|
|
|
|
|
2019-07-04 09:03:39 +02:00
|
|
|
if(model){
|
2019-05-29 20:59:01 +02:00
|
|
|
control.status = 200
|
2019-07-04 09:03:39 +02:00
|
|
|
control.ready = true
|
2019-05-29 20:59:01 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
control.ready = false
|
|
|
|
control.status = 901
|
2019-07-04 09:03:39 +02:00
|
|
|
return
|
2019-05-29 20:59:01 +02:00
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
autoScroll()
|
2019-06-23 10:55:08 +02:00
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
onWidgetDataChanged: {
|
2019-05-24 14:15:07 +02:00
|
|
|
// if the IFSC Calendar is open -> add the worldranking
|
2019-06-23 10:55:08 +02:00
|
|
|
if(params.nation === "ICC"){
|
2019-05-24 14:15:07 +02:00
|
|
|
control.widgetData['cups'].unshift({"SerId":"","rkey":"","name":"Worldranking","modified":"2018-10-24 16:11:12","modifier":"","year":"","num_comps":"","cats":["ICC-COA","ICC-HD","ICC-MED","ICC_F","ICC_FB","ICC_FS","ICC_M","ICC_MB","ICC_MS"]})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
function autoScroll() {
|
2019-05-29 20:59:01 +02:00
|
|
|
// function to scroll to the next competition that is not already over
|
2019-05-23 23:17:27 +02:00
|
|
|
var compList = control.widgetData["competitions"]
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
//console.log("scrolling")
|
2019-05-29 20:59:01 +02:00
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
if(parseInt(control.year) === new Date().getFullYear()){
|
|
|
|
for(var i = 0; i < compList.length; i ++){
|
2019-07-04 09:03:39 +02:00
|
|
|
// get the start date of the competition
|
2019-05-23 23:17:27 +02:00
|
|
|
var startDate = Date.fromLocaleString(Qt.locale(), compList[i]["date"], "yyyy-MM-dd")
|
2019-07-04 09:03:39 +02:00
|
|
|
//control.widgetData["competitions"][i]["month"] = startDate.getMonth()
|
|
|
|
|
|
|
|
//console.log("got date: " + startDate + " from string: " + compList[i]["date"] + " -> month is: " + compList[i]["month"])
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
// get the duration of the competition
|
|
|
|
var durationString = compList[i]["duration"] === undefined ? "1":compList[i]["duration"]
|
|
|
|
var days = parseInt(durationString.replace(/\D/g,''))
|
|
|
|
// calculate the end date of the competition
|
|
|
|
var endDate = new Date(startDate.valueOf())
|
|
|
|
endDate.setDate(endDate.getDate() + days);
|
|
|
|
|
|
|
|
//console.log(compList[i]["date"] + ": " + startDate + " to " + endDate)
|
|
|
|
|
|
|
|
if(endDate.getTime() < new Date().getTime()){
|
|
|
|
// end date is already over -> move the list view down!
|
|
|
|
control.positionViewAtIndex(i, ListView.Top)
|
|
|
|
//console.log("moving down!")
|
|
|
|
}
|
|
|
|
}
|
2019-07-04 09:03:39 +02:00
|
|
|
|
|
|
|
//control.widgetData = control.widgetData
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
2019-05-29 20:59:01 +02:00
|
|
|
else {
|
|
|
|
//console.log("not current year")
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getCompCatData(compCatId) {
|
|
|
|
var obj = app.compCats
|
|
|
|
|
|
|
|
for(var prop in obj) {
|
|
|
|
// go through the whole array and search for data keys
|
|
|
|
if (obj.hasOwnProperty(prop) && obj[prop]["cat_id"].indexOf(compCatId) >= 0) {
|
|
|
|
//console.log("found cat: " + obj[prop]['label'])
|
|
|
|
return obj[prop]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function openComp(compIndex){
|
|
|
|
var cats = control.widgetData["competitions"][compIndex]["cats"]
|
|
|
|
|
|
|
|
cats.sort(function(a, b) {
|
|
|
|
return parseInt(a["GrpId"]) - parseInt(b["GrpId"]);
|
|
|
|
});
|
|
|
|
|
|
|
|
var selectOptions = []
|
|
|
|
|
|
|
|
for(var prop in cats){
|
|
|
|
if (cats.hasOwnProperty(prop)) {
|
|
|
|
selectOptions.push({text: cats[prop]["name"], data:{cat: cats[prop]["GrpId"], comp: control.widgetData["competitions"][compIndex]["WetId"], status:cats[prop]["status"]}})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
var infosheet = getCompInfoUrl(compIndex) !== undefined ? ("<a href='" + getCompInfoUrl(compIndex) + "'>" + qsTr('infosheet') + "</a>"): ""
|
|
|
|
var eventWebsite = control.widgetData["competitions"][compIndex]["homepage"] !== undefined ? ("<a href='" + control.widgetData["competitions"][compIndex]["homepage"] + "'>" + qsTr('Event Website') + "</a>"):""
|
|
|
|
|
|
|
|
selector.appear(selectOptions, control.widgetData["competitions"][compIndex]['name'], eventWebsite + ((eventWebsite !== "" && infosheet !== "") ? ", ":"") + infosheet )
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function changeYear(){
|
|
|
|
var years = control.widgetData["years"]
|
|
|
|
|
|
|
|
var selectOptions = []
|
|
|
|
|
|
|
|
for(var prop in years){
|
|
|
|
if (years.hasOwnProperty(prop)) {
|
|
|
|
selectOptions.push({text: years[prop], data:{year: years[prop]}})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
selector.appear(selectOptions, qsTr("select year"))
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
function openCup(state, data) {
|
|
|
|
var cups = control.widgetData["cups"]
|
|
|
|
|
|
|
|
var prop
|
|
|
|
var selectOptions = []
|
|
|
|
var selectTitle = ""
|
|
|
|
|
|
|
|
if(state === undefined){
|
|
|
|
// opened for the first time -> select cup
|
|
|
|
selectTitle = qsTr("select cup")
|
|
|
|
|
|
|
|
cups.sort(function(a, b) {
|
|
|
|
return parseInt(b["SerId"]) - parseInt(a["SerId"]);
|
|
|
|
});
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-05-24 14:15:07 +02:00
|
|
|
for(prop in cups){
|
|
|
|
if (cups.hasOwnProperty(prop)) {
|
|
|
|
selectOptions.push({text: cups[prop]["name"], data:{cup: cups[prop]["SerId"]}})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(state === 1){
|
|
|
|
// opened for the second time -> select cat
|
|
|
|
var cup
|
|
|
|
|
|
|
|
// find the selected cup
|
|
|
|
for(prop in cups){
|
|
|
|
if (cups.hasOwnProperty(prop) && cups[prop]['SerId'] === data.cup) {
|
|
|
|
cup = cups[prop]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cup === undefined){
|
|
|
|
// cup was not found
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
selectTitle = cup['name'] + ": " + qsTr("select category")
|
|
|
|
|
|
|
|
// build a list with all cat in the cup out of the cat keys (rkey) given in the cup.cats
|
|
|
|
for(prop in cup['cats']){
|
|
|
|
if (cup['cats'].hasOwnProperty(prop)) {
|
|
|
|
|
|
|
|
// search the rkey in the cat list
|
|
|
|
for(var i = 0; i < control.widgetData["cats"].length; i ++ ){
|
|
|
|
if(control.widgetData["cats"][i]["rkey"] === cup["cats"][prop] && control.widgetData["cats"][i]["sex"] !== undefined){
|
|
|
|
// found it -> append it to the select list
|
|
|
|
var catName = control.widgetData["cats"][i]["name"] // name of cat
|
|
|
|
var catId = control.widgetData["cats"][i]["GrpId"] // id of cat
|
|
|
|
selectOptions.push({text: catName, data:{cup: data.cup, cat: catId}})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
selector.appear(selectOptions, selectTitle)
|
|
|
|
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
function getCompInfoUrl(compIndex) {
|
|
|
|
switch(params.nation) {
|
|
|
|
case "GER":
|
|
|
|
if(control.widgetData["competitions"][compIndex]['info'] !== undefined){
|
|
|
|
return "http://ranking.alpenverein.de/" + control.year + "/GER/" + control.widgetData["competitions"][compIndex]['rkey'] + ".pdf"
|
|
|
|
}
|
|
|
|
return
|
|
|
|
case "SUI":
|
|
|
|
return
|
|
|
|
default:
|
|
|
|
if(control.widgetData["competitions"][compIndex]['info'] === undefined){
|
|
|
|
return control.widgetData["competitions"][compIndex]['info2']
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return control.widgetData["competitions"][compIndex]['info']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function filterCats(display, cats) {
|
|
|
|
//console.log("filtering cats: " + cats + " displaying: " + display)
|
|
|
|
for(var i = 0; i < cats.length; i ++){
|
|
|
|
if(control.displayedCompCats.indexOf(cats[i]) >= 0 && !display){
|
|
|
|
control.displayedCompCats.splice(control.displayedCompCats.indexOf(cats[i]), 1)
|
|
|
|
}
|
|
|
|
else if(control.displayedCompCats.indexOf(cats[i]) == -1 && display){
|
|
|
|
control.displayedCompCats.push(cats[i])
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// trigger 'changed' signal
|
|
|
|
control.displayedCompCats = control.displayedCompCats
|
|
|
|
appSettings.write("displayedCompCats"+params.nation, JSON.stringify(displayedCompCats))
|
|
|
|
//console.log("new JSON string is: " + JSON.stringify(displayedCompCats))
|
|
|
|
//console.log("displayed cats is now: " + control.displayedCompCats)
|
|
|
|
}
|
|
|
|
|
|
|
|
function initFilters() {
|
|
|
|
|
|
|
|
if(appSettings.read("displayedCompCats"+params.nation) !== "false"){
|
|
|
|
//console.log(appSettings.read("displayedCompCats"+params.nation))
|
|
|
|
control.displayedCompCats = JSON.parse(appSettings.read("displayedCompCats"+params.nation))
|
|
|
|
}
|
|
|
|
if(control.displayedCompCats.length === 0){
|
|
|
|
var obj = app.compCats
|
|
|
|
var compCats = new Array
|
|
|
|
|
|
|
|
for(var prop in obj) {
|
|
|
|
// go through the whole array and search for data keys
|
|
|
|
if (obj.hasOwnProperty(prop) && obj[prop]["nation"] === params.nation) {
|
|
|
|
//console.log("found cat: " + obj[prop]['label'])
|
|
|
|
filterCats(true, obj[prop]['cat_id'])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// trigger 'changed' signal
|
|
|
|
control.displayedCompCats = control.displayedCompCats
|
|
|
|
//console.log(control.displayedCompCats)
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
Connections {
|
2019-05-29 20:59:01 +02:00
|
|
|
target: parent.selector
|
2019-05-23 23:17:27 +02:00
|
|
|
onSelectionFinished: {
|
|
|
|
if(data.comp !== undefined){
|
2019-06-23 13:45:29 +02:00
|
|
|
//console.log(data.status)
|
2019-05-23 23:17:27 +02:00
|
|
|
app.openWidget({comp: data.comp, cat: data.cat, type:data.status === 4 ? 'starters':''})
|
|
|
|
}
|
|
|
|
else if(data.year !== undefined){
|
|
|
|
updateData({year: data.year}, true)
|
|
|
|
control.year = data.year
|
|
|
|
}
|
2019-05-24 14:15:07 +02:00
|
|
|
else if(data.cup !== undefined && data.cat === undefined){
|
|
|
|
control.openCup(1,data)
|
|
|
|
}
|
|
|
|
else if(data.cup !== undefined && data.cat !== undefined){
|
|
|
|
app.openWidget({cup: data.cup, cat: data.cat})
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
header: Item {
|
|
|
|
id: topSpacerItm
|
|
|
|
width: parent.width
|
|
|
|
height: 10
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: Item {
|
|
|
|
id: bottomSpacerItm
|
|
|
|
width: parent.width
|
|
|
|
height: 10
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
id: competitionDel
|
|
|
|
|
|
|
|
property bool over
|
|
|
|
property var thisData: control.widgetData["competitions"][index]
|
|
|
|
|
|
|
|
property string name: thisData["name"]
|
|
|
|
property string date: thisData["date_span"]
|
|
|
|
property var cats: thisData["cats"]
|
|
|
|
property int catId: thisData["cat_id"] === undefined ? 0:thisData["cat_id"]
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
property bool includedByFilter: control.displayedCompCats.indexOf(parseInt(thisData['cat_id'])) >= 0
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
width: parent.width
|
2019-06-23 13:45:29 +02:00
|
|
|
height: includedByFilter ? compDelCol.height + 10 : 0
|
2019-05-23 23:17:27 +02:00
|
|
|
|
2019-07-04 09:03:39 +02:00
|
|
|
enabled: (thisData["cats"] !== undefined && thisData["cats"].length > 0) || competitionDel.thisData["homepage"] !== undefined || getCompInfoUrl(index) !== undefined
|
2019-06-23 13:45:29 +02:00
|
|
|
//visible: includedByFilter
|
2019-05-23 23:17:27 +02:00
|
|
|
|
|
|
|
opacity: 0
|
|
|
|
scale: 0.9
|
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
Connections {
|
|
|
|
target: control
|
|
|
|
onDisplayedCompCatsChanged: {
|
2019-06-23 13:45:29 +02:00
|
|
|
competitionDel.includedByFilter = control.displayedCompCats.indexOf(parseInt(competitionDel.thisData['cat_id'])) >= 0
|
2019-06-23 10:55:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
onThisDataChanged: {
|
2019-06-23 13:45:29 +02:00
|
|
|
if(includedByFilter){
|
|
|
|
fadeInPa.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onIncludedByFilterChanged: {
|
|
|
|
if(includedByFilter){
|
|
|
|
fadeInPa.start()
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fadeOutPa.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on height {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 400
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
control.openComp(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
ParallelAnimation {
|
|
|
|
id: fadeInPa
|
|
|
|
NumberAnimation { target: competitionDel; property: "opacity"; from: 0; to: 1.0; duration: 400 }
|
|
|
|
NumberAnimation { target: competitionDel; property: "scale"; from: 0.8; to: 1.0; duration: 400 }
|
|
|
|
}
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
ParallelAnimation {
|
|
|
|
id: fadeOutPa
|
|
|
|
NumberAnimation { target: competitionDel; property: "opacity"; from: 1; to: 0; duration: 400 }
|
|
|
|
NumberAnimation { target: competitionDel; property: "scale"; from: 1; to: 0.8; duration: 400 }
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
Rectangle {
|
|
|
|
id: delBackroundRect
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
opacity: 0.5
|
|
|
|
|
|
|
|
color: control.getCompCatData(catId) === undefined ? "white":control.getCompCatData(catId)["bgcolor"]
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: compDelCol
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
width: parent.width * 0.97
|
|
|
|
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: nameLa
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
font.bold: true
|
|
|
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
|
|
|
text: name
|
|
|
|
}
|
2019-05-29 20:59:01 +02:00
|
|
|
|
2019-07-04 09:03:39 +02:00
|
|
|
Label {
|
|
|
|
//text: model.month
|
|
|
|
}
|
|
|
|
|
2019-05-23 23:17:27 +02:00
|
|
|
Label {
|
|
|
|
id: dateLa
|
|
|
|
|
|
|
|
color: "grey"
|
|
|
|
|
|
|
|
text: date
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: bottomLineRa
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
|
|
|
|
height: 1
|
|
|
|
|
|
|
|
color: "lightgrey"
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2019-06-23 10:55:08 +02:00
|
|
|
|
2019-07-04 09:03:39 +02:00
|
|
|
section.property: "month"
|
|
|
|
section.delegate: ItemDelegate {
|
|
|
|
id: name
|
|
|
|
background: Rectangle {
|
|
|
|
color: "red"
|
|
|
|
}
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
text: section
|
|
|
|
}
|
|
|
|
|
2019-06-23 10:55:08 +02:00
|
|
|
Dialog {
|
|
|
|
id: filterSelectPu
|
|
|
|
|
|
|
|
property var dataObj
|
|
|
|
property string subTitle: ""
|
|
|
|
|
|
|
|
signal selectionFinished(int index, var data)
|
|
|
|
|
|
|
|
x: 0 - control.anchors.leftMargin //root.width / 2 - width / 2
|
|
|
|
y: root.height - filterSelectPu.height * 0.7//root.height - height //root.height / 2 - height / 2
|
|
|
|
|
|
|
|
opacity: 0
|
|
|
|
|
|
|
|
width: control.width + control.anchors.leftMargin + control.anchors.rightMargin
|
|
|
|
height: selectorLv.implicitHeight
|
|
|
|
|
|
|
|
modal: true
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
title: ""
|
|
|
|
|
|
|
|
function appear(dataObj, title, subTitle) {
|
|
|
|
if(dataObj.length > 0){
|
|
|
|
filterSelectPu.dataObj = dataObj
|
|
|
|
filterSelectPu.title = title
|
|
|
|
filterSelectPu.subTitle = subTitle === undefined ? "":subTitle
|
|
|
|
filterSelectPu.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
header: Column {
|
|
|
|
id: filterSelectPuHeaderCol
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: headerLa
|
|
|
|
|
|
|
|
visible: filterSelectPu.title
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
padding: 24
|
|
|
|
bottomPadding: 0
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 16
|
|
|
|
background: Rectangle {
|
|
|
|
radius: 2
|
|
|
|
//color: filterSelectPu.Material.dialogColor
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
text: filterSelectPu.title
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
id: headerSubLa
|
|
|
|
|
|
|
|
visible: filterSelectPu.subTitle
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
|
|
|
|
elide: "ElideRight"
|
|
|
|
padding: 24
|
|
|
|
topPadding: 5
|
|
|
|
bottomPadding: 0
|
|
|
|
font.bold: true
|
|
|
|
font.pixelSize: 16
|
|
|
|
background: Rectangle {
|
|
|
|
radius: 2
|
|
|
|
//color: filterSelectPu.Material.dialogColor
|
|
|
|
clip: true
|
|
|
|
}
|
|
|
|
|
|
|
|
text: filterSelectPu.subTitle
|
|
|
|
|
|
|
|
onLinkActivated: {
|
|
|
|
Qt.openUrlExternally(link)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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: filterSelectPu.dataObj !== undefined ? filterSelectPu.dataObj.length:0
|
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator {
|
|
|
|
parent: selectorLv.parent
|
|
|
|
anchors {
|
|
|
|
top: selectorLv.top
|
|
|
|
left: selectorLv.right
|
|
|
|
margins: 10
|
|
|
|
leftMargin: 3
|
|
|
|
bottom: selectorLv.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: CheckDelegate {
|
|
|
|
id: catBt
|
|
|
|
|
|
|
|
width: parent.width
|
|
|
|
height: text !== "" ? selectorLv.delegateHeight:0
|
|
|
|
|
|
|
|
//flat: true
|
|
|
|
|
|
|
|
text: filterSelectPu.dataObj[index].text
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
checked = getCheckedState()
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: control
|
|
|
|
onDisplayedCompCatsChanged: {
|
|
|
|
//console.log("filters changed")
|
|
|
|
//competitionDel.visible = control.displayedCompCats.indexOf(parseInt(competitionDel.thisData['cat_id'])) >= 0
|
|
|
|
checked = getCheckedState()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCheckedState() {
|
|
|
|
for(var i = 0; i < filterSelectPu.dataObj[index].data.cat_id.length; i ++){
|
|
|
|
|
2019-06-23 13:45:29 +02:00
|
|
|
//console.log("checking cat " + filterSelectPu.dataObj[index].data.label )
|
2019-06-23 10:55:08 +02:00
|
|
|
if(control.displayedCompCats.indexOf(filterSelectPu.dataObj[index].data.cat_id[i] ) >= 0){
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
control.filterCats(checked, filterSelectPu.dataObj[index].data.cat_id)
|
|
|
|
if(control.displayedCompCats.length == 0){
|
|
|
|
control.filterCats(true, filterSelectPu.dataObj[index].data.cat_id)
|
|
|
|
checked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enter: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity";
|
|
|
|
//from: 0.0;
|
|
|
|
to: 1.0
|
|
|
|
}
|
|
|
|
NumberAnimation {
|
|
|
|
property: "y"
|
|
|
|
//from: root.height - filterSelectPu.height * 0.7
|
|
|
|
to: root.height - filterSelectPu.height
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit: Transition {
|
|
|
|
NumberAnimation {
|
|
|
|
property: "opacity";
|
|
|
|
//from: 1.0;
|
|
|
|
to: 0.0
|
|
|
|
}
|
|
|
|
NumberAnimation {
|
|
|
|
property: "y"
|
|
|
|
//from: root.height - filterSelectPu.height
|
|
|
|
to: root.height - filterSelectPu.height * 0.7
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-23 23:17:27 +02:00
|
|
|
}
|