5 #if defined(HAVE_CONFIG_H)
10 #include <qt/forms/ui_addressbookpage.h>
20 #include <QMessageBox>
21 #include <QSortFilterProxyModel>
29 : QSortFilterProxyModel(parent)
32 setDynamicSortFilter(
true);
33 setFilterCaseSensitivity(Qt::CaseInsensitive);
34 setSortCaseSensitivity(Qt::CaseInsensitive);
40 auto model = sourceModel();
49 if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
50 filterRegExp().indexIn(model->data(label).toString()) < 0) {
68 ui->newAddress->setIcon(QIcon());
69 ui->copyAddress->setIcon(QIcon());
70 ui->deleteAddress->setIcon(QIcon());
71 ui->exportButton->setIcon(QIcon());
84 case SendingTab: setWindowTitle(tr(
"Choose the address to send coins to"));
break;
85 case ReceivingTab: setWindowTitle(tr(
"Choose the address to receive coins with"));
break;
87 connect(
ui->tableView, &QTableView::doubleClicked,
this, &QDialog::accept);
88 ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
89 ui->tableView->setFocus();
90 ui->closeButton->setText(tr(
"C&hoose"));
91 ui->exportButton->hide();
96 case SendingTab: setWindowTitle(tr(
"Sending addresses"));
break;
97 case ReceivingTab: setWindowTitle(tr(
"Receiving addresses"));
break;
104 ui->labelExplanation->setText(tr(
"These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
105 ui->deleteAddress->setVisible(
true);
106 ui->newAddress->setVisible(
true);
109 ui->labelExplanation->setText(tr(
"These are your Bitcoin addresses for receiving payments. Use the 'Create new receiving address' button in the receive tab to create new addresses.\nSigning is only possible with addresses of the type 'legacy'."));
110 ui->deleteAddress->setVisible(
false);
111 ui->newAddress->setVisible(
false);
126 connect(
ui->closeButton, &QPushButton::clicked,
this, &QDialog::accept);
138 this->
model = _model;
146 connect(
ui->searchLineEdit, &QLineEdit::textChanged,
proxyModel, &QSortFilterProxyModel::setFilterWildcard);
149 ui->tableView->sortByColumn(0, Qt::AscendingOrder);
155 connect(
ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
179 if(!
ui->tableView->selectionModel())
181 QModelIndexList indexes =
ui->tableView->selectionModel()->selectedRows();
182 if(indexes.isEmpty())
189 dlg->setModel(
model);
190 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
191 dlg->loadRow(origIndex.row());
214 QTableView *table =
ui->tableView;
215 if(!table->selectionModel())
218 QModelIndexList indexes = table->selectionModel()->selectedRows();
219 if(!indexes.isEmpty())
221 table->model()->removeRow(indexes.at(0).row());
228 QTableView *table =
ui->tableView;
229 if(!table->selectionModel())
232 if(table->selectionModel()->hasSelection())
238 ui->deleteAddress->setEnabled(
true);
239 ui->deleteAddress->setVisible(
true);
243 ui->deleteAddress->setEnabled(
false);
244 ui->deleteAddress->setVisible(
false);
247 ui->copyAddress->setEnabled(
true);
251 ui->deleteAddress->setEnabled(
false);
252 ui->copyAddress->setEnabled(
false);
258 QTableView *table =
ui->tableView;
259 if(!table->selectionModel() || !table->model())
265 for (
const QModelIndex& index : indexes) {
266 QVariant address = table->model()->data(index);
276 QDialog::done(retval);
283 tr(
"Export Address List"), QString(),
286 tr(
"Comma separated file") + QLatin1String(
" (*.csv)"),
nullptr);
288 if (filename.isNull())
298 if(!writer.
write()) {
299 QMessageBox::critical(
this, tr(
"Exporting Failed"),
302 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
308 QModelIndex index =
ui->tableView->indexAt(point);
321 ui->tableView->setFocus();
322 ui->tableView->selectRow(idx.row());