Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | connect(ui->pushButtonSelectAll, &QPushButton::clicked, this, | ||||
&CoinControlDialog::buttonSelectAllClicked); | &CoinControlDialog::buttonSelectAllClicked); | ||||
ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); | ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); | ||||
ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 110); | ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 110); | ||||
ui->treeWidget->setColumnWidth(COLUMN_LABEL, 190); | ui->treeWidget->setColumnWidth(COLUMN_LABEL, 190); | ||||
ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 320); | ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 320); | ||||
ui->treeWidget->setColumnWidth(COLUMN_DATE, 130); | ui->treeWidget->setColumnWidth(COLUMN_DATE, 130); | ||||
ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 110); | ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 110); | ||||
// store transaction hash in this column, but don't show it | |||||
ui->treeWidget->setColumnHidden(COLUMN_TXID, true); | |||||
// store vout index in this column, but don't show it | |||||
ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); | |||||
// default view is sorted by amount desc | // default view is sorted by amount desc | ||||
sortView(COLUMN_AMOUNT, Qt::DescendingOrder); | sortView(COLUMN_AMOUNT, Qt::DescendingOrder); | ||||
// restore list mode and sortorder as a convenience feature | // restore list mode and sortorder as a convenience feature | ||||
QSettings settings; | QSettings settings; | ||||
if (settings.contains("nCoinControlMode") && | if (settings.contains("nCoinControlMode") && | ||||
!settings.value("nCoinControlMode").toBool()) { | !settings.value("nCoinControlMode").toBool()) { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
// context menu | // context menu | ||||
void CoinControlDialog::showMenu(const QPoint &point) { | void CoinControlDialog::showMenu(const QPoint &point) { | ||||
QTreeWidgetItem *item = ui->treeWidget->itemAt(point); | QTreeWidgetItem *item = ui->treeWidget->itemAt(point); | ||||
if (item) { | if (item) { | ||||
contextMenuItem = item; | contextMenuItem = item; | ||||
// disable some items (like Copy Transaction ID, lock, unlock) for tree | // disable some items (like Copy Transaction ID, lock, unlock) for tree | ||||
// roots in context menu | // roots in context menu | ||||
if (item->text(COLUMN_TXID).length() == 64) { | if (item->data(COLUMN_ADDRESS, TxIdRole).toString().length() == 64) { | ||||
COutPoint outpoint = buildOutPoint(item); | COutPoint outpoint = buildOutPoint(item); | ||||
// transaction hash is 64 characters (this means it is a child node, | // transaction hash is 64 characters (this means it is a child node, | ||||
// so it is not a parent node in tree mode) | // so it is not a parent node in tree mode) | ||||
copyTransactionHashAction->setEnabled(true); | copyTransactionHashAction->setEnabled(true); | ||||
if (model->wallet().isLockedCoin(outpoint)) { | if (model->wallet().isLockedCoin(outpoint)) { | ||||
lockAction->setEnabled(false); | lockAction->setEnabled(false); | ||||
unlockAction->setEnabled(true); | unlockAction->setEnabled(true); | ||||
Show All 38 Lines | if (ui->radioTreeMode->isChecked() && | ||||
GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_ADDRESS)); | GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_ADDRESS)); | ||||
} else { | } else { | ||||
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS)); | GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS)); | ||||
} | } | ||||
} | } | ||||
// context menu action: copy transaction id | // context menu action: copy transaction id | ||||
void CoinControlDialog::copyTransactionHash() { | void CoinControlDialog::copyTransactionHash() { | ||||
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXID)); | GUIUtil::setClipboard( | ||||
contextMenuItem->data(COLUMN_ADDRESS, TxIdRole).toString()); | |||||
} | } | ||||
// context menu action: lock coin | // context menu action: lock coin | ||||
void CoinControlDialog::lockCoin() { | void CoinControlDialog::lockCoin() { | ||||
if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) { | if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) { | ||||
contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | if (checked && model) { | ||||
updateView(); | updateView(); | ||||
} | } | ||||
} | } | ||||
// checkbox clicked by user | // checkbox clicked by user | ||||
void CoinControlDialog::viewItemChanged(QTreeWidgetItem *item, int column) { | void CoinControlDialog::viewItemChanged(QTreeWidgetItem *item, int column) { | ||||
// transaction hash is 64 characters (this means it is a child node, so it | // transaction hash is 64 characters (this means it is a child node, so it | ||||
// is not a parent node in tree mode) | // is not a parent node in tree mode) | ||||
if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXID).length() == 64) { | if (column == COLUMN_CHECKBOX && | ||||
item->data(COLUMN_ADDRESS, TxIdRole).toString().length() == 64) { | |||||
COutPoint outpoint = buildOutPoint(item); | COutPoint outpoint = buildOutPoint(item); | ||||
if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) { | if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) { | ||||
coinControl()->UnSelect(outpoint); | coinControl()->UnSelect(outpoint); | ||||
} else if (item->isDisabled()) { | } else if (item->isDisabled()) { | ||||
// locked (this happens if "check all" through parent node) | // locked (this happens if "check all" through parent node) | ||||
item->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | item->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
CCoinControl *CoinControlDialog::coinControl() { | CCoinControl *CoinControlDialog::coinControl() { | ||||
static CCoinControl coin_control; | static CCoinControl coin_control; | ||||
return &coin_control; | return &coin_control; | ||||
} | } | ||||
COutPoint CoinControlDialog::buildOutPoint(const QTreeWidgetItem *item) { | COutPoint CoinControlDialog::buildOutPoint(const QTreeWidgetItem *item) { | ||||
TxId txid; | TxId txid; | ||||
txid.SetHex(item->text(COLUMN_TXID).toStdString()); | txid.SetHex(item->data(COLUMN_ADDRESS, TxIdRole).toString().toStdString()); | ||||
return COutPoint(txid, item->text(COLUMN_VOUT_INDEX).toUInt()); | return COutPoint(txid, item->data(COLUMN_ADDRESS, VOutRole).toUInt()); | ||||
} | } | ||||
void CoinControlDialog::updateView() { | void CoinControlDialog::updateView() { | ||||
if (!model || !model->getOptionsModel() || !model->getAddressTableModel()) { | if (!model || !model->getOptionsModel() || !model->getAddressTableModel()) { | ||||
return; | return; | ||||
} | } | ||||
bool treeMode = ui->radioTreeMode->isChecked(); | bool treeMode = ui->radioTreeMode->isChecked(); | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | for (const auto &coins : model->wallet().listCoins()) { | ||||
// confirmations | // confirmations | ||||
itemOutput->setText(COLUMN_CONFIRMATIONS, | itemOutput->setText(COLUMN_CONFIRMATIONS, | ||||
QString::number(out.depth_in_main_chain)); | QString::number(out.depth_in_main_chain)); | ||||
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, | itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, | ||||
QVariant((qlonglong)out.depth_in_main_chain)); | QVariant((qlonglong)out.depth_in_main_chain)); | ||||
// transaction id | // transaction id | ||||
itemOutput->setText( | itemOutput->setData( | ||||
COLUMN_TXID, QString::fromStdString(output.GetTxId().GetHex())); | COLUMN_ADDRESS, TxIdRole, | ||||
QString::fromStdString(output.GetTxId().GetHex())); | |||||
// vout index | // vout index | ||||
itemOutput->setText(COLUMN_VOUT_INDEX, | itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.GetN()); | ||||
QString::number(output.GetN())); | |||||
// disable locked coins | // disable locked coins | ||||
if (model->wallet().isLockedCoin(output)) { | if (model->wallet().isLockedCoin(output)) { | ||||
// just to be sure | // just to be sure | ||||
coinControl()->UnSelect(output); | coinControl()->UnSelect(output); | ||||
itemOutput->setDisabled(true); | itemOutput->setDisabled(true); | ||||
itemOutput->setIcon( | itemOutput->setIcon( | ||||
COLUMN_CHECKBOX, | COLUMN_CHECKBOX, | ||||
Show All 34 Lines |