2015-11-29 16:30:41 +00:00
|
|
|
import QtQuick 2.4
|
2015-07-10 08:40:30 +00:00
|
|
|
import QtQuick.Controls 1.2
|
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
|
2015-11-29 16:30:41 +00:00
|
|
|
import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
|
2015-07-10 08:40:30 +00:00
|
|
|
import org.subsurfacedivelog.mobile 1.0
|
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.Page {
|
2015-07-10 08:40:30 +00:00
|
|
|
id: page
|
2015-08-20 08:44:01 +00:00
|
|
|
objectName: "DiveList"
|
2015-11-29 20:13:57 +00:00
|
|
|
color: MobileComponents.Theme.viewBackgroundColor
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2016-02-11 02:09:16 +00:00
|
|
|
property int credentialStatus: manager.credentialStatus
|
|
|
|
property int numDives: diveListView.count
|
2016-03-22 18:36:11 +00:00
|
|
|
property color textColor: subsurfaceTheme.diveListTextColor
|
2015-07-10 08:40:30 +00:00
|
|
|
Component {
|
|
|
|
id: diveDelegate
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.ListItem {
|
|
|
|
enabled: true
|
2016-02-07 21:23:08 +00:00
|
|
|
checked: diveListView.currentIndex === model.index
|
2015-12-27 20:28:08 +00:00
|
|
|
width: parent.width
|
2015-07-10 08:40:30 +00:00
|
|
|
|
|
|
|
property real detailsOpacity : 0
|
2015-12-08 02:27:47 +00:00
|
|
|
property int horizontalPadding: MobileComponents.Units.gridUnit / 2 - MobileComponents.Units.smallSpacing + 1
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2016-01-12 00:15:02 +00:00
|
|
|
// When clicked, the mode changes to details view
|
2015-11-29 20:13:57 +00:00
|
|
|
onClicked: {
|
2016-02-14 05:28:32 +00:00
|
|
|
if (detailsWindow.state === "view") {
|
|
|
|
diveListView.currentIndex = index
|
|
|
|
detailsWindow.showDiveIndex(index);
|
|
|
|
stackView.push(detailsWindow);
|
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
|
|
|
|
2015-10-09 03:05:23 +00:00
|
|
|
Item {
|
2015-12-08 00:10:56 +00:00
|
|
|
width: parent.width - MobileComponents.Units.gridUnit
|
2015-11-29 22:39:14 +00:00
|
|
|
height: childrenRect.height - MobileComponents.Units.smallSpacing
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2015-10-09 03:05:23 +00:00
|
|
|
id: locationText
|
2016-01-07 18:01:24 +00:00
|
|
|
text: dive.location
|
2015-11-29 22:39:14 +00:00
|
|
|
font.weight: Font.Light
|
2015-11-12 01:13:47 +00:00
|
|
|
elide: Text.ElideRight
|
|
|
|
maximumLineCount: 1 // needed for elide to work at all
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2015-12-08 02:27:47 +00:00
|
|
|
leftMargin: horizontalPadding
|
2015-10-09 03:05:23 +00:00
|
|
|
top: parent.top
|
2015-11-12 01:13:47 +00:00
|
|
|
right: dateLabel.left
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2015-11-12 01:13:47 +00:00
|
|
|
id: dateLabel
|
2016-01-11 06:06:25 +00:00
|
|
|
text: dive.date + " " + dive.time
|
2015-11-29 18:21:27 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
top: parent.top
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Row {
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
2015-12-08 02:27:47 +00:00
|
|
|
leftMargin: horizontalPadding
|
2015-10-09 03:05:23 +00:00
|
|
|
right: parent.right
|
2015-12-08 02:27:47 +00:00
|
|
|
rightMargin: horizontalPadding
|
2015-10-09 03:05:23 +00:00
|
|
|
bottom: numberText.bottom
|
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2015-10-09 03:05:23 +00:00
|
|
|
text: 'Depth: '
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2016-01-07 18:01:24 +00:00
|
|
|
text: dive.depth
|
2015-11-29 16:30:41 +00:00
|
|
|
width: Math.max(MobileComponents.Units.gridUnit * 3, paintedWidth) // helps vertical alignment throughout listview
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2015-10-09 03:05:23 +00:00
|
|
|
text: 'Duration: '
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2016-01-07 18:01:24 +00:00
|
|
|
text: dive.duration
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-29 22:39:14 +00:00
|
|
|
MobileComponents.Label {
|
2015-10-09 03:05:23 +00:00
|
|
|
id: numberText
|
2016-01-08 21:07:00 +00:00
|
|
|
text: "#" + dive.number
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-10-09 03:05:23 +00:00
|
|
|
anchors {
|
|
|
|
right: parent.right
|
|
|
|
top: locationText.bottom
|
|
|
|
}
|
2015-10-09 01:56:36 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: tripHeading
|
2015-10-09 01:56:36 +00:00
|
|
|
Item {
|
2015-12-08 00:10:56 +00:00
|
|
|
width: page.width - MobileComponents.Units.gridUnit
|
2016-03-31 01:16:50 +00:00
|
|
|
height: childrenRect.height + MobileComponents.Units.smallSpacing * 2 + Math.max(2, MobileComponents.Units.gridUnit / 2)
|
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.Heading {
|
2015-10-09 01:56:36 +00:00
|
|
|
id: sectionText
|
2016-01-27 04:06:30 +00:00
|
|
|
text: {
|
|
|
|
// if the tripMeta (which we get as "section") ends in ::-- we know
|
|
|
|
// that there's no trip -- otherwise strip the meta information before
|
|
|
|
// the :: and show the trip location
|
|
|
|
var shownText
|
|
|
|
var endsWithDoubleDash = /::--$/;
|
2016-01-29 05:58:27 +00:00
|
|
|
if (endsWithDoubleDash.test(section) || section === "--") {
|
2016-01-27 04:06:30 +00:00
|
|
|
shownText = ""
|
|
|
|
} else {
|
|
|
|
shownText = section.replace(/.*::/, "")
|
|
|
|
}
|
|
|
|
shownText
|
|
|
|
}
|
2015-10-09 01:56:36 +00:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
2016-01-21 20:42:16 +00:00
|
|
|
topMargin: Math.max(2, MobileComponents.Units.gridUnit / 2)
|
2015-12-08 00:10:56 +00:00
|
|
|
leftMargin: MobileComponents.Units.gridUnit / 2
|
2015-10-09 01:56:36 +00:00
|
|
|
right: parent.right
|
|
|
|
}
|
2016-03-31 01:16:50 +00:00
|
|
|
color: textColor
|
2015-11-29 20:13:57 +00:00
|
|
|
level: 2
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
2015-10-09 01:56:36 +00:00
|
|
|
Rectangle {
|
2015-11-29 16:30:41 +00:00
|
|
|
height: Math.max(2, MobileComponents.Units.gridUnit / 12) // we want a thicker line
|
2015-10-09 01:56:36 +00:00
|
|
|
anchors {
|
2016-03-31 01:16:50 +00:00
|
|
|
top: sectionText.bottom
|
2015-10-09 01:56:36 +00:00
|
|
|
left: parent.left
|
2015-12-08 02:10:03 +00:00
|
|
|
leftMargin: MobileComponents.Units.gridUnit * -2
|
|
|
|
rightMargin: MobileComponents.Units.gridUnit * -2
|
2015-10-09 01:56:36 +00:00
|
|
|
right: parent.right
|
|
|
|
}
|
2015-11-29 18:21:27 +00:00
|
|
|
color: subsurfaceTheme.accentColor
|
2015-10-09 01:56:36 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
Connections {
|
|
|
|
target: stackView
|
|
|
|
onDepthChanged: {
|
2016-02-07 21:23:08 +00:00
|
|
|
if (stackView.depth === 1) {
|
2015-11-29 20:13:57 +00:00
|
|
|
diveListView.currentIndex = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-12 00:15:02 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
ScrollView {
|
2016-02-11 02:09:16 +00:00
|
|
|
id: outerScrollView
|
2015-07-10 08:40:30 +00:00
|
|
|
anchors.fill: parent
|
2016-02-11 14:55:27 +00:00
|
|
|
opacity: 0.8 - startPageWrapper.opacity
|
2016-02-11 02:09:16 +00:00
|
|
|
visible: opacity > 0
|
2015-11-29 20:13:57 +00:00
|
|
|
ListView {
|
|
|
|
id: diveListView
|
|
|
|
anchors.fill: parent
|
|
|
|
model: diveModel
|
|
|
|
currentIndex: -1
|
|
|
|
delegate: diveDelegate
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2016-01-06 02:48:51 +00:00
|
|
|
maximumFlickVelocity: parent.height * 5
|
2016-02-11 20:43:32 +00:00
|
|
|
bottomMargin: MobileComponents.Units.iconSizes.medium + MobileComponents.Units.gridUnit
|
2016-01-13 02:01:46 +00:00
|
|
|
cacheBuffer: 0 // seems to avoid empty rendered profiles
|
2016-01-27 04:06:30 +00:00
|
|
|
section.property: "dive.tripMeta"
|
2015-11-29 20:13:57 +00:00
|
|
|
section.criteria: ViewSection.FullString
|
|
|
|
section.delegate: tripHeading
|
2015-12-08 00:10:56 +00:00
|
|
|
header: MobileComponents.Heading {
|
|
|
|
x: MobileComponents.Units.gridUnit / 2
|
2015-12-08 02:10:03 +00:00
|
|
|
height: paintedHeight + MobileComponents.Units.gridUnit / 2
|
|
|
|
verticalAlignment: Text.AlignBottom
|
2015-12-08 00:10:56 +00:00
|
|
|
text: "Dive Log"
|
2016-03-22 18:36:11 +00:00
|
|
|
color: textColor
|
2015-12-08 00:10:56 +00:00
|
|
|
}
|
2016-01-13 02:01:46 +00:00
|
|
|
Connections {
|
|
|
|
target: detailsWindow
|
|
|
|
onCurrentIndexChanged: diveListView.currentIndex = detailsWindow.currentIndex
|
|
|
|
}
|
2015-11-29 20:13:57 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|
2016-02-14 05:09:33 +00:00
|
|
|
|
|
|
|
property QtObject saveAction: Action {
|
|
|
|
iconName: "document-save"
|
|
|
|
onTriggered: {
|
|
|
|
startPage.saveCredentials();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onBackRequested: {
|
2016-02-14 20:17:24 +00:00
|
|
|
if (startPageWrapper.visible && diveListView.count > 0 && manager.credentialStatus != QMLManager.INVALID) {
|
2016-02-14 05:09:33 +00:00
|
|
|
manager.credentialStatus = oldStatus
|
2016-02-14 20:17:24 +00:00
|
|
|
event.accepted = true;
|
2016-02-14 05:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 14:55:27 +00:00
|
|
|
ScrollView {
|
|
|
|
id: startPageWrapper
|
2015-11-07 00:45:40 +00:00
|
|
|
anchors.fill: parent
|
2016-02-12 06:46:00 +00:00
|
|
|
opacity: (diveListView.count > 0 && (credentialStatus == QMLManager.VALID || credentialStatus == QMLManager.VALID_EMAIL)) ? 0 : 1
|
2015-11-07 23:05:31 +00:00
|
|
|
visible: opacity > 0
|
2015-11-29 16:30:41 +00:00
|
|
|
Behavior on opacity { NumberAnimation { duration: MobileComponents.Units.shortDuration } }
|
2016-02-14 05:09:33 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
page.mainAction = page.saveAction
|
2016-03-31 01:38:51 +00:00
|
|
|
showingDiveList = false
|
2016-02-14 05:09:33 +00:00
|
|
|
} else {
|
|
|
|
page.mainAction = null
|
2016-03-31 01:38:51 +00:00
|
|
|
showingDiveList = true
|
2016-02-14 05:09:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-11 14:55:27 +00:00
|
|
|
StartPage {
|
2016-02-14 05:09:33 +00:00
|
|
|
id: startPage
|
2016-02-11 14:55:27 +00:00
|
|
|
}
|
2015-11-07 00:45:40 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|