8 #if defined(HAVE_CONFIG_H)
13 #include "ui_addressbookpage.h"
23 #include <QMessageBox>
24 #include <QSortFilterProxyModel>
34 #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac
35 ui->newAddress->setIcon(QIcon());
36 ui->copyAddress->setIcon(QIcon());
37 ui->deleteAddress->setIcon(QIcon());
38 ui->exportButton->setIcon(QIcon());
44 setWindowTitle(tr(
"Choose the address to send coins to"));
47 setWindowTitle(tr(
"Choose the address to receive coins with"));
50 connect(
ui->tableView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(accept()));
51 ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
52 ui->tableView->setFocus();
53 ui->closeButton->setText(tr(
"C&hoose"));
54 ui->exportButton->hide();
59 setWindowTitle(tr(
"Sending addresses"));
62 setWindowTitle(tr(
"Receiving addresses"));
69 ui->labelExplanation->setText(tr(
"These are your PRCY addresses for sending payments. Always check the amount and the receiving address before sending coins."));
70 ui->deleteAddress->setVisible(
true);
73 ui->labelExplanation->setText(tr(
"These are your PRCY addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
74 ui->deleteAddress->setVisible(
false);
79 QAction* copyAddressAction =
new QAction(tr(
"&Copy Address"),
this);
80 QAction* copyLabelAction =
new QAction(tr(
"Copy &Label"),
this);
81 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()));
119 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
120 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
139 connect(
ui->tableView->selectionModel(), SIGNAL(
selectionChanged(QItemSelection, QItemSelection)),
143 connect(
model, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
this, SLOT(
selectNewAddress(QModelIndex,
int,
int)));
163 if (!
ui->tableView->selectionModel())
165 QModelIndexList indexes =
ui->tableView->selectionModel()->selectedRows();
166 if (indexes.isEmpty())
175 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
198 QTableView* table =
ui->tableView;
199 if (!table->selectionModel())
202 QModelIndexList indexes = table->selectionModel()->selectedRows();
203 if (!indexes.isEmpty()) {
204 table->model()->removeRow(indexes.at(0).row());
211 QTableView* table =
ui->tableView;
212 if (!table->selectionModel())
215 if (table->selectionModel()->hasSelection()) {
219 ui->deleteAddress->setEnabled(
true);
220 ui->deleteAddress->setVisible(
true);
225 ui->deleteAddress->setEnabled(
false);
226 ui->deleteAddress->setVisible(
false);
230 ui->copyAddress->setEnabled(
true);
232 ui->deleteAddress->setEnabled(
false);
233 ui->copyAddress->setEnabled(
false);
239 QTableView* table =
ui->tableView;
240 if (!table->selectionModel() || !table->model())
246 Q_FOREACH (QModelIndex index, indexes) {
247 QVariant address = table->model()->data(index);
256 QDialog::done(retval);
263 tr(
"Export Address List"), QString(),
264 tr(
"Comma separated file (*.csv)"), NULL);
266 if (filename.isNull())
276 if (!writer.
write()) {
277 QMessageBox::critical(
this, tr(
"Exporting Failed"),
278 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
284 QModelIndex index =
ui->tableView->indexAt(point);
285 if (index.isValid()) {
295 ui->tableView->setFocus();
296 ui->tableView->selectRow(idx.row());