16 #include <QMessageBox> 17 #include <QSortFilterProxyModel> 18 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) 19 #include <QRegularExpression> 30 : QSortFilterProxyModel(parent)
33 setDynamicSortFilter(
true);
34 setFilterCaseSensitivity(Qt::CaseInsensitive);
35 setSortCaseSensitivity(Qt::CaseInsensitive);
41 auto model = sourceModel();
50 #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) 51 const auto pattern = filterRegularExpression();
53 const auto pattern = filterRegExp();
55 return (model->data(address).toString().contains(pattern) ||
56 model->data(label).toString().contains(pattern));
83 case SendingTab: setWindowTitle(tr(
"Choose the address to send coins to"));
break;
84 case ReceivingTab: setWindowTitle(tr(
"Choose the address to receive coins with"));
break;
86 connect(
ui->
tableView, &QTableView::doubleClicked,
this, &QDialog::accept);
87 ui->
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
95 ui->
labelExplanation->setText(tr(
"These are your Bitcoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
100 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'."));
117 connect(
ui->
closeButton, &QPushButton::clicked,
this, &QDialog::accept);
129 this->
model = _model;
140 ui->
tableView->sortByColumn(0, Qt::AscendingOrder);
146 connect(
ui->
tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
173 QModelIndexList indexes =
ui->
tableView->selectionModel()->selectedRows();
174 if(indexes.isEmpty())
181 dlg->setModel(
model);
182 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
183 dlg->loadRow(origIndex.row());
207 if(!table->selectionModel())
210 QModelIndexList indexes = table->selectionModel()->selectedRows();
211 if(!indexes.isEmpty())
213 table->model()->removeRow(indexes.at(0).row());
221 if(!table->selectionModel())
224 if(table->selectionModel()->hasSelection())
251 if(!table->selectionModel() || !table->model())
257 for (
const QModelIndex& index : indexes) {
258 QVariant address = table->model()->data(index);
268 QDialog::done(retval);
275 tr(
"Export Address List"), QString(),
278 tr(
"Comma separated file") + QLatin1String(
" (*.csv)"),
nullptr);
280 if (filename.isNull())
290 if(!writer.
write()) {
291 QMessageBox::critical(
this, tr(
"Exporting Failed"),
294 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
326 case SendingTab: setWindowTitle(tr(
"Sending addresses - %1").arg(walletName));
break;
327 case ReceivingTab: setWindowTitle(tr(
"Receiving addresses - %1").arg(walletName));
break;
AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent=nullptr)
void on_newAddress_clicked()
Create a new address for receiving coins and / or add a new address book entry.
void onCopyLabelAction()
Copy label of currently selected address entry to clipboard (no button)
void addColumn(const QString &title, int column, int role=Qt::EditRole)
Utility functions used by the Bitcoin Qt UI.
void setModel(AddressTableModel *model)
void onEditAction()
Edit currently selected address entry (no button)
AddressTableModel * model
QPushButton * copyAddress
void updateWindowsTitleWithWalletName()
void on_exportButton_clicked()
Export button clicked.
Open address book for editing.
Open address book to pick address.
void ShowModalDialogAsynchronously(QDialog *dialog)
Shows a QDialog instance asynchronously, and deletes it on close.
Export a Qt table model to a CSV file.
QString newAddressToSelect
static const QString Send
Specifies send address.
constexpr auto dialog_flags
void selectNewAddress(const QModelIndex &parent, int begin, int)
New entry/entries were added to address table.
QPushButton * closeButton
void setModel(AddressTableModel *model)
QLineEdit * searchLineEdit
void setupUi(QWidget *AddressBookPage)
void handleCloseWindowShortcut(QWidget *w)
AddressBookSortFilterProxyModel * proxyModel
QPushButton * deleteAddress
AddressBookSortFilterProxyModel(const QString &type, QObject *parent)
void on_copyAddress_clicked()
Copy address of currently selected address entry to clipboard.
Widget that shows a list of sending or receiving addresses.
void copyEntryData(const QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
Qt model of the address book in the core.
void done(int retval) override
void selectionChanged()
Set button states based on selected tab and selection.
QPushButton * exportButton
void setModel(const QAbstractItemModel *model)
QString GetWalletDisplayName() const
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 ...
static const QString Receive
Specifies receive address.
Dialog for editing an address and associated information.
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
QString getAddress() const
void contextualMenu(const QPoint &point)
Spawn contextual menu (right mouse menu) for address book entry.
QLabel * labelExplanation
void on_deleteAddress_clicked()
Delete currently selected address entry.
QModelIndex index(int row, int column, const QModelIndex &parent) const override
bool write()
Perform export of the model to CSV.
Type of address (Send or Receive)