5 #if defined(HAVE_CONFIG_H) 6 #include <config/bitcoin-config.h> 10 #include <qt/forms/ui_addressbookpage.h> 20 #include <QMessageBox> 21 #include <QSortFilterProxyModel> 28 : QSortFilterProxyModel(parent), m_type(type) {
29 setDynamicSortFilter(
true);
30 setFilterCaseSensitivity(Qt::CaseInsensitive);
31 setSortCaseSensitivity(Qt::CaseInsensitive);
36 auto model = sourceModel();
46 if (filterRegExp().indexIn(model->data(address).toString()) < 0 &&
47 filterRegExp().indexIn(model->data(label).toString()) < 0) {
56 Tabs _tab, QWidget *parent)
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(
80 setWindowTitle(tr(
"Choose the address to send coins to"));
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();
97 setWindowTitle(tr(
"Sending addresses"));
100 setWindowTitle(tr(
"Receiving addresses"));
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);
125 QAction *copyAddressAction =
new QAction(tr(
"&Copy Address"),
this);
126 QAction *copyLabelAction =
new QAction(tr(
"Copy &Label"),
this);
127 QAction *editAction =
new QAction(tr(
"&Edit"),
this);
132 contextMenu->addAction(copyAddressAction);
133 contextMenu->addAction(copyLabelAction);
134 contextMenu->addAction(editAction);
138 contextMenu->addSeparator();
141 connect(copyAddressAction, &QAction::triggered,
this,
143 connect(copyLabelAction, &QAction::triggered,
this,
145 connect(editAction, &QAction::triggered,
this,
150 connect(
ui->tableView, &QWidget::customContextMenuRequested,
this,
153 connect(
ui->closeButton, &QPushButton::clicked,
this, &QDialog::accept);
161 this->
model = _model;
171 connect(
ui->searchLineEdit, &QLineEdit::textChanged,
proxyModel,
172 &QSortFilterProxyModel::setFilterWildcard);
175 ui->tableView->sortByColumn(0, Qt::AscendingOrder);
178 ui->tableView->horizontalHeader()->setSectionResizeMode(
180 ui->tableView->horizontalHeader()->setSectionResizeMode(
183 connect(
ui->tableView->selectionModel(),
184 &QItemSelectionModel::selectionChanged,
this,
188 connect(_model, &AddressTableModel::rowsInserted,
this,
207 if (!
ui->tableView->selectionModel()) {
210 QModelIndexList indexes =
ui->tableView->selectionModel()->selectedRows();
211 if (indexes.isEmpty()) {
220 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
242 QTableView *table =
ui->tableView;
243 if (!table->selectionModel()) {
247 QModelIndexList indexes = table->selectionModel()->selectedRows();
248 if (!indexes.isEmpty()) {
249 table->model()->removeRow(indexes.at(0).row());
255 QTableView *table =
ui->tableView;
256 if (!table->selectionModel()) {
260 if (table->selectionModel()->hasSelection()) {
264 ui->deleteAddress->setEnabled(
true);
265 ui->deleteAddress->setVisible(
true);
270 ui->deleteAddress->setEnabled(
false);
271 ui->deleteAddress->setVisible(
false);
275 ui->copyAddress->setEnabled(
true);
277 ui->deleteAddress->setEnabled(
false);
278 ui->copyAddress->setEnabled(
false);
283 QTableView *table =
ui->tableView;
284 if (!table->selectionModel() || !table->model()) {
289 QModelIndexList indexes =
292 for (
const QModelIndex &index : indexes) {
293 QVariant address = table->model()->data(index);
309 tr(
"Comma separated file (*.csv)"),
nullptr);
311 if (filename.isNull()) {
322 if (!writer.
write()) {
323 QMessageBox::critical(
this, tr(
"Exporting Failed"),
324 tr(
"There was an error trying to save the " 325 "address list to %1. Please try again.")
331 QModelIndex index =
ui->tableView->indexAt(point);
332 if (index.isValid()) {
344 ui->tableView->setFocus();
345 ui->tableView->selectRow(idx.row());
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)
void setModel(AddressTableModel *model)
void onEditAction()
Edit currently selected address entry (no button)
AddressTableModel * model
void on_exportButton_clicked()
Export button clicked.
Open address book for editing.
Open address book to pick address.
Export a Qt table model to a CSV file.
QString newAddressToSelect
static const QString Send
Specifies send address.
void selectNewAddress(const QModelIndex &parent, int begin, int)
New entry/entries were added to address table.
void setModel(AddressTableModel *model)
AddressBookSortFilterProxyModel * proxyModel
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.
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.
void setModel(const QAbstractItemModel *model)
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
QString getAddress() const
void copyEntryData(QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
void contextualMenu(const QPoint &point)
Spawn contextual menu (right mouse menu) for address book entry.
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)