import QtQuick 2.0 import QtQuick.Controls 2.4 DataListView { id: control property var listData: ({}) onListDataChanged: { model = listData[ root.listKey ] === undefined ? 0:listData[ root.listKey ].length } model: listData[ root.listKey ] === undefined ? 0:listData[ root.listKey ].length delegate: ItemDelegate { id: partDel property int ind: index width: parent.width height: 70 text: "" Rectangle { anchors.fill: parent width: partDel.width color: partDel.ind % 2 == 0 ? "white":"lightgrey" opacity: 0.2 } Column { id: partDelCol anchors.fill: parent anchors.margins: 5 Row { id: partDelFirstRow width: parent.width height: parent.height - partDelSecondRow.height Label { height: parent.height width: parent.width * 0.1 fontSizeMode: Text.Fit font.bold: true font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 ) verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: listData[ "participants" ][index]["result_rank"] } Label { height: parent.height width: parent.width * 0.5 fontSizeMode: Text.Fit font.bold: true font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.6:height * 0.4 ) verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignLeft text: listData[ "participants" ][index]["firstname"] + " " + listData[ "participants" ][index]["lastname"] } Label { height: parent.height width: parent.width * 0.4 fontSizeMode: Text.Fit font.bold: false font.pixelSize: Math.abs( partDelSecondRow.height > 0 ? height * 0.4:height * 0.3 ) minimumPixelSize: 0 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: "(" + (listData[ "display_athlete" ] === "nation" ? listData[ "participants" ][index]["nation"] : listData[ "participants" ][index]["federation"]) + ")" onLinkActivated: { Qt.openUrlExternally(link) } } } Row { id: partDelSecondRow width: parent.width height: multiResRow.enabled || multiGenResRow.enabled || resultLa.enabled ? parent.height / 2:0 Row { id: multiResRow height: parent.height width: enabled ? parent.width * 0.75:0 enabled: parseInt(listData[ "route_order" ]) > -1 && boulderResRep.model > 0 Repeater { id: boulderResRep model: parseInt(listData[ "route_num_problems" ]) delegate: Item { id: boulderResItm anchors.verticalCenter: parent.verticalCenter 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" } Label { anchors.centerIn: parent height: parent.height width: parent.width * 0.9 fontSizeMode: Text.Fit font.pixelSize: Math.abs( height * 0.6 ) minimumPixelSize: 0 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: listData[ "participants" ][partDel.ind]["boulder"+(index+1)] === undefined ? "":listData[ "participants" ][partDel.ind]["boulder"+(index+1)] } } } } Row { id: multiGenResRow height: parent.height width: enabled ? parent.width - resultLa.width:0 enabled: ((parseInt(listData[ "route_order" ]) === -1) && (generalResRep.model > 0)) ? true:false Repeater { id: generalResRep property var routes: getRoutes() model: routes.length function getRoutes() { var obj = listData["route_names"] var routes = [] for(var prop in obj) { // go through the whole array and search for data keys if (obj.hasOwnProperty(prop) && prop > -1) { routes.push([prop, obj[prop]]) //console.log("found " + obj[prop] + " at index " + prop) } } routes.sort(function(a, b) { return a[0] - b[0]; }); return routes } delegate: Item { id: boulderGenResItm anchors.verticalCenter: parent.verticalCenter width: parent.width / ( generalResRep.model ) height: parent.height visible: boulderGenResLa.text != "" 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" } Label { id: boulderGenResLa anchors.centerIn: parent height: parent.height width: parent.width * 0.9 fontSizeMode: Text.Fit font.pixelSize: Math.abs( height * 0.6 ) minimumPixelSize: 0 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: listData[ "participants" ][partDel.ind]["result"+(generalResRep.routes[index][0])] === undefined ? "":listData[ "participants" ][partDel.ind]["result"+(generalResRep.routes[index][0])] } } } } Label { id: resultLa width: enabled ? parent.width * 0.25:0 height: enabled ? parent.height:0 enabled: ( boulderResRep.model > 0 || listData["discipline"] !== "boulder" ) && parseInt(listData[ "route_order" ]) > -1 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter fontSizeMode: Text.Fit font.pixelSize: Math.abs( height * 0.6 ) minimumPixelSize: 0 text: listData[ "participants" ][partDel.ind]["result"] === undefined ? "":listData[ "participants" ][partDel.ind]["result"] } } } } }