~ubuntu-clock-dev/ubuntu-clock-app/trunk

« back to all changes in this revision

Viewing changes to app/stopwatch/LapListView.qml

  • Committer: Tarmac
  • Author(s): Nekhelesh Ramananthan, Bartosz Kosiorek, Victor Thompson
  • Date: 2015-08-20 21:00:13 UTC
  • mfrom: (315.3.65 stopwatch-feature)
  • Revision ID: tarmac-20150820210013-z604hoot1qu5bu0p
Implement the new stopwatch feature. Fixes: https://bugs.launchpad.net/bugs/1437313.

Approved by Ubuntu Phone Apps Jenkins Bot, Bartosz Kosiorek.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2015 Canonical Ltd
 
3
 *
 
4
 * This file is part of Ubuntu Clock App
 
5
 *
 
6
 * Ubuntu Clock App is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License version 3 as
 
8
 * published by the Free Software Foundation.
 
9
 *
 
10
 * Ubuntu Clock App is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
import QtQuick 2.4
 
20
import QtQuick.Layouts 1.1
 
21
import Ubuntu.Components 1.2
 
22
 
 
23
ListView {
 
24
    id: lapListView
 
25
 
 
26
    clip: true
 
27
 
 
28
    StopwatchUtils {
 
29
        id: stopwatchUtils
 
30
    }
 
31
 
 
32
    header: ListItem {
 
33
        visible: count !== 0
 
34
        Row {
 
35
            anchors {
 
36
                left: parent.left
 
37
                right: parent.right
 
38
                verticalCenter: parent.verticalCenter
 
39
                margins: units.gu(2)
 
40
            }
 
41
 
 
42
            Label {
 
43
                // #TRANSLATORS: This refers to the stopwatch lap and is shown as a header where space is limited. Constrain
 
44
                // translation length to a few characters.
 
45
                text: i18n.tr("Lap")
 
46
                width: parent.width / 7
 
47
                elide: Text.ElideRight
 
48
                font.weight: Font.DemiBold
 
49
                horizontalAlignment: Text.AlignHCenter
 
50
            }
 
51
 
 
52
            Label {
 
53
                width: 3 * parent.width / 7
 
54
                elide: Text.ElideRight
 
55
                text: i18n.tr("Lap Time")
 
56
                font.weight: Font.DemiBold
 
57
                horizontalAlignment: Text.AlignHCenter
 
58
            }
 
59
 
 
60
            Label {
 
61
                width: 3 * parent.width / 7
 
62
                elide: Text.ElideRight
 
63
                text: i18n.tr("Total Time")
 
64
                font.weight: Font.DemiBold
 
65
                horizontalAlignment: Text.AlignHCenter
 
66
            }
 
67
        }
 
68
    }
 
69
 
 
70
    displaced: Transition {
 
71
        UbuntuNumberAnimation {
 
72
            property: "y"
 
73
            duration: UbuntuAnimation.BriskDuration
 
74
        }
 
75
    }
 
76
 
 
77
    delegate: ListItem {
 
78
        divider.visible: true
 
79
        leadingActions: ListItemActions {
 
80
            actions: [
 
81
                Action {
 
82
                    iconName: "delete"
 
83
                    onTriggered: {
 
84
                        lapHistory.removeLap(index)
 
85
                    }
 
86
                }
 
87
            ]
 
88
        }
 
89
 
 
90
        Row {
 
91
            anchors {
 
92
                left: parent.left
 
93
                right: parent.right
 
94
                verticalCenter: parent.verticalCenter
 
95
                margins: units.gu(2)
 
96
            }
 
97
 
 
98
            Label {
 
99
                color: UbuntuColors.midAubergine
 
100
                text: "#%1".arg(Number(count - index).toLocaleString(Qt.locale(), "f", 0))
 
101
                width: parent.width / 7
 
102
                horizontalAlignment: Text.AlignHCenter
 
103
            }
 
104
 
 
105
            Item {
 
106
                width: 3 * parent.width / 7
 
107
                height: childrenRect.height
 
108
                Row {
 
109
                    anchors.horizontalCenter: parent.horizontalCenter
 
110
                    Label {
 
111
                        text: stopwatchUtils.lapTimeToString(model.laptime) + "."
 
112
                    }
 
113
                    Label {
 
114
                        fontSize: "x-small"
 
115
                        text: stopwatchUtils.millisToString(model.laptime)
 
116
                        anchors.bottom: parent.bottom
 
117
                        anchors.bottomMargin: units.dp(1)
 
118
                    }
 
119
                }
 
120
            }
 
121
 
 
122
            Item {
 
123
                width: 3 * parent.width / 7
 
124
                height: childrenRect.height
 
125
                Row {
 
126
                    anchors.horizontalCenter: parent.horizontalCenter
 
127
                    Label {
 
128
                        text: stopwatchUtils.lapTimeToString(model.totaltime) + "."
 
129
                    }
 
130
                    Label {
 
131
                        fontSize: "x-small"
 
132
                        text: stopwatchUtils.millisToString(model.totaltime)
 
133
                        anchors.bottom: parent.bottom
 
134
                        anchors.bottomMargin: units.dp(1)
 
135
                    }
 
136
                }
 
137
            }
 
138
        }
 
139
    }
 
140
}