2019-06-08 11:14:18 +02:00
|
|
|
/*
|
|
|
|
Speed Climbing Stopwatch - Simple Stopwatch for Climbers
|
|
|
|
Copyright (C) 2018 - 2019 Itsblue Development - Dorian Zeder
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, version 3 of the License.
|
|
|
|
|
|
|
|
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 Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import QtQuick 2.9
|
|
|
|
import QtMultimedia 5.8
|
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Controls 2.4
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
2020-05-26 17:57:54 +02:00
|
|
|
|
|
|
|
import de.itsblue.ScStw 2.0
|
|
|
|
import de.itsblue.ScStw.Styling 2.0
|
|
|
|
import de.itsblue.ScStw.Styling.Components 1.0
|
|
|
|
import de.itsblue.ScStwApp 2.0
|
2019-06-08 11:14:18 +02:00
|
|
|
|
|
|
|
import "../components"
|
|
|
|
|
|
|
|
|
|
|
|
RemoteDataListView {
|
|
|
|
id: profileList
|
|
|
|
|
|
|
|
property int currentAthlete: -1
|
|
|
|
property string title: "profiles"
|
|
|
|
property string secondButt: "add"
|
|
|
|
|
|
|
|
signal opened()
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
profileList.loadData()
|
|
|
|
}
|
|
|
|
|
|
|
|
//anchors.fill: parent
|
|
|
|
//anchors.topMargin: topContainerItm.height * 0.1
|
|
|
|
|
|
|
|
loadData: function () {
|
|
|
|
status = 905
|
|
|
|
//listData = {}
|
|
|
|
var retData = speedBackend.getAthletes()
|
|
|
|
|
2019-08-19 15:14:11 +02:00
|
|
|
if(!retData){
|
2019-06-08 11:14:18 +02:00
|
|
|
status = 500
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
listData = retData["allAthletes"]
|
|
|
|
currentAthlete = retData["activeAthlete"]
|
|
|
|
status = listData.lenght !== false ? 200:0
|
|
|
|
}
|
|
|
|
|
|
|
|
delegate: SwipeDelegate {
|
|
|
|
id: swipeDelegate
|
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
property int thisIndex: index
|
2019-06-08 11:14:18 +02:00
|
|
|
|
|
|
|
text: profileList.listData[index]["fullName"]
|
|
|
|
width: profileList.width - (swipeDelegate.x)
|
|
|
|
height: profileList.height / 5
|
|
|
|
|
|
|
|
font.pixelSize: profilesStack.text_pixelSize
|
|
|
|
|
|
|
|
function remove() {
|
|
|
|
removeAnim.start()
|
|
|
|
}
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
profilesStack.openResults(profileList.listData[index]["userName"])
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Text {
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: swipeDelegate.width * 0.05
|
2019-09-08 15:08:50 +02:00
|
|
|
right: athleteSelectBoxRow.left
|
|
|
|
rightMargin: leftMargin
|
2019-06-08 11:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
text: swipeDelegate.text
|
2020-05-19 12:43:32 +02:00
|
|
|
color: appTheme.theme.colors.text
|
2019-06-08 11:14:18 +02:00
|
|
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
|
|
|
|
fontSizeMode: Text.Fit
|
|
|
|
|
|
|
|
font.pixelSize: swipeDelegate.height * 0.4
|
|
|
|
|
|
|
|
minimumPixelSize: 1
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
2020-05-19 12:43:32 +02:00
|
|
|
color: pressed ? appTheme.theme.colors.delegatePressed : appTheme.theme.colors.delegateBackground
|
2019-06-08 11:14:18 +02:00
|
|
|
|
|
|
|
Behavior on color {
|
|
|
|
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
Row {
|
|
|
|
id: athleteSelectBoxRow
|
2019-06-08 11:14:18 +02:00
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: 7
|
|
|
|
}
|
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
height: parent.height
|
|
|
|
width: childrenRect.width
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
Repeater {
|
|
|
|
id: athleteSelectBoxRep
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
model: scStwRemoteRace.timers.length
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
delegate: CheckBox {
|
|
|
|
id: control
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
property bool active: scStwRemoteRace.timers[index]["id"] === profileList.listData[swipeDelegate.thisIndex]["active"]
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
height: parent.height * 0.6
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2020-10-09 15:44:24 +02:00
|
|
|
enabled: scStwRemoteRace.timers[index]["state"] !== ScStwTimer.DISABLED
|
2019-09-08 15:08:50 +02:00
|
|
|
checked: control.active
|
2019-06-08 11:14:18 +02:00
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
onCheckedChanged: {
|
2020-10-09 15:44:24 +02:00
|
|
|
if(checked && !control.active && speedBackend.selectAthlete(profileList.listData[swipeDelegate.thisIndex]["userName"], scStwRemoteRace.timers[index]["id"])){
|
2019-09-08 15:08:50 +02:00
|
|
|
profileList.loadData()
|
2019-06-08 11:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-08 15:08:50 +02:00
|
|
|
indicator: Rectangle {
|
|
|
|
implicitWidth: 26
|
|
|
|
implicitHeight: 26
|
|
|
|
|
|
|
|
height: parent.height
|
|
|
|
width: height
|
|
|
|
|
|
|
|
x: control.leftPadding
|
|
|
|
y: parent.height / 2 - height / 2
|
|
|
|
|
|
|
|
radius: width * 0.2
|
|
|
|
border.color: control.enabled ? control.down ? "#17a81a" : "#21be2b" : "grey"
|
2020-05-19 12:43:32 +02:00
|
|
|
color: control.down ? appTheme.theme.colors.delegatePressed : appTheme.theme.colors.delegateBackground
|
2019-09-08 15:08:50 +02:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: parent.width * 0.65
|
|
|
|
height: width
|
|
|
|
anchors.centerIn: parent
|
|
|
|
radius: control.checked ? width * 0.2:0
|
|
|
|
color: control.enabled ? control.down ? "#17a81a" : "#21be2b" : "grey"
|
|
|
|
opacity: control.checked ? 1:0
|
|
|
|
scale: control.checked ? 0.9:0
|
|
|
|
|
|
|
|
Behavior on color {
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on radius {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on opacity {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Behavior on scale {
|
|
|
|
NumberAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
2019-06-08 11:14:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-08 15:08:50 +02:00
|
|
|
|
2019-06-08 11:14:18 +02:00
|
|
|
}
|
2019-09-08 15:08:50 +02:00
|
|
|
|
2019-06-08 11:14:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: "grey"
|
|
|
|
height: 1
|
|
|
|
width: parent.width * 0.9
|
|
|
|
visible: index > 0
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
top: parent.top
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NumberAnimation {
|
|
|
|
id: removeAnim
|
|
|
|
target: swipeDelegate
|
|
|
|
property: "height"
|
|
|
|
to: 0
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
onStopped: profileModel.model.remove(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
swipe.transition: Transition {
|
|
|
|
SmoothedAnimation { velocity: 3; easing.type: Easing.InOutCubic }
|
|
|
|
}
|
|
|
|
|
|
|
|
swipe.left: Row {
|
|
|
|
anchors.left: parent.left
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: deleteLabel
|
|
|
|
text: qsTr("Delete")
|
2020-05-19 12:43:32 +02:00
|
|
|
color: appTheme.theme.colors.text
|
2019-06-08 11:14:18 +02:00
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
padding: 12
|
|
|
|
height: parent.height
|
|
|
|
|
|
|
|
SwipeDelegate.onClicked: {
|
|
|
|
profileList.status = 905
|
|
|
|
if(speedBackend.deleteAthlete(profileList.listData[index]["userName"])){
|
|
|
|
profileList.loadData()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
profileList.status = 200
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
color: deleteLabel.SwipeDelegate.pressed ? Qt.darker("tomato", 1.1) : "tomato"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|