-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMainView.qml
145 lines (118 loc) · 3.35 KB
/
MainView.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
import QtQuick 2.4
import QtQuick.Layouts 1.3
import "controls"
Rectangle {
signal switchToTransfer()
signal switchToDeposit()
signal switchToStats()
signal depositCommand(string member, int amount)
signal purchaseCommand(string member, var bill)
id: mainView
property bool depositMode: false
color: "black"
Rectangle {
// This is a cheat to use anchor-based layout with fixed object sizes
id: centerBlip
x: parent.width - (application.buttonWidth + 10) * 3 - 10
y: 319
width: 0
height: 10
color: "#004000"
anchors.margins: 10
}
LogView {
id: logView
anchors {
left: parent.left
right: centerBlip.left
top: parent.top
bottom: utils.top
leftMargin: 10
topMargin: 10
bottomMargin: 0
}
}
TallyView {
id: tally
anchors {
left: centerBlip.right
right: parent.right
top: parent.top
bottom: centerBlip.top
rightMargin: 10
topMargin: 10
}
}
UtilView {
id: utils
anchors {
left: parent.left
bottom: centerBlip.top
right: centerBlip.left
}
onSwitchToDeposit: {
depositMode = !depositMode
}
onSwitchToStats: parent.switchToStats()
onSwitchToTransfer: parent.switchToTransfer()
}
StackLayout {
anchors {
left: parent.left
right: centerBlip.left
top: centerBlip.bottom
bottom: parent.bottom
}
currentIndex: depositMode ? 1 : 0
ProductList {
id: productList
onSelected: {
var product = productModel.get(index)
tallyModel.addItem(product.internal_name, product.name, product.cost, 1)
}
}
Item {
NumberEntry {
id: depositEntry
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 10
hasNegate: true
}
}
}
MemberList {
id: memberList
anchors {
left: centerBlip.right
right: parent.right
top: centerBlip.bottom
bottom: parent.bottom
}
onSelected: {
if (depositMode && depositEntry.value != 0) {
depositCommand(name, depositEntry.value)
depositMode = false
depositEntry.reset()
resetPages()
} else if (!depositMode && tallyModel.count > 0) {
var bill = []
for (var i = 0; i < tallyModel.count; i++) {
var item = tallyModel.get(i)
bill.push(item)
}
purchaseCommand(name, bill)
tallyModel.clear()
resetPages()
} else {
var pos = members.memberPosition(name)
var member = members.get(pos)
logModel.log(member["name"] + " has a balance of " + formatCurrency(member["balance"]));
}
}
}
function resetPages() {
memberList.page = 0
productList.page = 0
}
}