summaryrefslogtreecommitdiffstats
path: root/app/NextCrossDistance.qml
blob: 7719976cbb5f7fde45dbaf310d24638f5750f86e (plain)
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
90
91
92
import QtQuick 2.0
import QtQuick.Layouts 1.1

Item {
    id: root
    property int units: 0
    property int tens: 0
    property int hundreds: 0
    ListModel {
        id: model
        ListElement {
            name: "0"
            picturePath: "qrc:tbt_0.png"
        }
        ListElement {
            name: "1"
            picturePath: "qrc:tbt_1.png"
        }
        ListElement {
            name: "2"
            picturePath: "qrc:tbt_2.png"
        }
        ListElement {
            name: "3"
            picturePath: "qrc:tbt_3.png"
        }
        ListElement {
            name: "4"
            picturePath: "qrc:tbt_4.png"
        }
        ListElement {
            name: "5"
            picturePath: "qrc:tbt_5.png"
        }
        ListElement {
            name: "6"
            picturePath: "qrc:tbt_6.png"
        }
        ListElement {
            name: "7"
            picturePath: "qrc:tbt_7.png"
        }
        ListElement {
            name: "8"
            picturePath: "qrc:tbt_8.png"
        }
        ListElement {
            name: "9"
            picturePath: "qrc:tbt_9.png"
        }
    }

    RowLayout {
        anchors.fill: parent
        Image {
            id: hundreds_image
            width: parent.width * 0.25
        }
        Image {
            id: tens_image
            width: parent.width * 0.25
        }
        Image {
            id: units_image
            width: parent.width * 0.25
            source: "qrc:tbt_0.png"
        }
        Image {
            id: metre_image
            width: parent.width * 0.25
            source: "qrc:tbt_m.png"
        }
    }

    function setCorssDistance(dis) {
        hundreds = dis / 100 % 10
        tens = dis / 10 % 10
        units = dis % 10
        if(hundreds != 0) {
            hundreds_image.source = model.get(hundreds).picturePath
            tens_image.source = model.get(tens).picturePath
            units_image.source = model.get(units).picturePath
        } else {
            if(tens != 0) {
                tens_image.source = model.get(tens).picturePath
            }
            units_image.source = model.get(units).picturePath
        }

    }

}