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
|
|
|
|
|
|
|
Component {
|
|
|
|
id: diveDelegate
|
2015-11-29 20:13:57 +00:00
|
|
|
MobileComponents.ListItem {
|
|
|
|
enabled: true
|
|
|
|
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-01-29 18:17:22 +00:00
|
|
|
diveListView.currentIndex = index
|
2016-01-12 00:15:02 +00:00
|
|
|
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
|
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-10-09 03:05:23 +00:00
|
|
|
opacity: 0.6
|
2015-11-29 18:21:27 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
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: '
|
|
|
|
opacity: 0.6
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
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
|
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: '
|
|
|
|
opacity: 0.6
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
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
|
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 16:30:41 +00:00
|
|
|
color: MobileComponents.Theme.textColor
|
2015-11-29 22:39:14 +00:00
|
|
|
font.pointSize: subsurfaceTheme.smallPointSize
|
|
|
|
opacity: 0.6
|
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-01-21 20:42:16 +00:00
|
|
|
height: childrenRect.height + MobileComponents.Units.smallSpacing * 2 + Math.max(2, MobileComponents.Units.gridUnit / 2)
|
2015-07-10 08:40:30 +00:00
|
|
|
|
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
|
|
|
|
}
|
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 {
|
|
|
|
top: sectionText.bottom
|
|
|
|
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: {
|
|
|
|
if (stackView.depth == 1) {
|
|
|
|
diveListView.currentIndex = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-12 00:15:02 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
ScrollView {
|
2015-07-10 08:40:30 +00:00
|
|
|
anchors.fill: parent
|
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-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"
|
|
|
|
opacity: 0.8 - startPage.opacity
|
|
|
|
visible: opacity > 0
|
|
|
|
}
|
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
|
|
|
}
|
2015-11-07 00:45:40 +00:00
|
|
|
StartPage {
|
2015-12-08 00:10:56 +00:00
|
|
|
id: startPage
|
2015-11-07 00:45:40 +00:00
|
|
|
anchors.fill: parent
|
2015-11-07 23:46:36 +00:00
|
|
|
opacity: (diveListView.count == 0) ? 1.0 : 0
|
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 } }
|
2015-11-07 00:45:40 +00:00
|
|
|
}
|
2015-07-10 08:40:30 +00:00
|
|
|
}
|