-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathClientEditor.cpp
111 lines (92 loc) · 2.9 KB
/
ClientEditor.cpp
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
#include <QDialogButtonBox>
#include <QBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QSpinBox>
#include <QPushButton>
#include "Client.h"
#include "RateEditor.h"
#include "ClientEditor.h"
ClientEditor::
ClientEditor(QWidget *parent, const Client *src)
/*************************************************************************************
* Construct the dialog.
*/
: QDialog(parent)
{
setWindowTitle("Client Editor");
QVBoxLayout *vbl = new QVBoxLayout(this);
{ /************************** 1st row ************************/
QHBoxLayout *hbl = new QHBoxLayout;
vbl->addLayout(hbl);
{ /* Acronym */
QLabel *lbl = new QLabel("Acronym:", this);
hbl->addWidget(lbl);
_acronym_le = new QLineEdit(this);
hbl->addWidget(_acronym_le);
QString acronym;
src->acronym(&acronym);
_acronym_le->setText(acronym);
}
hbl->addStretch();
{ /* Default Rate */
QLabel *lbl = new QLabel("Default Rate: $", this);
hbl->addWidget(lbl);
int64_t default_rate=0;
src->default_rate(&default_rate);
_default_rate_re = new RateEditor(default_rate, this);
hbl->addWidget(_default_rate_re);
}
}
{ /************************** 2nd row ************************/
QHBoxLayout *hbl = new QHBoxLayout;
vbl->addLayout(hbl);
{ /* Full name */
QLabel *lbl = new QLabel("Full Name:", this);
hbl->addWidget(lbl);
_name_le = new QLineEdit(this);
hbl->addWidget(_name_le);
QString name;
src->name(&name);
_name_le->setText(name);
}
{ /* Charge quantum */
QLabel *lbl = new QLabel("Billing Quantum (min):", this);
hbl->addWidget(lbl);
_charge_quantum_sb= new QSpinBox(this);
hbl->addWidget(_charge_quantum_sb);
int32_t charge_quantum=10;
src->default_charge_quantum(&charge_quantum);
_charge_quantum_sb->setValue(charge_quantum);
}
}
{ /* Accept & Cancel buttons */
QHBoxLayout *hbl = new QHBoxLayout;
vbl->addLayout(hbl);
QDialogButtonBox *dbb =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
hbl->addWidget(dbb);
connect(dbb, SIGNAL(rejected()), SLOT(reject()));
connect(dbb, SIGNAL(accepted()), SLOT(accept()));
}
}
ClientEditor::
~ClientEditor()
/*************************************************************************************
* Destruct the dialog.
*/
{
}
void
ClientEditor::
assign(Client *target) const
/*************************************************************************************
* Assign editor values to the target
*/
{
/* Put supplied values into the client object */
target->set_acronym(_acronym_le->text());
target->set_name(_name_le->text());
target->set_default_rate(_default_rate_re->pennies());
target->set_default_charge_quantum(_charge_quantum_sb->value());
}