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
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/qt/editaddressdialog.h]
/**
| Dialog for editing an address and associated
| information.
|
*/
#[Q_OBJECT]
pub struct EditAddressDialog {
base: QDialog,
ui: *mut UiEditAddressDialog,
mapper: *mut QDataWidgetMapper,
mode: EditAddressDialogMode,
model: *mut AddressTableModel,
address: String,
}
pub enum EditAddressDialogMode {
NewSendingAddress,
EditReceivingAddress,
EditSendingAddress
}
//-------------------------------------------[.cpp/bitcoin/src/qt/editaddressdialog.cpp]
impl Drop for EditAddressDialog {
fn drop(&mut self) {
todo!();
/*
delete ui;
*/
}
}
impl EditAddressDialog {
pub fn new(
mode: EditAddressDialogMode,
parent: *mut QWidget) -> Self {
todo!();
/*
:
QDialog(parent, typename gui_util::dialog_flags),
ui(new UiEditAddressDialog),
mapper(nullptr),
mode(_mode),
model(nullptr)
ui->setupUi(this);
typename gui_util::setupAddressWidget(ui->addressEdit, this);
switch(mode)
{
case NewSendingAddress:
setWindowTitle(tr("New sending address"));
break;
case EditReceivingAddress:
setWindowTitle(tr("Edit receiving address"));
ui->addressEdit->setEnabled(false);
break;
case EditSendingAddress:
setWindowTitle(tr("Edit sending address"));
break;
}
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
typename gui_util::ItemDelegate* delegate = new typename gui_util::ItemDelegate(mapper);
connect(delegate, &typename gui_util::ItemDelegate::keyEscapePressed, this, &EditAddressDialog::reject);
mapper->setItemDelegate(delegate);
typename gui_util::handleCloseWindowShortcut(this);
*/
}
pub fn set_model(&mut self, model: *mut AddressTableModel) {
todo!();
/*
this->model = _model;
if(!_model)
return;
mapper->setModel(_model);
mapper->addMapping(ui->labelEdit, AddressTableModel::Label);
mapper->addMapping(ui->addressEdit, AddressTableModel::Address);
*/
}
pub fn load_row(&mut self, row: i32) {
todo!();
/*
mapper->setCurrentIndex(row);
*/
}
#[Q_SLOT]
pub fn save_current_row(&mut self) -> bool {
todo!();
/*
if(!model)
return false;
switch(mode)
{
case NewSendingAddress:
address = model->addRow(
AddressTableModel::Send,
ui->labelEdit->text(),
ui->addressEdit->text(),
model->GetDefaultAddressType());
break;
case EditReceivingAddress:
case EditSendingAddress:
if(mapper->submit())
{
address = ui->addressEdit->text();
}
break;
}
return !address.isEmpty();
*/
}
#[Q_SLOT]
pub fn accept(&mut self) {
todo!();
/*
if(!model)
return;
if(!saveCurrentRow())
{
switch(model->getEditStatus())
{
case AddressTableModel::OK:
// Failed with unknown reason. Just reject.
break;
case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject.
break;
case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid Bitcoin address.").arg(ui->addressEdit->text()),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(),
getDuplicateAddressWarning(),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok);
break;
case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok);
break;
}
return;
}
QDialog::accept();
*/
}
/**
| Return a descriptive string when adding
| an already-existing address fails.
|
*/
pub fn get_duplicate_address_warning(&self) -> String {
todo!();
/*
QString dup_address = ui->addressEdit->text();
QString existing_label = model->labelForAddress(dup_address);
QString existing_purpose = model->purposeForAddress(dup_address);
if (existing_purpose == "receive" &&
(mode == NewSendingAddress || mode == EditSendingAddress)) {
return tr(
"Address \"%1\" already exists as a receiving address with label "
"\"%2\" and so cannot be added as a sending address."
).arg(dup_address).arg(existing_label);
}
return tr(
"The entered address \"%1\" is already in the address book with "
"label \"%2\"."
).arg(dup_address).arg(existing_label);
*/
}
pub fn get_address(&self) -> String {
todo!();
/*
return address;
*/
}
pub fn set_address(&mut self, address: &String) {
todo!();
/*
this->address = _address;
ui->addressEdit->setText(_address);
*/
}
}