-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebtorPage.qml
242 lines (209 loc) · 7.12 KB
/
DebtorPage.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import QtQuick 2.8
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
import sql.debtor.model 1.0
Page {
id: debtorPage
property int currentDebtor: -1
header: DebtToolBar {
Label {
text: qsTr("Debtors")
font.pixelSize: 20
anchors.centerIn: parent
}
ToolButton {
text: qsTr("Back")
anchors.left: parent.left
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
onClicked: debtorPage.StackView.view.pop()
}
ComboBox{
id:filterColumnName
model: ["Name", "Surename", "Phone"]
currentIndex: 0
onCurrentIndexChanged: {
if(currentIndex===0)listView.model.sortBy("name")
else if(currentIndex===1)listView.model.sortBy("surename");
else listView.model.sortBy("phone");
}
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
ListView {
id: listView
anchors.fill: parent
delegate: SwipeDelegate {
id: delegate
width: listView.width
onClicked: {
debtorPage.StackView.view.push("qrc:/ProductsPage.qml", { currentDebtor: model.id, currentDebtorName: model.name})
}
hoverEnabled: true
onHoveredChanged: !hovered?checked=false:checked=true
checkable: true
contentItem: ColumnLayout{
Row{
Label {
text: name +" " + surename
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
}
Label{
text: " :: "+comment
font.italic: true
color: "grey"
elide: Text.ElideRight
}
}
GridLayout {
id: grid
visible: false
columns: 2
rowSpacing: 10
columnSpacing: 10
Label {
text: qsTr("Address:")
Layout.leftMargin: 60
}
Label {
text: address_name_2
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
}
Label {
text: qsTr("Phone:")
Layout.leftMargin: 60
}
Label {
text: phone
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
}
Label {
text: qsTr("E_mail:")
Layout.leftMargin: 60
}
Label {
text: e_mail
font.bold: true
elide: Text.ElideRight
Layout.fillWidth: true
}
}
states: [
State {
name: "expanded"
when: delegate.checked
PropertyChanges {
target: grid
visible: true
}
}
]
}
//Right
swipe.right: Rectangle {
color: SwipeDelegate.pressed ? "#333" : "#444"
width: parent.width
height: parent.height
clip: true
SwipeDelegate.onClicked: listModel.remove(index)
Label {
font.pixelSize: delegate.font.pixelSize
text: "Remove"
color: "white"
anchors.centerIn: parent
}
}
//Left
swipe.left: Rectangle {
color: SwipeDelegate.pressed ? "#333" : "#444"
width: parent.width
height: parent.height
clip: true
SwipeDelegate.onClicked: {
currentDebtor=index;
debtorDialog.editDebtor(listView.model.get(currentDebtor));
}
Label {
font.pixelSize: delegate.font.pixelSize
text: "Edit"
color: "white"
anchors.centerIn: parent
}
}
}
model: SqlDebtorModel {
id: listModel
}
ScrollBar.vertical: ScrollBar { }
section.property: {filterColumnName.currentIndex===0?"name":filterColumnName.currentIndex===1?"surename":"phone";}
section.criteria: ViewSection.FirstCharacter
section.delegate: sectionHeading
section.labelPositioning: listView.section.labelPositioning |= ViewSection.CurrentLabelAtStart
}
Label {
id: placeholder
text: qsTr("No more Debtors")
anchors.margins: 60
anchors.fill: parent
opacity: 0.5
visible: listView.count === 0
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
wrapMode: Label.WordWrap
font.pixelSize: 18
}
DebtorDialog {
id: debtorDialog
onFinished: {
if (currentDebtor === -1)
listView.model.append(name, surename, phone, email, comment, address)
else
listView.model.set(currentDebtor, name, surename, phone, email, comment, address)
}
}
RoundButton {
text: qsTr("+")
highlighted: true
anchors.margins: 10
anchors.right: parent.right
anchors.bottom: parent.bottom
onClicked: {
currentDebtor = -1
debtorDialog.createDebtor()
}
}
// footer: RowLayout {
// // TextArea {
// // id: messageField
// // Layout.fillWidth: true
// // placeholderText: qsTr("Search...")
// // wrapMode: TextArea.Wrap
// // onTextChanged: {
// // listView.currentIndex=20
// // }
// // }
// }
//Section Component
Component {
id: sectionHeading
ToolBar {
opacity: 0.8
width: listView.width
Label {
id: label
text: section
anchors.fill: parent
horizontalAlignment: Qt.AlignHCenter
verticalAlignment: Qt.AlignVCenter
}
}
}
}