6 #if defined(HAVE_CONFIG_H) 11 #include "ui_addressbookpage.h" 22 #include <QMessageBox> 23 #include <QSortFilterProxyModel> 35 ui->newAddress->setIcon(QIcon());
36 ui->copyAddress->setIcon(QIcon());
37 ui->deleteAddress->setIcon(QIcon());
38 ui->exportButton->setIcon(QIcon());
51 case SendingTab: setWindowTitle(tr(
"Choose the address to send coins to"));
break;
52 case ReceivingTab: setWindowTitle(tr(
"Choose the address to receive coins with"));
break;
54 connect(
ui->tableView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(accept()));
55 ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
56 ui->tableView->setFocus();
57 ui->closeButton->setText(tr(
"C&hoose"));
58 ui->exportButton->hide();
63 case SendingTab: setWindowTitle(tr(
"Sending addresses"));
break;
64 case ReceivingTab: setWindowTitle(tr(
"Receiving addresses"));
break;
71 ui->labelExplanation->setText(tr(
"These are your Raven addresses for sending payments. Always check the amount and the receiving address before sending coins."));
72 ui->deleteAddress->setVisible(
true);
75 ui->labelExplanation->setText(tr(
"These are your Raven addresses for receiving payments. It is recommended to use a new receiving address for each transaction."));
76 ui->deleteAddress->setVisible(
false);
81 QAction *copyAddressAction =
new QAction(tr(
"&Copy Address"),
this);
82 QAction *copyLabelAction =
new QAction(tr(
"Copy &Label"),
this);
83 QAction *editAction =
new QAction(tr(
"&Edit"),
this);
88 contextMenu->addAction(copyAddressAction);
89 contextMenu->addAction(copyLabelAction);
90 contextMenu->addAction(editAction);
93 contextMenu->addSeparator();
98 connect(editAction, SIGNAL(triggered()),
this, SLOT(
onEditAction()));
101 connect(
ui->tableView, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(
contextualMenu(QPoint)));
103 connect(
ui->closeButton, SIGNAL(clicked()),
this, SLOT(accept()));
113 this->
model = _model;
120 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
121 proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
136 ui->tableView->sortByColumn(0, Qt::AscendingOrder);
139 #if QT_VERSION < 0x050000 147 connect(
ui->tableView->selectionModel(), SIGNAL(
selectionChanged(QItemSelection,QItemSelection)),
151 connect(_model, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
this, SLOT(
selectNewAddress(QModelIndex,
int,
int)));
171 if(!
ui->tableView->selectionModel())
173 QModelIndexList indexes =
ui->tableView->selectionModel()->selectedRows();
174 if(indexes.isEmpty())
182 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
205 QTableView *table =
ui->tableView;
206 if(!table->selectionModel())
209 QModelIndexList indexes = table->selectionModel()->selectedRows();
210 if(!indexes.isEmpty())
212 table->model()->removeRow(indexes.at(0).row());
219 QTableView *table =
ui->tableView;
220 if(!table->selectionModel())
223 if(table->selectionModel()->hasSelection())
229 ui->deleteAddress->setEnabled(
true);
230 ui->deleteAddress->setVisible(
true);
235 ui->deleteAddress->setEnabled(
false);
236 ui->deleteAddress->setVisible(
false);
240 ui->copyAddress->setEnabled(
true);
244 ui->deleteAddress->setEnabled(
false);
245 ui->copyAddress->setEnabled(
false);
251 QTableView *table =
ui->tableView;
252 if(!table->selectionModel() || !table->model())
258 for (
const QModelIndex& index : indexes) {
259 QVariant address = table->model()->data(index);
269 QDialog::done(retval);
276 tr(
"Export Address List"), QString(),
277 tr(
"Comma separated file (*.csv)"),
nullptr);
279 if (filename.isNull())
289 if(!writer.
write()) {
290 QMessageBox::critical(
this, tr(
"Exporting Failed"),
291 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
297 QModelIndex index =
ui->tableView->indexAt(point);
310 ui->tableView->setFocus();
311 ui->tableView->selectRow(idx.row());
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)
QModelIndex index(int row, int column, const QModelIndex &parent) const
void setModel(AddressTableModel *model)
void onEditAction()
Edit currently selected address entry (no button)
AddressTableModel * model
AddressBookPage(const PlatformStyle *platformStyle, Mode mode, Tabs tab, QWidget *parent)
QSortFilterProxyModel * proxyModel
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)
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 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.
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.
bool write()
Perform export of the model to CSV.
Type of address (Send or Receive)