-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProductsDialog.qml
124 lines (112 loc) · 3.67 KB
/
ProductsDialog.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
import QtQuick 2.7
import QtQuick.Controls 2.1
import sql.lender.model 1.0
Dialog {
id: dialog
//Component.onCompleted: preset()
signal finished(string product, double quantity, double cost, string comment_1, string borrowed_data, int lender, double paid_back, string paid_back_data, string comment_2, int paid_back_to)
function createDebt(pay) {
if(pay){
makeInvisible(true);
dialog.title = qsTr("Pay Debt");
}
else {
makeInvisible(false)
dialog.title = qsTr("Add Debt");
}
dialog.open();
}
function editDebt(debt) {
form.product.text=debt.product;
form.quantity.value=debt.quantity;
form.cost.value=debt.cost;
form.comment_1.text=debt.comment_1;
form.borrowed_data.text=debt.borrowed_data;
form.lender.currentIndex=debt.lender;
if(debt.paid_back=="")makeInvisible(false)
else{
form.paid_back.value=debt.paid_back;
form.paid_back_data.text=debt.paid_back_data;
form.comment_2.text=debt.comment_2;
form.paid_back_to.currentIndex=debt.paid_back_to;
}
dialog.title = qsTr("Edit Debt");
dialog.open();
}
function preset()
{
if(!form.product.visible)
{
form.product.visible=true;
form.quantity.visible=true;
form.cost.visible=true;
form.comment_1.visible=true;
form.borrowed_data.visible=true;
form.lender.visible=true;
}
if(!form.paid_back.visible)
{
form.paid_back.visible=true;
form.paid_back_data.visible=true;
form.comment_2.visible=true;
form.paid_back_to.visible=true;
}
if(form.product!="")
{
form.product.clear();
form.quantity.value=0;
form.cost.value=0;
form.comment_1.clear();
form.borrowed_data.clear();
form.lender.currentIndex=-1;
}
if(form.paid_back.value!=0)
{
form.paid_back.value=0;
form.paid_back_data.clear();
form.comment_2.clear();
form.paid_back_to.currentIndex=-1;
}
}
function makeInvisible(part)
{
if(part)
{
form.product.visible=false;
form.quantity.visible=false;
form.cost.visible=false;
form.comment_1.visible=false;
form.borrowed_data.visible=false;
form.lender.visible=false;
return;
}
form.paid_back.visible=false;
form.paid_back_data.visible=false;
form.comment_2.visible=false;
form.paid_back_to.visible=false;
}
x: parent.width / 2 - width / 2
y: parent.height / 2 - height / 2
focus: true
modal: true
//title: qsTr("Add Debt")
standardButtons: Dialog.Ok | Dialog.Cancel
SqlLenderModel{
id:model;
}
contentItem: ProductsForm {
id: form
lender.model: model
paid_back_to.model: model
}
onAccepted: finished(form.product.text,
form.quantity.value,
form.cost.value,
form.comment_1.text,
form.borrowed_data,
form.lender.currentIndex,
form.paid_back.value,
form.paid_back_data.text,
form.comment_2.text,
form.paid_back_to.currentIndex)
}