5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
10#include <qt/forms/ui_addressbookpage.h>
21#include <QSortFilterProxyModel>
28 : QSortFilterProxyModel(parent),
m_type(type) {
62 ui->newAddress->setIcon(
QIcon());
63 ui->copyAddress->setIcon(
QIcon());
64 ui->deleteAddress->setIcon(
QIcon());
65 ui->exportButton->setIcon(
QIcon());
68 ui->copyAddress->setIcon(
70 ui->deleteAddress->setIcon(
72 ui->exportButton->setIcon(
84 tr(
"Choose the address to receive coins with"));
87 connect(
ui->tableView, &QTableView::doubleClicked,
this,
89 ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
90 ui->tableView->setFocus();
91 ui->closeButton->setText(
tr(
"C&hoose"));
92 ui->exportButton->hide();
107 ui->labelExplanation->setText(
108 tr(
"These are your Bitcoin addresses for sending payments. "
109 "Always check the amount and the receiving address before "
111 ui->deleteAddress->setVisible(
true);
112 ui->newAddress->setVisible(
true);
115 ui->labelExplanation->setText(
116 tr(
"These are your Bitcoin addresses for receiving payments. "
117 "Use the 'Create new receiving address' button in the "
118 "receive tab to create new addresses."));
119 ui->deleteAddress->setVisible(
false);
120 ui->newAddress->setVisible(
false);
141 connect(copyAddressAction, &QAction::triggered,
this,
143 connect(copyLabelAction, &QAction::triggered,
this,
150 connect(
ui->tableView, &QWidget::customContextMenuRequested,
this,
153 connect(
ui->closeButton, &QPushButton::clicked,
this, &QDialog::accept);
174 &QSortFilterProxyModel::setFilterWildcard);
177 ui->tableView->sortByColumn(0, Qt::AscendingOrder);
180 ui->tableView->horizontalHeader()->setSectionResizeMode(
182 ui->tableView->horizontalHeader()->setSectionResizeMode(
186 &QItemSelectionModel::selectionChanged,
this,
209 if (!
ui->tableView->selectionModel()) {
245 if (!table->selectionModel()) {
251 table->model()->removeRow(
indexes.at(0).row());
258 if (!table->selectionModel()) {
262 if (table->selectionModel()->hasSelection()) {
266 ui->deleteAddress->setEnabled(
true);
267 ui->deleteAddress->setVisible(
true);
272 ui->deleteAddress->setEnabled(
false);
273 ui->deleteAddress->setVisible(
false);
277 ui->copyAddress->setEnabled(
true);
279 ui->deleteAddress->setEnabled(
false);
280 ui->copyAddress->setEnabled(
false);
286 if (!table->selectionModel() || !table->model()) {
295 QVariant address = table->model()->data(index);
311 tr(
"Comma separated file (*.csv)"),
nullptr);
313 if (filename.isNull()) {
325 QMessageBox::critical(
this,
tr(
"Exporting Failed"),
326 tr(
"There was an error trying to save the "
327 "address list to %1. Please try again.")
334 if (index.isValid()) {
346 ui->tableView->setFocus();
347 ui->tableView->selectRow(idx.row());
Widget that shows a list of sending or receiving addresses.
void onEditAction()
Edit currently selected address entry (no button)
@ ForEditing
Open address book for editing.
@ ForSelection
Open address book to pick address.
void setModel(AddressTableModel *model)
void onCopyLabelAction()
Copy label of currently selected address entry to clipboard (no button)
QString newAddressToSelect
void done(int retval) override
AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent=nullptr)
void on_copyAddress_clicked()
Copy address of currently selected address entry to clipboard.
void on_exportButton_clicked()
Export button clicked.
void on_deleteAddress_clicked()
Delete currently selected address entry.
void contextualMenu(const QPoint &point)
Spawn contextual menu (right mouse menu) for address book entry.
AddressTableModel * model
void selectionChanged()
Set button states based on selected tab and selection.
void selectNewAddress(const QModelIndex &parent, int begin, int)
New entry/entries were added to address table.
void on_newAddress_clicked()
Create a new address for receiving coins and / or add a new address book entry.
AddressBookSortFilterProxyModel * proxyModel
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
AddressBookSortFilterProxyModel(const QString &type, QObject *parent)
Qt model of the address book in the core.
@ TypeRole
Type of address (Send or Receive)
@ Address
Bitcoin address.
@ Label
User specified label.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
static const QString Send
Specifies send address.
static const QString Receive
Specifies receive address.
Export a Qt table model to a CSV file.
Dialog for editing an address and associated information.
void setModel(AddressTableModel *model)
void handleCloseWindowShortcut(QWidget *w)
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...