Changeset View
Changeset View
Standalone View
Standalone View
src/qt/addressbookpage.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | switch (mode) { | ||||
case SendingTab: | case SendingTab: | ||||
setWindowTitle(tr("Choose the address to send coins to")); | setWindowTitle(tr("Choose the address to send coins to")); | ||||
break; | break; | ||||
case ReceivingTab: | case ReceivingTab: | ||||
setWindowTitle( | setWindowTitle( | ||||
tr("Choose the address to receive coins with")); | tr("Choose the address to receive coins with")); | ||||
break; | break; | ||||
} | } | ||||
connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, | connect(ui->tableView, &QTableView::doubleClicked, this, | ||||
SLOT(accept())); | &QDialog::accept); | ||||
ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); | ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); | ||||
ui->tableView->setFocus(); | ui->tableView->setFocus(); | ||||
ui->closeButton->setText(tr("C&hoose")); | ui->closeButton->setText(tr("C&hoose")); | ||||
ui->exportButton->hide(); | ui->exportButton->hide(); | ||||
break; | break; | ||||
case ForEditing: | case ForEditing: | ||||
switch (tab) { | switch (tab) { | ||||
case SendingTab: | case SendingTab: | ||||
Show All 36 Lines | AddressBookPage::AddressBookPage(const PlatformStyle *platformStyle, Mode _mode, | ||||
contextMenu->addAction(copyLabelAction); | contextMenu->addAction(copyLabelAction); | ||||
contextMenu->addAction(editAction); | contextMenu->addAction(editAction); | ||||
if (tab == SendingTab) { | if (tab == SendingTab) { | ||||
contextMenu->addAction(deleteAction); | contextMenu->addAction(deleteAction); | ||||
} | } | ||||
contextMenu->addSeparator(); | contextMenu->addSeparator(); | ||||
// Connect signals for context menu actions | // Connect signals for context menu actions | ||||
connect(copyAddressAction, SIGNAL(triggered()), this, | connect(copyAddressAction, &QAction::triggered, this, | ||||
SLOT(on_copyAddress_clicked())); | &AddressBookPage::on_copyAddress_clicked); | ||||
connect(copyLabelAction, SIGNAL(triggered()), this, | connect(copyLabelAction, &QAction::triggered, this, | ||||
SLOT(onCopyLabelAction())); | &AddressBookPage::onCopyLabelAction); | ||||
connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); | connect(editAction, &QAction::triggered, this, | ||||
connect(deleteAction, SIGNAL(triggered()), this, | &AddressBookPage::onEditAction); | ||||
SLOT(on_deleteAddress_clicked())); | connect(deleteAction, &QAction::triggered, this, | ||||
&AddressBookPage::on_deleteAddress_clicked); | |||||
connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, | connect(ui->tableView, &QWidget::customContextMenuRequested, this, | ||||
SLOT(contextualMenu(QPoint))); | &AddressBookPage::contextualMenu); | ||||
connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept())); | connect(ui->closeButton, &QPushButton::clicked, this, &QDialog::accept); | ||||
} | } | ||||
AddressBookPage::~AddressBookPage() { | AddressBookPage::~AddressBookPage() { | ||||
delete ui; | delete ui; | ||||
} | } | ||||
void AddressBookPage::setModel(AddressTableModel *_model) { | void AddressBookPage::setModel(AddressTableModel *_model) { | ||||
this->model = _model; | this->model = _model; | ||||
if (!_model) { | if (!_model) { | ||||
return; | return; | ||||
} | } | ||||
auto type = tab == ReceivingTab ? AddressTableModel::Receive | auto type = tab == ReceivingTab ? AddressTableModel::Receive | ||||
: AddressTableModel::Send; | : AddressTableModel::Send; | ||||
proxyModel = new AddressBookSortFilterProxyModel(type, this); | proxyModel = new AddressBookSortFilterProxyModel(type, this); | ||||
proxyModel->setSourceModel(_model); | proxyModel->setSourceModel(_model); | ||||
connect(ui->searchLineEdit, SIGNAL(textChanged(QString)), proxyModel, | connect(ui->searchLineEdit, &QLineEdit::textChanged, proxyModel, | ||||
SLOT(setFilterWildcard(QString))); | &QSortFilterProxyModel::setFilterWildcard); | ||||
ui->tableView->setModel(proxyModel); | ui->tableView->setModel(proxyModel); | ||||
ui->tableView->sortByColumn(0, Qt::AscendingOrder); | ui->tableView->sortByColumn(0, Qt::AscendingOrder); | ||||
// Set column widths | // Set column widths | ||||
ui->tableView->horizontalHeader()->setSectionResizeMode( | ui->tableView->horizontalHeader()->setSectionResizeMode( | ||||
AddressTableModel::Label, QHeaderView::Stretch); | AddressTableModel::Label, QHeaderView::Stretch); | ||||
ui->tableView->horizontalHeader()->setSectionResizeMode( | ui->tableView->horizontalHeader()->setSectionResizeMode( | ||||
AddressTableModel::Address, QHeaderView::ResizeToContents); | AddressTableModel::Address, QHeaderView::ResizeToContents); | ||||
connect(ui->tableView->selectionModel(), | connect(ui->tableView->selectionModel(), | ||||
SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, | &QItemSelectionModel::selectionChanged, this, | ||||
SLOT(selectionChanged())); | &AddressBookPage::selectionChanged); | ||||
// Select row for newly created address | // Select row for newly created address | ||||
connect(_model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, | connect(_model, &AddressTableModel::rowsInserted, this, | ||||
SLOT(selectNewAddress(QModelIndex, int, int))); | &AddressBookPage::selectNewAddress); | ||||
selectionChanged(); | selectionChanged(); | ||||
} | } | ||||
void AddressBookPage::on_copyAddress_clicked() { | void AddressBookPage::on_copyAddress_clicked() { | ||||
GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); | GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |