5 #if defined(HAVE_CONFIG_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) {
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'."));
116 QAction *copyAddressAction =
new QAction(tr(
"&Copy Address"),
this);
117 QAction *copyLabelAction =
new QAction(tr(
"Copy &Label"),
this);
118 QAction *editAction =
new QAction(tr(
"&Edit"),
this);
123 contextMenu->addAction(copyAddressAction);
124 contextMenu->addAction(copyLabelAction);
125 contextMenu->addAction(editAction);
128 contextMenu->addSeparator();
138 connect(
ui->
closeButton, &QPushButton::clicked,
this, &QDialog::accept);
150 this->
model = _model;
161 ui->
tableView->sortByColumn(0, Qt::AscendingOrder);
167 connect(
ui->
tableView->selectionModel(), &QItemSelectionModel::selectionChanged,
193 QModelIndexList indexes =
ui->
tableView->selectionModel()->selectedRows();
194 if(indexes.isEmpty())
202 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
227 if(!table->selectionModel())
230 QModelIndexList indexes = table->selectionModel()->selectedRows();
231 if(!indexes.isEmpty())
233 table->model()->removeRow(indexes.at(0).row());
241 if(!table->selectionModel())
244 if(table->selectionModel()->hasSelection())
273 if(!table->selectionModel() || !table->model())
279 for (
const QModelIndex& index : indexes) {
280 QVariant address = table->model()->data(index);
290 QDialog::done(retval);
297 tr(
"Export Address List"), QString(),
298 tr(
"Comma separated file (*.csv)"),
nullptr);
300 if (filename.isNull())
310 if(!writer.
write()) {
311 QMessageBox::critical(
this, tr(
"Exporting Failed"),
312 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
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)
QString getAddress() const
void setModel(AddressTableModel *model)
QModelIndex index(int row, int column, const QModelIndex &parent) const override
void onEditAction()
Edit currently selected address entry (no button)
AddressTableModel * model
QPushButton * copyAddress
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.
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.
bool filterAcceptsRow(int row, const QModelIndex &parent) const override
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 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.
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.
bool write()
Perform export of the model to CSV.
Type of address (Send or Receive)