Bump version to 0.2.2
[harbour-pedalo.git] / qml / pages / Stats.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import harbour.pedalo.graph 1.0
4 import "../components"
5
6 Page {
7     id: statsPage
8
9     // The effective value will be restricted by ApplicationWindow.allowedOrientations
10     allowedOrientations: Orientation.All
11     property int showingindex: 0
12
13     SilicaFlickable {
14         id: statsView
15         anchors.fill: parent
16         contentHeight: statsColumn.implicitHeight + headerItem.height
17
18         VerticalScrollDecorator {}
19
20         PageHeader {
21             id: headerItem
22             title: qsTr("Stats")
23         }
24
25         Column {
26             id: statsColumn
27             spacing: Theme.paddingLarge
28             width: isPortrait ? parent.width : parent.width * 0.5
29             y: headerItem.height
30
31             InfoRow {
32                 label: qsTr("Journeys:")
33                 value: currentStatus.getJourneyCount()
34                 midlineRatio: 0.7
35                 midlineMin: Theme.fontSizeSmall * 10
36                 midlineMax: Theme.fontSizeSmall * 20
37                 pixelSize: Theme.fontSizeMedium
38                 labelTextBold: true
39                 horizontalAlignment: Text.AlignRight
40             }
41
42             InfoRow {
43                 label: qsTr("Time spent cycling:")
44                 value: currentStatus.getFormattedTime(currentStatus.getTimeSpentCycling(), 0, 5)
45                 midlineRatio: 0.5
46                 midlineMin: Theme.fontSizeSmall * 10
47                 midlineMax: Theme.fontSizeSmall * 20
48                 pixelSize: Theme.fontSizeMedium
49                 labelTextBold: true
50                 horizontalAlignment: Text.AlignRight
51             }
52
53             InfoRow {
54                 label: qsTr("Average journey duration:")
55                 value: currentStatus.getFormattedTime(currentStatus.getAverageDuration(), 1, 5)
56                 midlineRatio: 0.6
57                 midlineMin: Theme.fontSizeSmall * 10
58                 midlineMax: Theme.fontSizeSmall * 20
59                 pixelSize: Theme.fontSizeMedium
60                 labelTextBold: true
61                 horizontalAlignment: Text.AlignRight
62             }
63
64             InfoRow {
65                 label: qsTr("Speed percentile:")
66                 value: Math.round(100.0 - currentStatus.getSpeedPercentile() * 100) + "%"
67                 midlineRatio: 0.7
68                 midlineMin: Theme.fontSizeSmall * 10
69                 midlineMax: Theme.fontSizeSmall * 20
70                 pixelSize: Theme.fontSizeMedium
71                 labelTextBold: true
72                 horizontalAlignment: Text.AlignRight
73             }
74         }
75
76         SlideshowView {
77             id: graphsView
78             width: isPortrait ? parent.width : parent.width * 0.5
79             height: (isPortrait ? statsPage.height / 2.0 : statsPage.height) - Theme.paddingLarge
80             itemWidth: width
81             clip: true
82             anchors.left: isPortrait ? statsColumn.left : statsColumn.right
83             anchors.leftMargin: 0
84
85             y: (isPortrait ? (statsPage.height / 2.0) : statsColumn.y)
86
87             onModelChanged: {
88                 console.log("Model changed");
89                 model.updateAll();
90             }
91
92             model: statsmodel
93             delegate: Item {
94                 id: delegateItem
95                 width: graphsView.itemWidth
96                 height: graphsView.height
97
98                 SectionHeader {
99                     id: sectionHeaderItem
100                     text: title
101                 }
102
103                 Graph {
104                     id: graph
105                     width: parent.width - Theme.horizontalPageMargin
106                     anchors.top: sectionHeaderItem.bottom
107                     height: (isPortrait ? (statsPage.height / 2.0) - Theme.paddingLarge : statsPage.height - Theme.paddingLarge - headerItem.height) - sectionHeaderItem.height
108                     anchors.left: parent.left
109                     bardata: barvalues
110                     linedata: linevalues
111                     labelsx: labels
112                     //labelsy: ["0%", "10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "100%"]
113                     unitsy: units
114                     primary: Theme.primaryColor
115                     secondary: Theme.highlightColor
116                     highlight: Theme.secondaryColor
117                     miny: minval
118                     maxy: maxval
119                     stepy: step
120                     gap: 0.1
121                     fontsize: Theme.fontSizeExtraSmall
122                     animate: (graphsView.currentItem === delegateItem) ? 1.0 : 0.0
123
124                     Behavior on animate {
125                         NumberAnimation {
126                             easing.type: Easing.OutExpo
127                             duration: 2000
128                         }
129                     }
130                 }
131             }
132         }
133     }
134 }