2017-04-27 18:30:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-01-22 00:22:15 +00:00
|
|
|
import QtQuick 2.6
|
2018-10-27 14:17:33 +00:00
|
|
|
import QtQuick.Controls 2.2 as Controls
|
2015-11-29 16:30:41 +00:00
|
|
|
import QtQuick.Layouts 1.2
|
2015-07-10 08:40:30 +00:00
|
|
|
import QtQuick.Window 2.2
|
|
|
|
import QtQuick.Dialogs 1.2
|
2018-10-12 12:57:43 +00:00
|
|
|
import org.kde.kirigami 2.5 as Kirigami
|
2015-07-10 08:40:30 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
|
|
|
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.ScrollablePage {
|
2015-07-10 08:40:30 +00:00
|
|
|
id: page
|
2015-08-20 08:44:01 +00:00
|
|
|
objectName: "DiveList"
|
2016-05-03 19:24:00 +00:00
|
|
|
title: qsTr("Dive list")
|
2018-04-15 14:28:41 +00:00
|
|
|
verticalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
2020-11-24 23:55:03 +00:00
|
|
|
property int dlHorizontalPadding: Kirigami.Units.gridUnit / 2 - Kirigami.Units.smallSpacing + 1
|
2020-04-01 14:27:10 +00:00
|
|
|
property QtObject diveListModel: null
|
2020-12-22 23:02:39 +00:00
|
|
|
// we want to use our own colors for Kirigami, so let's define our colorset
|
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Button
|
|
|
|
Kirigami.Theme.backgroundColor: subsurfaceTheme.backgroundColor
|
|
|
|
Kirigami.Theme.textColor: subsurfaceTheme.textColor
|
|
|
|
|
2017-06-21 22:54:34 +00:00
|
|
|
supportsRefreshing: true
|
|
|
|
onRefreshingChanged: {
|
|
|
|
if (refreshing) {
|
2020-01-05 16:08:48 +00:00
|
|
|
if (Backend.cloud_verification_status === Enums.CS_VERIFIED) {
|
2017-06-21 22:54:34 +00:00
|
|
|
detailsWindow.endEditMode()
|
|
|
|
manager.saveChangesCloud(true)
|
2021-01-23 18:53:10 +00:00
|
|
|
showPassiveNotification(qsTr("Completed manual sync with cloud\n") + manager.syncState)
|
2017-06-21 22:54:34 +00:00
|
|
|
refreshing = false
|
|
|
|
} else {
|
2019-11-11 21:03:40 +00:00
|
|
|
manager.appendTextToLog("sync with cloud storage requested, but credentialStatus is " + Backend.cloud_verification_status)
|
2019-10-30 08:16:58 +00:00
|
|
|
manager.appendTextToLog("no syncing, turn off spinner")
|
2017-06-22 09:22:21 +00:00
|
|
|
refreshing = false
|
2017-06-21 22:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-10 08:40:30 +00:00
|
|
|
Component {
|
2019-11-11 21:03:40 +00:00
|
|
|
id: diveOrTripDelegate
|
2016-03-08 20:26:54 +00:00
|
|
|
Kirigami.AbstractListItem {
|
2019-10-07 22:29:18 +00:00
|
|
|
// this allows us to access properties of the currentItem from outside
|
|
|
|
property variant myData: model
|
2020-01-09 18:58:05 +00:00
|
|
|
property var view: ListView.view
|
|
|
|
property bool selected: !isTrip && current // don't use 'checked' for this as that confuses QML as it tries
|
2020-04-02 01:05:09 +00:00
|
|
|
property bool invalid: isInvalid === true
|
2019-11-11 21:03:40 +00:00
|
|
|
id: diveOrTripDelegateItem
|
|
|
|
padding: 0
|
2016-03-08 20:26:54 +00:00
|
|
|
supportsMouseEvents: true
|
2019-11-11 21:03:40 +00:00
|
|
|
anchors {
|
2020-12-30 22:03:31 +00:00
|
|
|
left: parent ? parent.left : undefined
|
|
|
|
right: parent ? parent.right : undefined
|
2019-11-11 21:03:40 +00:00
|
|
|
}
|
2020-12-17 22:54:57 +00:00
|
|
|
height: isTrip ? 1 + 8 * Kirigami.Units.smallSpacing : 11 * Kirigami.Units.smallSpacing // delegateInnerItem.height
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2020-01-09 18:58:05 +00:00
|
|
|
onSelectedChanged: {
|
2021-01-13 22:40:10 +00:00
|
|
|
if (selected && index !== view.currentIndex)
|
2020-01-09 18:58:05 +00:00
|
|
|
view.currentIndex = index;
|
|
|
|
}
|
|
|
|
|
2019-11-11 21:03:40 +00:00
|
|
|
// When clicked, a trip expands / unexpands, a dive is opened in DiveDetails
|
2015-11-29 20:13:57 +00:00
|
|
|
onClicked: {
|
2020-01-09 18:58:05 +00:00
|
|
|
view.currentIndex = index
|
2019-11-11 21:03:40 +00:00
|
|
|
if (isTrip) {
|
|
|
|
manager.appendTextToLog("clicked on trip " + tripTitle)
|
|
|
|
// toggle expand (backend to deal with unexpand other trip)
|
2020-03-06 17:06:31 +00:00
|
|
|
diveModel.toggle(model.row);
|
2019-11-11 21:03:40 +00:00
|
|
|
} else {
|
|
|
|
manager.appendTextToLog("clicked on dive")
|
|
|
|
if (detailsWindow.state === "view") {
|
2019-12-06 13:14:00 +00:00
|
|
|
manager.selectRow(model.row);
|
2020-03-26 03:29:05 +00:00
|
|
|
showPage(detailsWindow)
|
2019-11-11 21:03:40 +00:00
|
|
|
}
|
2016-02-14 05:28:32 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
2020-02-21 17:56:21 +00:00
|
|
|
// use this to select a dive without switching to dive details; instead open context drawer
|
|
|
|
onPressAndHold: {
|
|
|
|
view.currentIndex = index
|
2020-02-22 04:44:15 +00:00
|
|
|
manager.appendTextToLog("press and hold on trip or dive; open context drawer")
|
|
|
|
manager.selectRow(model.row)
|
|
|
|
contextDrawer.open()
|
2020-02-21 17:56:21 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2019-11-11 21:03:40 +00:00
|
|
|
// first we look at the trip
|
2017-06-20 16:13:12 +00:00
|
|
|
Item {
|
2019-11-11 21:03:40 +00:00
|
|
|
id: delegateInnerItem
|
|
|
|
width: page.width
|
|
|
|
height: childrenRect.height
|
2017-06-20 16:13:12 +00:00
|
|
|
Rectangle {
|
2019-11-11 21:03:40 +00:00
|
|
|
id: headingBackground
|
|
|
|
height: visible ? 8 * Kirigami.Units.smallSpacing : 0
|
2017-06-20 16:13:12 +00:00
|
|
|
anchors {
|
2019-11-11 21:03:40 +00:00
|
|
|
topMargin: Kirigami.Units.smallSpacing / 2
|
2017-06-20 16:13:12 +00:00
|
|
|
left: parent.left
|
2019-11-11 21:03:40 +00:00
|
|
|
right: parent.right
|
2017-06-20 16:13:12 +00:00
|
|
|
}
|
2019-11-11 21:03:40 +00:00
|
|
|
color: subsurfaceTheme.lightPrimaryColor
|
|
|
|
visible: isTrip
|
|
|
|
Rectangle {
|
|
|
|
id: dateBox
|
2020-12-17 23:04:42 +00:00
|
|
|
height: 1.5 * Kirigami.Units.gridUnit
|
|
|
|
width: 1.8 * Kirigami.Units.gridUnit
|
2019-11-11 21:03:40 +00:00
|
|
|
color: subsurfaceTheme.primaryColor
|
2020-12-17 23:04:42 +00:00
|
|
|
radius: Kirigami.Units.smallSpacing * 1.5
|
2019-11-11 21:03:40 +00:00
|
|
|
antialiasing: true
|
2016-04-02 15:40:54 +00:00
|
|
|
anchors {
|
2019-11-11 21:03:40 +00:00
|
|
|
verticalCenter: parent.verticalCenter
|
2016-04-02 15:40:54 +00:00
|
|
|
left: parent.left
|
2019-11-11 21:03:40 +00:00
|
|
|
leftMargin: Kirigami.Units.smallSpacing
|
2016-04-02 15:40:54 +00:00
|
|
|
}
|
2019-11-06 12:24:31 +00:00
|
|
|
Controls.Label {
|
2019-11-11 21:03:40 +00:00
|
|
|
visible: headingBackground.visible
|
|
|
|
text: visible ? tripShortDate : ""
|
|
|
|
color: subsurfaceTheme.primaryTextColor
|
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize * 0.8
|
|
|
|
lineHeightMode: Text.FixedHeight
|
2020-12-17 23:04:42 +00:00
|
|
|
lineHeight: Kirigami.Units.gridUnit *.6
|
2019-11-11 21:03:40 +00:00
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
height: contentHeight
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
2016-04-02 15:40:54 +00:00
|
|
|
}
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
2017-10-12 12:25:22 +00:00
|
|
|
Controls.Label {
|
2019-11-11 21:03:40 +00:00
|
|
|
text: visible ? tripTitle : ""
|
|
|
|
elide: Text.ElideRight
|
|
|
|
visible: headingBackground.visible
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pointSize: subsurfaceTheme.regularPointSize
|
2018-10-27 07:21:40 +00:00
|
|
|
anchors {
|
|
|
|
verticalCenter: parent.verticalCenter
|
2019-11-11 21:03:40 +00:00
|
|
|
left: dateBox.right
|
2020-11-24 23:55:03 +00:00
|
|
|
leftMargin: dlHorizontalPadding * 2
|
2019-11-11 21:03:40 +00:00
|
|
|
right: parent.right
|
2018-10-27 07:21:40 +00:00
|
|
|
}
|
2019-11-11 21:03:40 +00:00
|
|
|
color: subsurfaceTheme.lightPrimaryTextColor
|
2018-10-27 07:21:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-11 21:03:40 +00:00
|
|
|
|
2018-10-27 07:21:40 +00:00
|
|
|
Rectangle {
|
2019-11-11 21:03:40 +00:00
|
|
|
id: diveBackground
|
|
|
|
height: visible ? diveListEntry.height + Kirigami.Units.smallSpacing : 0
|
2017-06-21 14:01:37 +00:00
|
|
|
anchors {
|
2019-11-11 21:03:40 +00:00
|
|
|
left: parent.left
|
2017-06-21 14:01:37 +00:00
|
|
|
right: parent.right
|
|
|
|
}
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.darkerPrimaryColor : subsurfaceTheme.backgroundColor
|
2019-11-11 21:03:40 +00:00
|
|
|
visible: !isTrip
|
|
|
|
Item {
|
2016-04-02 15:40:54 +00:00
|
|
|
anchors.fill: parent
|
2019-11-11 21:03:40 +00:00
|
|
|
Rectangle {
|
|
|
|
id: leftBarDive
|
|
|
|
width: Kirigami.Units.smallSpacing
|
|
|
|
height: isTopLevel ? 0 : diveListEntry.height * 0.8
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.backgroundColor :subsurfaceTheme.darkerPrimaryColor // reverse of the diveBackground
|
2019-11-11 21:03:40 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
top: parent.top
|
|
|
|
leftMargin: Kirigami.Units.smallSpacing
|
|
|
|
topMargin: Kirigami.Units.smallSpacing * 2
|
|
|
|
bottomMargin: Kirigami.Units.smallSpacing * 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
id: diveListEntry
|
2020-12-17 23:11:20 +00:00
|
|
|
height: visible ? 10 * Kirigami.Units.smallSpacing - 1 : 0
|
2019-11-11 21:03:40 +00:00
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
left: leftBarDive.right
|
|
|
|
verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
Controls.Label {
|
|
|
|
id: locationText
|
|
|
|
text: (undefined !== location && "" != location) ? location : qsTr("<unnamed dive site>")
|
|
|
|
font.weight: Font.Medium
|
2020-04-02 01:05:09 +00:00
|
|
|
font.strikeout: invalid
|
2019-11-11 21:03:40 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1 // needed for elide to work at all
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.textColor
|
2019-11-11 21:03:40 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2020-11-24 23:55:03 +00:00
|
|
|
leftMargin: dlHorizontalPadding * 2
|
2019-11-11 21:03:40 +00:00
|
|
|
topMargin: Kirigami.Units.smallSpacing / 2
|
|
|
|
top: parent.top
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
anchors {
|
|
|
|
left: locationText.left
|
|
|
|
top: locationText.bottom
|
|
|
|
topMargin: Kirigami.Units.smallSpacing / 2
|
|
|
|
}
|
|
|
|
|
|
|
|
Controls.Label {
|
|
|
|
id: dateLabel
|
|
|
|
text: (undefined !== dateTime) ? dateTime : ""
|
|
|
|
width: Math.max(locationText.width * 0.45, paintedWidth) // helps vertical alignment throughout listview
|
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2020-04-02 01:05:09 +00:00
|
|
|
font.strikeout: invalid
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
2019-11-11 21:03:40 +00:00
|
|
|
}
|
|
|
|
// spacer, just in case
|
|
|
|
Controls.Label {
|
|
|
|
text: " "
|
|
|
|
width: Kirigami.Units.largeSpacing
|
|
|
|
}
|
|
|
|
// let's try to show the depth / duration very compact
|
|
|
|
Controls.Label {
|
|
|
|
text: (undefined !== depthDuration) ? depthDuration : ""
|
|
|
|
width: Math.max(Kirigami.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
|
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2020-04-02 01:05:09 +00:00
|
|
|
font.strikeout: invalid
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
2019-11-11 21:03:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Controls.Label {
|
|
|
|
id: numberText
|
|
|
|
text: "#" + number
|
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2020-04-02 01:05:09 +00:00
|
|
|
font.strikeout: invalid
|
2020-01-09 18:58:05 +00:00
|
|
|
color: selected ? subsurfaceTheme.darkerPrimaryTextColor : subsurfaceTheme.secondaryTextColor
|
2019-11-11 21:03:40 +00:00
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
rightMargin: Kirigami.Units.smallSpacing
|
|
|
|
top: locationText.bottom
|
|
|
|
topMargin: Kirigami.Units.smallSpacing / 2
|
|
|
|
}
|
|
|
|
}
|
2016-04-02 15:40:54 +00:00
|
|
|
}
|
2016-04-02 12:49:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-11 21:03:40 +00:00
|
|
|
|
2016-04-02 12:49:28 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-21 05:39:30 +00:00
|
|
|
property alias currentItem: diveListView.currentItem
|
|
|
|
|
|
|
|
property QtObject removeDiveFromTripAction: Kirigami.Action {
|
|
|
|
text: visible ? qsTr ("Remove dive %1 from trip").arg(currentItem.myData.number) : ""
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/chevron_left.svg" }
|
2020-02-22 04:44:15 +00:00
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.diveInTrip === true
|
2020-02-21 05:39:30 +00:00
|
|
|
onTriggered: {
|
|
|
|
manager.removeDiveFromTrip(currentItem.myData.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
property QtObject addDiveToTripAboveAction: Kirigami.Action {
|
|
|
|
text: visible ? qsTr ("Add dive %1 to trip above").arg(currentItem.myData.number) : ""
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/expand_less.svg" }
|
2020-02-22 04:44:15 +00:00
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.tripAbove !== -1
|
2020-02-21 05:39:30 +00:00
|
|
|
onTriggered: {
|
|
|
|
manager.addDiveToTrip(currentItem.myData.id, currentItem.myData.tripAbove)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
property QtObject addDiveToTripBelowAction: Kirigami.Action {
|
|
|
|
text: visible ? qsTr ("Add dive %1 to trip below").arg(currentItem.myData.number) : ""
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/expand_more.svg" }
|
2020-02-22 04:44:15 +00:00
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.tripBelow !== -1
|
2020-02-21 05:39:30 +00:00
|
|
|
onTriggered: {
|
|
|
|
manager.addDiveToTrip(currentItem.myData.id, currentItem.myData.tripBelow)
|
|
|
|
}
|
|
|
|
}
|
2020-03-26 19:12:38 +00:00
|
|
|
property QtObject createTripForDiveAction: Kirigami.Action {
|
|
|
|
text: visible ? qsTr("Create trip with dive %1").arg(currentItem.myData.number) : ""
|
|
|
|
icon { name: ":/icons/list-add" }
|
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.isTopLevel
|
|
|
|
onTriggered: {
|
|
|
|
manager.addTripForDive(currentItem.myData.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 22:59:38 +00:00
|
|
|
property QtObject toggleInvalidAction: Kirigami.Action {
|
|
|
|
text: currentItem && currentItem.myData && currentItem.myData.isInvalid ? qsTr("Mark dive as valid") : qsTr("Mark dive as invalid")
|
|
|
|
// icon: { name: "TBD" }
|
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip
|
|
|
|
onTriggered: manager.toggleDiveInvalid(currentItem.myData.id)
|
|
|
|
}
|
2020-02-21 18:35:44 +00:00
|
|
|
property QtObject deleteAction: Kirigami.Action {
|
|
|
|
text: qsTr("Delete dive")
|
|
|
|
icon { name: ":/icons/trash-empty.svg" }
|
2020-02-22 04:44:15 +00:00
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip
|
2020-02-21 18:35:44 +00:00
|
|
|
onTriggered: manager.deleteDive(currentItem.myData.id)
|
|
|
|
}
|
|
|
|
property QtObject mapAction: Kirigami.Action {
|
|
|
|
text: qsTr("Show on map")
|
|
|
|
icon { name: ":/icons/gps" }
|
2020-02-22 04:44:15 +00:00
|
|
|
visible: currentItem && currentItem.myData && !currentItem.myData.isTrip && currentItem.myData.gps !== ""
|
2020-02-21 18:35:44 +00:00
|
|
|
onTriggered: {
|
|
|
|
showMap()
|
|
|
|
mapPage.centerOnDiveSite(currentItem.myData.diveSite)
|
|
|
|
}
|
|
|
|
}
|
2020-02-22 05:32:40 +00:00
|
|
|
property QtObject tripDetailsEdit: Kirigami.Action {
|
|
|
|
text: qsTr("Edit trip details")
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/trip_details.svg" }
|
2020-02-22 05:32:40 +00:00
|
|
|
visible: currentItem && currentItem.myData && currentItem.myData.isTrip
|
|
|
|
onTriggered: {
|
2020-02-22 22:07:46 +00:00
|
|
|
tripEditWindow.tripId = currentItem.myData.tripId
|
2020-02-22 05:32:40 +00:00
|
|
|
tripEditWindow.tripLocation = currentItem.myData.tripLocation
|
|
|
|
tripEditWindow.tripNotes = currentItem.myData.tripNotes
|
2020-03-26 03:29:05 +00:00
|
|
|
showPage(tripEditWindow)
|
2020-02-22 05:32:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-21 05:39:30 +00:00
|
|
|
property QtObject undoAction: Kirigami.Action {
|
|
|
|
text: qsTr("Undo") + " " + manager.undoText
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/undo.svg" }
|
2020-02-21 05:39:30 +00:00
|
|
|
enabled: manager.undoText !== ""
|
|
|
|
onTriggered: manager.undo()
|
|
|
|
}
|
|
|
|
property QtObject redoAction: Kirigami.Action {
|
|
|
|
text: qsTr("Redo") + " " + manager.redoText
|
2020-02-22 23:23:24 +00:00
|
|
|
icon { name: ":/icons/redo.svg" }
|
2020-02-21 05:39:30 +00:00
|
|
|
enabled: manager.redoText !== ""
|
|
|
|
onTriggered: manager.redo()
|
|
|
|
}
|
2020-03-26 19:12:38 +00:00
|
|
|
property variant contextactions: [ removeDiveFromTripAction, createTripForDiveAction, addDiveToTripAboveAction, addDiveToTripBelowAction, toggleInvalidAction, deleteAction, mapAction, tripDetailsEdit, undoAction, redoAction ]
|
2019-11-11 21:03:40 +00:00
|
|
|
|
2020-03-11 23:54:46 +00:00
|
|
|
function setupActions() {
|
|
|
|
if (Backend.cloud_verification_status === Enums.CS_VERIFIED || Backend.cloud_verification_status === Enums.CS_NOCLOUD) {
|
|
|
|
page.actions.main = page.downloadFromDCAction
|
|
|
|
page.actions.right = page.addDiveAction
|
|
|
|
page.actions.left = page.filterToggleAction
|
|
|
|
page.contextualActions = contextactions
|
|
|
|
page.title = qsTr("Dive list")
|
|
|
|
if (diveListView.count === 0)
|
|
|
|
showPassiveNotification(qsTr("Please tap the '+' button to add a dive (or download dives from a supported dive computer)"), 3000)
|
|
|
|
} else {
|
|
|
|
page.actions.main = null
|
|
|
|
page.actions.right = null
|
|
|
|
page.actions.left = null
|
|
|
|
page.contextualActions = null
|
|
|
|
page.title = qsTr("Cloud credentials")
|
2019-11-11 21:03:40 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
|
|
|
|
2018-09-28 11:44:08 +00:00
|
|
|
Controls.Label {
|
2020-03-29 19:53:01 +00:00
|
|
|
property bool showProcessingText: manager.diveListProcessing
|
2018-09-28 11:44:08 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
2020-03-29 19:53:01 +00:00
|
|
|
text: diveListModel && !showProcessingText ? qsTr("No dives in dive list") : qsTr("Please wait, updating the dive list")
|
2016-06-21 14:53:00 +00:00
|
|
|
visible: diveListView.visible && diveListView.count === 0
|
2020-03-29 19:53:01 +00:00
|
|
|
onShowProcessingTextChanged: {
|
|
|
|
manager.appendTextToLog("============diveListProcessing is " + showProcessingText)
|
|
|
|
}
|
2016-06-21 14:53:00 +00:00
|
|
|
}
|
2019-11-11 21:03:40 +00:00
|
|
|
|
2020-03-29 19:18:24 +00:00
|
|
|
Rectangle {
|
2018-02-04 15:46:03 +00:00
|
|
|
id: filterHeader
|
2020-03-29 19:18:24 +00:00
|
|
|
visible: filterBar.height > 0
|
|
|
|
implicitHeight: filterBar.implicitHeight
|
|
|
|
implicitWidth: filterBar.implicitWidth
|
|
|
|
height: filterBar.height
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
}
|
|
|
|
color: subsurfaceTheme.backgroundColor
|
|
|
|
enabled: rootItem.filterToggle
|
|
|
|
RowLayout {
|
|
|
|
id: filterBar
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "isVisible"
|
|
|
|
when: rootItem.filterToggle
|
|
|
|
PropertyChanges { target: filterBar; height: sitefilter.implicitHeight }
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "isHidden"
|
|
|
|
when: !rootItem.filterToggle
|
|
|
|
PropertyChanges { target: filterBar; height: 0 }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
transitions: [
|
|
|
|
Transition { NumberAnimation { property: "height"; duration: 400; easing.type: Easing.InOutQuad }}
|
|
|
|
]
|
2018-10-20 10:00:20 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2020-03-29 19:18:24 +00:00
|
|
|
anchors.leftMargin: Kirigami.Units.gridUnit / 2
|
|
|
|
anchors.rightMargin: Kirigami.Units.gridUnit / 2
|
2021-01-11 17:59:43 +00:00
|
|
|
TemplateSlimComboBox {
|
2020-03-29 19:18:24 +00:00
|
|
|
visible: filterBar.height === sitefilter.implicitHeight
|
|
|
|
id: sitefilterMode
|
|
|
|
model: ListModel {
|
|
|
|
ListElement {text: qsTr("Fulltext")}
|
|
|
|
ListElement {text: qsTr("People")}
|
|
|
|
ListElement {text: qsTr("Tags")}
|
2020-02-19 20:39:23 +00:00
|
|
|
}
|
2020-03-29 19:18:24 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
|
|
|
Layout.maximumWidth: parent.width * 0.3
|
|
|
|
onActivated: {
|
|
|
|
manager.setFilter(sitefilter.text, currentIndex)
|
2018-10-18 10:46:50 +00:00
|
|
|
}
|
2020-03-29 19:18:24 +00:00
|
|
|
}
|
2020-12-21 01:14:01 +00:00
|
|
|
TemplateTextField {
|
2020-03-29 19:18:24 +00:00
|
|
|
id: sitefilter
|
|
|
|
verticalAlignment: TextInput.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
text: ""
|
|
|
|
placeholderText: sitefilterMode.currentText
|
2020-12-21 01:14:01 +00:00
|
|
|
placeholderTextColor: subsurfaceTheme.secondaryTextColor
|
2020-03-29 19:18:24 +00:00
|
|
|
onAccepted: {
|
|
|
|
manager.setFilter(text, sitefilterMode.currentIndex)
|
2018-10-20 10:02:15 +00:00
|
|
|
}
|
2020-03-31 17:19:24 +00:00
|
|
|
onVisibleChanged: {
|
2020-03-29 19:18:24 +00:00
|
|
|
// reset the filter when it gets toggled
|
|
|
|
text = ""
|
|
|
|
if (visible) {
|
|
|
|
forceActiveFocus()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-12-21 01:14:01 +00:00
|
|
|
TemplateLabel {
|
2020-03-29 19:18:24 +00:00
|
|
|
id: numShown
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
text: diveModel.shown
|
2018-10-17 10:28:53 +00:00
|
|
|
}
|
2018-10-20 10:00:20 +00:00
|
|
|
}
|
2018-02-04 15:46:03 +00:00
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
ListView {
|
|
|
|
id: diveListView
|
2020-03-29 19:18:24 +00:00
|
|
|
topMargin: filterHeader.height
|
2015-07-10 08:40:30 +00:00
|
|
|
anchors.fill: parent
|
2019-11-06 23:17:34 +00:00
|
|
|
model: diveListModel
|
2016-03-08 20:26:54 +00:00
|
|
|
currentIndex: -1
|
2019-11-11 21:03:40 +00:00
|
|
|
delegate: diveOrTripDelegate
|
2017-06-28 17:55:19 +00:00
|
|
|
boundsBehavior: Flickable.DragOverBounds
|
2016-03-08 20:26:54 +00:00
|
|
|
maximumFlickVelocity: parent.height * 5
|
|
|
|
bottomMargin: Kirigami.Units.iconSizes.medium + Kirigami.Units.gridUnit
|
2020-04-02 01:14:48 +00:00
|
|
|
cacheBuffer: 0
|
2019-11-11 21:03:40 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
manager.appendTextToLog("finished setting up the diveListView")
|
2016-03-08 20:26:54 +00:00
|
|
|
}
|
2020-04-01 18:55:15 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible)
|
|
|
|
setupActions()
|
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
2016-02-14 05:09:33 +00:00
|
|
|
|
2017-06-28 04:45:17 +00:00
|
|
|
property QtObject downloadFromDCAction: Kirigami.Action {
|
2018-01-02 16:02:19 +00:00
|
|
|
icon {
|
2018-04-17 00:28:53 +00:00
|
|
|
name: ":/icons/downloadDC"
|
2017-11-19 18:27:45 +00:00
|
|
|
color: subsurfaceTheme.primaryColor
|
2018-01-02 16:02:19 +00:00
|
|
|
}
|
2018-10-03 07:54:49 +00:00
|
|
|
text: qsTr("Download dives")
|
2017-06-28 04:45:17 +00:00
|
|
|
onTriggered: {
|
2020-03-09 17:46:17 +00:00
|
|
|
rootItem.showDownloadPage()
|
2017-06-28 04:45:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-31 14:15:14 +00:00
|
|
|
property QtObject addDiveAction: Kirigami.Action {
|
2018-01-02 16:02:19 +00:00
|
|
|
icon {
|
2018-04-17 00:28:53 +00:00
|
|
|
name: ":/icons/list-add"
|
2018-01-02 16:02:19 +00:00
|
|
|
}
|
2020-12-21 21:57:10 +00:00
|
|
|
color: subsurfaceTheme.textColor
|
2018-10-03 07:54:49 +00:00
|
|
|
text: qsTr("Add dive")
|
2016-04-02 03:31:33 +00:00
|
|
|
onTriggered: {
|
|
|
|
startAddDive()
|
|
|
|
}
|
|
|
|
}
|
2016-03-08 20:26:54 +00:00
|
|
|
|
2018-02-04 15:46:03 +00:00
|
|
|
property QtObject filterToggleAction: Kirigami.Action {
|
|
|
|
icon {
|
|
|
|
name: ":icons/ic_filter_list"
|
|
|
|
}
|
2020-12-21 21:57:10 +00:00
|
|
|
color: subsurfaceTheme.textColor
|
2018-02-04 15:46:03 +00:00
|
|
|
text: qsTr("Filter dives")
|
|
|
|
onTriggered: {
|
|
|
|
rootItem.filterToggle = !rootItem.filterToggle
|
2020-02-19 20:39:23 +00:00
|
|
|
manager.setFilter("", 0)
|
2020-03-29 19:27:09 +00:00
|
|
|
if (rootItem.filterToggle)
|
|
|
|
Qt.inputMethod.show()
|
|
|
|
else
|
|
|
|
Qt.inputMethod.hide()
|
2018-02-04 15:46:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-14 05:09:33 +00:00
|
|
|
onBackRequested: {
|
2019-11-11 21:03:40 +00:00
|
|
|
if (startPage.visible && diveListView.count > 0 &&
|
2020-11-24 18:52:05 +00:00
|
|
|
Backend.cloud_verification_status !== Enums.CS_INCORRECT_USER_PASSWD) {
|
2019-11-11 21:03:40 +00:00
|
|
|
Backend.cloud_verification_status = oldStatus
|
|
|
|
event.accepted = true;
|
|
|
|
}
|
|
|
|
if (!startPage.visible) {
|
2020-03-30 16:43:18 +00:00
|
|
|
if (globalDrawer.visible) {
|
|
|
|
globalDrawer.close()
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
if (contextDrawer.visible) {
|
|
|
|
contextDrawer.close()
|
|
|
|
event.accepted = true
|
|
|
|
}
|
|
|
|
if (event.accepted === false && Qt.platform.os !== "ios") {
|
2019-11-11 21:03:40 +00:00
|
|
|
manager.quit()
|
|
|
|
}
|
|
|
|
// let's make sure Kirigami doesn't quit on our behalf
|
|
|
|
event.accepted = true
|
|
|
|
}
|
2016-02-14 05:09:33 +00:00
|
|
|
}
|
2018-03-08 19:49:24 +00:00
|
|
|
|
|
|
|
function setCurrentDiveListIndex(idx, noScroll) {
|
2019-10-07 22:29:18 +00:00
|
|
|
// pick the dive in the dive list and make sure its trip is expanded
|
2018-03-08 19:49:24 +00:00
|
|
|
diveListView.currentIndex = idx
|
2019-11-06 23:17:34 +00:00
|
|
|
if (diveListModel)
|
|
|
|
diveListModel.setActiveTrip(diveListView.currentItem.myData.tripId)
|
2019-10-07 22:29:18 +00:00
|
|
|
|
2018-03-08 19:49:24 +00:00
|
|
|
// updating the index of the ListView triggers a non-linear scroll
|
|
|
|
// animation that can be very slow. the fix is to stop this animation
|
|
|
|
// by setting contentY to itself and then using positionViewAtIndex().
|
|
|
|
// the downside is that the view jumps to the index immediately.
|
|
|
|
if (noScroll) {
|
|
|
|
diveListView.contentY = diveListView.contentY
|
|
|
|
diveListView.positionViewAtIndex(idx, ListView.Center)
|
|
|
|
}
|
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|