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
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
//When clicked, the mode changes to details view
|
2015-07-10 08:40:30 +00:00
|
|
|
|
2015-11-29 20:13:57 +00:00
|
|
|
onClicked: {
|
|
|
|
diveListView.currentIndex = model.index
|
|
|
|
detailsWindow.width = parent.width
|
2016-01-07 18:01:24 +00:00
|
|
|
detailsWindow.location = dive.location
|
|
|
|
detailsWindow.gps = dive.gps
|
|
|
|
detailsWindow.dive_id = dive.id
|
|
|
|
detailsWindow.diveNumber = dive.number
|
|
|
|
detailsWindow.duration = dive.duration
|
|
|
|
detailsWindow.depth = dive.depth
|
|
|
|
detailsWindow.rating = dive.rating
|
|
|
|
detailsWindow.buddy = dive.buddy
|
|
|
|
detailsWindow.suit = dive.suit
|
|
|
|
detailsWindow.airtemp = dive.airTemp
|
|
|
|
detailsWindow.watertemp = dive.waterTemp
|
|
|
|
detailsWindow.divemaster = dive.divemaster
|
|
|
|
detailsWindow.notes = dive.notes
|
|
|
|
detailsWindow.number = dive.number
|
2016-01-11 06:06:25 +00:00
|
|
|
detailsWindow.date = dive.date + " " + dive.time
|
2016-01-07 18:01:24 +00:00
|
|
|
// detailsWindow.weight = dive.weights
|
2015-11-29 20:13:57 +00:00
|
|
|
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
|
2015-11-29 16:30:41 +00:00
|
|
|
height: childrenRect.height + MobileComponents.Units.smallSpacing * 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
|
2015-07-10 08:40:30 +00:00
|
|
|
text: section
|
2015-10-09 01:56:36 +00:00
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
left: parent.left
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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
|
|
|
|
cacheBuffer: parent.height * 5
|
2015-11-29 20:13:57 +00:00
|
|
|
//highlight: Rectangle { color: MobileComponents.Theme.highlightColor; width: MobileComponents.Units.smallSpacing }
|
|
|
|
focus: true
|
|
|
|
clip: true
|
|
|
|
section.property: "trip"
|
|
|
|
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
|
|
|
|
}
|
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
|
|
|
}
|