5#if defined(HAVE_CONFIG_H)
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) {
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);
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."));
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'."));
126 connect(
ui->
closeButton, &QPushButton::clicked,
this, &QDialog::accept);
138 this->
model = _model;
149 ui->
tableView->sortByColumn(0, Qt::AscendingOrder);
155 connect(
ui->
tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
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());
215 if(!table->selectionModel())
218 QModelIndexList indexes = table->selectionModel()->selectedRows();
219 if(!indexes.isEmpty())
221 table->model()->removeRow(indexes.at(0).row());
229 if(!table->selectionModel())
232 if(table->selectionModel()->hasSelection())
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));
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.
bool write()
Perform export of the model to CSV.
void setModel(const QAbstractItemModel *model)
void addColumn(const QString &title, int column, int role=Qt::EditRole)
Dialog for editing an address and associated information.
void setModel(AddressTableModel *model)
QString getAddress() const
QLabel * labelExplanation
void setupUi(QWidget *AddressBookPage)
QPushButton * copyAddress
QLineEdit * searchLineEdit
QPushButton * exportButton
QPushButton * deleteAddress
QPushButton * closeButton
Utility functions used by the Bitcoin Qt UI.
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 ...
constexpr auto dialog_flags
void ShowModalDialogAndDeleteOnClose(QDialog *dialog)
Shows a QDialog instance asynchronously, and deletes it on close.