~cibersheep/unav/systemcolors

« back to all changes in this revision

Viewing changes to qml/RouteInfoListPage.qml

  • Committer: costales
  • Date: 2016-03-26 18:53:17 UTC
  • Revision ID: costales.marcos@gmail.com-20160326185317-4iau3yhe8986h5pg
Init team

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * GPS Navigation http://launchpad.net/unav
 
3
 * Copyright (C) 2015-2016 Marcos Alvarez Costales https://launchpad.net/~costales
 
4
 * Copyright (C) 2015-2016 JkB https://launchpad.net/~joergberroth
 
5
 * Copyright (C) 2016 Dan Chapman https://launchpad.net/~dpniel
 
6
 *
 
7
 * GPS Navigation is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 3 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * GPS Navigation is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 */
 
17
 
 
18
import QtQuick 2.4
 
19
import QtQuick.Layouts 1.1
 
20
import Ubuntu.Components 1.3
 
21
import Ubuntu.Components.ListItems 1.3 as ListItems
 
22
import QtQuick.XmlListModel 2.0
 
23
 
 
24
 
 
25
Page {
 
26
    id: routeInfoListPage
 
27
 
 
28
    property var routeList
 
29
 
 
30
    title: i18n.tr("Route Info")
 
31
    anchors.fill: parent
 
32
 
 
33
    ListModel {
 
34
        id: routeInfoListModel
 
35
 
 
36
        function initializeList (){
 
37
            var item
 
38
            for ( var i = 0; i < routeList.length; i++) {
 
39
                item  = {
 
40
                    "type": routeList[i].type,
 
41
                    "lng": routeList[i].coordinates[0],
 
42
                    "lat": routeList[i].coordinates[1],
 
43
                    "instruction": routeList[i].instruction,
 
44
                    "distance": routeList[i].distance,
 
45
                    "duration": routeList[i].duration,
 
46
                    "way_name": routeList[i].way_name,
 
47
                    "speaked": routeList[i].speaked,
 
48
                }
 
49
                routeInfoListModel.append(item);
 
50
            }
 
51
        }
 
52
    }
 
53
    // Note: No need for UbuntuListView here as no expanding animations
 
54
    // are being used.
 
55
    ListView {
 
56
        id: resultsListView
 
57
 
 
58
        model: routeInfoListModel
 
59
 
 
60
        anchors.fill: parent
 
61
        visible: false
 
62
 
 
63
        delegate: ListItem {
 
64
 
 
65
            height: routeInfoLayout.implicitHeight
 
66
 
 
67
            ListItemLayout {
 
68
                id: routeInfoLayout
 
69
 
 
70
                title.text: instruction
 
71
                title.color: !speaked ? UbuntuColors.darkGrey : UbuntuColors.lightGrey
 
72
                title.textFormat: Text.RichText // Hack: Space character in translations
 
73
 
 
74
                UbuntuShape {
 
75
                    aspect: UbuntuShape.Flat
 
76
                    height: units.gu(6); width: height
 
77
                    sourceScale: Qt.vector2d(0.8, 0.8)
 
78
                    radius: "small"
 
79
                    backgroundColor: "#292929"
 
80
                    source: Image {
 
81
                        source: Qt.resolvedUrl("../nav/img/steps/" + type + ".svg")
 
82
                    }
 
83
                    sourceFillMode: UbuntuShape.PreserveAspectFit
 
84
                    sourceHorizontalAlignment: UbuntuShape.AlignHCenter
 
85
 
 
86
                    // We want this on the left side of the main slot
 
87
                    SlotsLayout.position: SlotsLayout.Leading
 
88
                }
 
89
 
 
90
                Item {
 
91
                    id: inner_infoCol
 
92
 
 
93
                    height: inner_timeLabel.height + units.gu(1) + inner_distanceLabel.height
 
94
                    width: Math.max(inner_timeLabel.width, inner_distanceLabel.width + units.gu(1))
 
95
                    SlotsLayout.overrideVerticalPositioning: true
 
96
 
 
97
                    Label {
 
98
                        id: inner_timeLabel
 
99
                        anchors.top: parent.top
 
100
                        anchors.topMargin: units.gu(1.5)
 
101
                        anchors.right: parent.right
 
102
                        text: duration !== 0 ? ( (duration/60).toFixed(1) + " min" ) : ""
 
103
                        fontSize: "small"
 
104
                    }
 
105
 
 
106
                    Label {
 
107
                        id: inner_distanceLabel
 
108
                        anchors.right: parent.right
 
109
                        anchors.top: inner_timeLabel.bottom
 
110
                        anchors.topMargin: units.gu(2)
 
111
                        text: distance !== 0 ? ( (distance /1000).toFixed(2) + (navApp.settings.unit === 1 ? " mi" : " km") ) : ""
 
112
                        fontSize: "small"
 
113
                    }
 
114
                }
 
115
            }
 
116
        }
 
117
    }
 
118
 
 
119
    Component.onCompleted: {
 
120
        routeInfoListModel.initializeList();
 
121
        resultsListView.visible = true
 
122
    }
 
123
}