summaryrefslogtreecommitdiffstats
path: root/qt-mobile/main.qml
blob: ab147a2b42f99137ce9db0cbf9bb18d4211d5326 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import org.subsurfacedivelog.mobile 1.0

ApplicationWindow {
	title: qsTr("Subsurface")
	width: 500;
	height: 700

	FileDialog {
		id: fileOpen
		selectExisting: true
		selectMultiple: true

		onAccepted: {
			manager.setFilename(fileUrl)
		}
	}

	QMLManager {
		id: manager
	}

	menuBar: MenuBar {
		Menu {
			title: qsTr("File")
			MenuItem {
				text: qsTr("Open")
				onTriggered: fileOpen.open()
			}

			MenuItem {
				text: qsTr("Exit")
				onTriggered: Qt.quit();
			}
		}
	}

	Rectangle {
		width: parent.width; height: parent.height
		anchors.fill: parent

		Component {
			id: diveDelegate
			Item {
				id: wrapper
				width: parent.width; height: 55
				Column {
					Text { text: '#:' + diveNumber + "(" + location + ")"  }
					Text { text: date }
					Text { text: duration + " " + depth }
				}
				MouseArea { anchors.fill: parent; onClicked: diveListView.currentIndex = index }

				states: State {
					name: "Current"
					when: wrapper.ListView.isCurrentItem
					PropertyChanges { target: wrapper; x:20 }
				}
				transitions: Transition {
					NumberAnimation { properties: "x"; duration: 200  }
				}
			}
		}

		Component {
			id: highlightBar
			Rectangle {
				width: parent.width; height: 50
				color: "#FFFF88"
				y: diveListView.currentItem.y;
				Behavior on y {  SpringAnimation  { spring: 2; damping: 0.1 } }
			}
		}

		ListView {
			id: diveListView
			width: parent.width; height: parent.height
			anchors.fill: parent
			model: diveModel
			delegate: diveDelegate
			focus: true
			highlight: highlightBar
			highlightFollowsCurrentItem: false
		}
	}
}