Changeset View
Changeset View
Standalone View
Standalone View
src/qt/receivecoinsdialog.cpp
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | void ReceiveCoinsDialog::updateDisplayUnit() { | ||||
if (model && model->getOptionsModel()) { | if (model && model->getOptionsModel()) { | ||||
ui->reqAmount->setDisplayUnit( | ui->reqAmount->setDisplayUnit( | ||||
model->getOptionsModel()->getDisplayUnit()); | model->getOptionsModel()->getDisplayUnit()); | ||||
} | } | ||||
} | } | ||||
void ReceiveCoinsDialog::on_receiveButton_clicked() { | void ReceiveCoinsDialog::on_receiveButton_clicked() { | ||||
if (!model || !model->getOptionsModel() || !model->getAddressTableModel() || | if (!model || !model->getOptionsModel() || !model->getAddressTableModel() || | ||||
!model->getRecentRequestsTableModel()) | !model->getRecentRequestsTableModel()) { | ||||
return; | return; | ||||
} | |||||
QString address; | QString address; | ||||
QString label = ui->reqLabel->text(); | QString label = ui->reqLabel->text(); | ||||
/* Generate new receiving address */ | /* Generate new receiving address */ | ||||
OutputType address_type = model->wallet().getDefaultAddressType(); | OutputType address_type = model->wallet().getDefaultAddressType(); | ||||
address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, | address = model->getAddressTableModel()->addRow(AddressTableModel::Receive, | ||||
label, "", address_type); | label, "", address_type); | ||||
SendCoinsRecipient info(address, label, ui->reqAmount->value(), | SendCoinsRecipient info(address, label, ui->reqAmount->value(), | ||||
Show All 26 Lines | void ReceiveCoinsDialog::recentRequestsView_selectionChanged( | ||||
bool enable = | bool enable = | ||||
!ui->recentRequestsView->selectionModel()->selectedRows().isEmpty(); | !ui->recentRequestsView->selectionModel()->selectedRows().isEmpty(); | ||||
ui->showRequestButton->setEnabled(enable); | ui->showRequestButton->setEnabled(enable); | ||||
ui->removeRequestButton->setEnabled(enable); | ui->removeRequestButton->setEnabled(enable); | ||||
} | } | ||||
void ReceiveCoinsDialog::on_showRequestButton_clicked() { | void ReceiveCoinsDialog::on_showRequestButton_clicked() { | ||||
if (!model || !model->getRecentRequestsTableModel() || | if (!model || !model->getRecentRequestsTableModel() || | ||||
!ui->recentRequestsView->selectionModel()) | !ui->recentRequestsView->selectionModel()) { | ||||
return; | return; | ||||
} | |||||
QModelIndexList selection = | QModelIndexList selection = | ||||
ui->recentRequestsView->selectionModel()->selectedRows(); | ui->recentRequestsView->selectionModel()->selectedRows(); | ||||
for (const QModelIndex &index : selection) { | for (const QModelIndex &index : selection) { | ||||
on_recentRequestsView_doubleClicked(index); | on_recentRequestsView_doubleClicked(index); | ||||
} | } | ||||
} | } | ||||
void ReceiveCoinsDialog::on_removeRequestButton_clicked() { | void ReceiveCoinsDialog::on_removeRequestButton_clicked() { | ||||
if (!model || !model->getRecentRequestsTableModel() || | if (!model || !model->getRecentRequestsTableModel() || | ||||
!ui->recentRequestsView->selectionModel()) | !ui->recentRequestsView->selectionModel()) { | ||||
return; | return; | ||||
} | |||||
QModelIndexList selection = | QModelIndexList selection = | ||||
ui->recentRequestsView->selectionModel()->selectedRows(); | ui->recentRequestsView->selectionModel()->selectedRows(); | ||||
if (selection.empty()) return; | if (selection.empty()) { | ||||
return; | |||||
} | |||||
// correct for selection mode ContiguousSelection | // correct for selection mode ContiguousSelection | ||||
QModelIndex firstIndex = selection.at(0); | QModelIndex firstIndex = selection.at(0); | ||||
model->getRecentRequestsTableModel()->removeRows( | model->getRecentRequestsTableModel()->removeRows( | ||||
firstIndex.row(), selection.length(), firstIndex.parent()); | firstIndex.row(), selection.length(), firstIndex.parent()); | ||||
} | } | ||||
// We override the virtual resizeEvent of the QWidget to adjust tables column | // We override the virtual resizeEvent of the QWidget to adjust tables column | ||||
// sizes as the tables width is proportional to the dialogs width. | // sizes as the tables width is proportional to the dialogs width. | ||||
Show All 13 Lines | if (event->key() == Qt::Key_Return) { | ||||
} | } | ||||
} | } | ||||
this->QDialog::keyPressEvent(event); | this->QDialog::keyPressEvent(event); | ||||
} | } | ||||
QModelIndex ReceiveCoinsDialog::selectedRow() { | QModelIndex ReceiveCoinsDialog::selectedRow() { | ||||
if (!model || !model->getRecentRequestsTableModel() || | if (!model || !model->getRecentRequestsTableModel() || | ||||
!ui->recentRequestsView->selectionModel()) | !ui->recentRequestsView->selectionModel()) { | ||||
return QModelIndex(); | return QModelIndex(); | ||||
} | |||||
QModelIndexList selection = | QModelIndexList selection = | ||||
ui->recentRequestsView->selectionModel()->selectedRows(); | ui->recentRequestsView->selectionModel()->selectedRows(); | ||||
if (selection.empty()) return QModelIndex(); | if (selection.empty()) { | ||||
return QModelIndex(); | |||||
} | |||||
// correct for selection mode ContiguousSelection | // correct for selection mode ContiguousSelection | ||||
QModelIndex firstIndex = selection.at(0); | QModelIndex firstIndex = selection.at(0); | ||||
return firstIndex; | return firstIndex; | ||||
} | } | ||||
// copy column of selected row to clipboard | // copy column of selected row to clipboard | ||||
void ReceiveCoinsDialog::copyColumnToClipboard(int column) { | void ReceiveCoinsDialog::copyColumnToClipboard(int column) { | ||||
QModelIndex firstIndex = selectedRow(); | QModelIndex firstIndex = selectedRow(); | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |