forked from 0x20/tab-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTallyView.qml
163 lines (137 loc) · 4.17 KB
/
TallyView.qml
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import QtQuick 2.0
import QtQuick.Layouts 1.3
import "Colors.js" as Colors
import "controls"
Rectangle {
id: tally
color: application.layoutColor("#440000")
property bool hasSelection: tallyList.currentIndex !== -1
ListView {
anchors {
top: parent.top
right: parent.right
left: parent.left
bottom: totalRow.top
}
id: tallyList
model: tallyModel
clip: true
delegate: MouseArea {
width: parent.width
height: itemRow.height
Row {
id: itemRow
width: parent.width
Text {
id: qtyLabel
color: "white"
width: 50
horizontalAlignment: Text.AlignRight
text: (count > 1) ? (count + "x ") : ""
font.pixelSize: application.fontSize
font.family: application.fontFace
}
Text {
width: parent.width - qtyLabel.width - costLabel.width
color: "white"
text: name
font.pixelSize: application.fontSize
font.family: application.fontFace
}
Text {
id: costLabel
color: "white"
width: 100
horizontalAlignment: Text.AlignRight
font.pixelSize: application.fontSize
font.family: application.fontFace
text: {
application.formatCurrency(cost * count)
}
}
}
onClicked: {
tallyList.currentIndex = index
console.log("sel index: " + tallyList.currentIndex)
}
}
onCountChanged: {
currentIndex = count - 1
currentIndex = -1
}
highlight: Rectangle {
color: Colors.primary[4]
}
focus: true
}
Row {
id: totalRow
anchors {
right: parent.right
left: parent.left
bottom: controls.top
}
Text {
color: "white"
font.pixelSize: application.fontSize
font.family: application.fontFace
text: " Total: "
width: parent.width - totalLabel.width
}
Text {
id: totalLabel
color: "white"
width: 120
font.pixelSize: application.fontSize
font.family: application.fontFace
horizontalAlignment: Text.AlignRight
text: {
application.formatCurrency(tallyModel.total)
}
}
}
Item {
id: controls
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 0
anchors.bottomMargin: 10
height: application.buttonHeight
TqButton {
text: "Cancel Transaction"
enabled: tallyModel.count > 0
bgColor: Colors.secondary1[0]
onClicked: {
tallyModel.clear()
}
}
Text {
anchors.centerIn: parent
text: curDate.toLocaleString(Qt.locale(""), "yyyy-MM-dd\nHH:mm:ss")
color: "white"
font.pixelSize: application.fontSize
font.family: application.fontFace
horizontalAlignment: Text.AlignHCenter
property var curDate: new Date()
Timer {
interval: 200
running: true
repeat: true
onTriggered: parent.curDate = new Date()
}
}
TqButton {
anchors.right: parent.right
anchors.margins: 0
enabled: tally.hasSelection
bgColor: Colors.secondary1[0]
text: "Remove Item"
onClicked: {
tallyModel.adjustQuantity(tallyList.currentIndex, -1)
}
}
}
}