5 #if defined(HAVE_CONFIG_H)
6 #include "config/bitcoin-config.h"
10 #include "ui_addressbookpage.h"
21 #include <QMessageBox>
22 #include <QSortFilterProxyModel>
34 ui->newAddress->setIcon(QIcon());
35 ui->copyAddress->setIcon(QIcon());
36 ui->deleteAddress->setIcon(QIcon());
37 ui->exportButton->setIcon(QIcon());
50 case SendingTab: setWindowTitle(tr(
"Choose the address to send coins to"));
break;
51 case ReceivingTab: setWindowTitle(tr(
"Choose the address to receive coins with"));
break;
53 connect(
ui->tableView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(accept()));
54 ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
55 ui->tableView->setFocus();
56 ui->closeButton->setText(tr(
"C&hoose"));
57 ui->exportButton->hide();
62 case SendingTab: setWindowTitle(tr(
"Such sending addresses"));
break;
63 case ReceivingTab: setWindowTitle(tr(
"Much receiving addresses"));
break;
70 ui->labelExplanation->setText(tr(
"These are your Dogecoin addresses for sending payments. Always check the amount and the receiving address before sending coins."));
71 ui->deleteAddress->setVisible(
true);
74 ui->labelExplanation->setText(tr(
"These are your Dogecoin addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
75 ui->deleteAddress->setVisible(
false);
80 QAction *copyAddressAction =
new QAction(tr(
"&Copy Address"),
this);
81 QAction *copyLabelAction =
new QAction(tr(
"Copy &Label"),
this);
82 QAction *editAction =
new QAction(tr(
"&Edit"),
this);
97 connect(editAction, SIGNAL(triggered()),
this, SLOT(
onEditAction()));
100 connect(
ui->tableView, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(
contextualMenu(QPoint)));
102 connect(
ui->closeButton, SIGNAL(clicked()),
this, SLOT(accept()));
112 this->
model = _model;
119 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
120 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
135 ui->tableView->sortByColumn(0, Qt::AscendingOrder);
138 #if QT_VERSION < 0x050000
146 connect(
ui->tableView->selectionModel(), SIGNAL(
selectionChanged(QItemSelection,QItemSelection)),
150 connect(_model, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
this, SLOT(
selectNewAddress(QModelIndex,
int,
int)));
170 if(!
ui->tableView->selectionModel())
172 QModelIndexList indexes =
ui->tableView->selectionModel()->selectedRows();
173 if(indexes.isEmpty())
181 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
204 QTableView *table =
ui->tableView;
205 if(!table->selectionModel())
208 QModelIndexList indexes = table->selectionModel()->selectedRows();
209 if(!indexes.isEmpty())
211 table->model()->removeRow(indexes.at(0).row());
218 QTableView *table =
ui->tableView;
219 if(!table->selectionModel())
222 if(table->selectionModel()->hasSelection())
228 ui->deleteAddress->setEnabled(
true);
229 ui->deleteAddress->setVisible(
true);
234 ui->deleteAddress->setEnabled(
false);
235 ui->deleteAddress->setVisible(
false);
239 ui->copyAddress->setEnabled(
true);
243 ui->deleteAddress->setEnabled(
false);
244 ui->copyAddress->setEnabled(
false);
250 QTableView *table =
ui->tableView;
251 if(!table->selectionModel() || !table->model())
257 Q_FOREACH (
const QModelIndex& index, indexes) {
258 QVariant address = table->model()->data(index);
268 QDialog::done(retval);
275 tr(
"Export Address List"), QString(),
276 tr(
"Comma separated file (*.csv)"), NULL);
278 if (filename.isNull())
288 if(!writer.
write()) {
289 QMessageBox::critical(
this, tr(
"Exporting Failed"),
290 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
296 QModelIndex index =
ui->tableView->indexAt(point);
309 ui->tableView->setFocus();
310 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 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.
AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent)
QSortFilterProxyModel * proxyModel
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
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
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 ...
void copyEntryData(QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.