Changeset View
Changeset View
Standalone View
Standalone View
src/qt/coincontroldialog.cpp
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | if (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_TXHASH).length() == 64) { | if (item->text(COLUMN_TXHASH).length() == 64) { | ||||
// transaction hash is 64 characters (this means its a child node, | // transaction hash is 64 characters (this means its a child node, | ||||
// so its not a parent node in tree mode) | // so its not a parent node in tree mode) | ||||
copyTransactionHashAction->setEnabled(true); | copyTransactionHashAction->setEnabled(true); | ||||
if (model->isLockedCoin( | if (model->isLockedCoin( | ||||
uint256S(item->text(COLUMN_TXHASH).toStdString()), | txhash_t(uint256S(item->text(COLUMN_TXHASH).toStdString())), | ||||
item->text(COLUMN_VOUT_INDEX).toUInt())) { | item->text(COLUMN_VOUT_INDEX).toUInt())) { | ||||
lockAction->setEnabled(false); | lockAction->setEnabled(false); | ||||
unlockAction->setEnabled(true); | unlockAction->setEnabled(true); | ||||
} else { | } else { | ||||
lockAction->setEnabled(true); | lockAction->setEnabled(true); | ||||
unlockAction->setEnabled(false); | unlockAction->setEnabled(false); | ||||
} | } | ||||
} else { | } else { | ||||
Show All 39 Lines | void CoinControlDialog::copyTransactionHash() { | ||||
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH)); | GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH)); | ||||
} | } | ||||
// 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); | ||||
COutPoint outpt( | COutPoint outpt(unspentid_t(uint256S( | ||||
uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | contextMenuItem->text(COLUMN_TXHASH).toStdString())), | ||||
contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | ||||
model->lockCoin(outpt); | model->lockCoin(outpt); | ||||
contextMenuItem->setDisabled(true); | contextMenuItem->setDisabled(true); | ||||
contextMenuItem->setIcon( | contextMenuItem->setIcon( | ||||
COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); | COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); | ||||
updateLabelLocked(); | updateLabelLocked(); | ||||
} | } | ||||
// context menu action: unlock coin | // context menu action: unlock coin | ||||
void CoinControlDialog::unlockCoin() { | void CoinControlDialog::unlockCoin() { | ||||
COutPoint outpt( | COutPoint outpt(unspentid_t(uint256S( | ||||
uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), | contextMenuItem->text(COLUMN_TXHASH).toStdString())), | ||||
contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); | ||||
model->unlockCoin(outpt); | model->unlockCoin(outpt); | ||||
contextMenuItem->setDisabled(false); | contextMenuItem->setDisabled(false); | ||||
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); | contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); | ||||
updateLabelLocked(); | updateLabelLocked(); | ||||
} | } | ||||
// copy label "Quantity" to clipboard | // copy label "Quantity" to clipboard | ||||
void CoinControlDialog::clipboardQuantity() { | void CoinControlDialog::clipboardQuantity() { | ||||
▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | void CoinControlDialog::radioListMode(bool checked) { | ||||
if (checked && model) updateView(); | if (checked && model) 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 its a child node, so its | // transaction hash is 64 characters (this means its a child node, so its | ||||
// not a parent node in tree mode) | // not a parent node in tree mode) | ||||
if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) { | if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) { | ||||
COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), | COutPoint outpt( | ||||
unspentid_t(uint256S(item->text(COLUMN_TXHASH).toStdString())), | |||||
item->text(COLUMN_VOUT_INDEX).toUInt()); | item->text(COLUMN_VOUT_INDEX).toUInt()); | ||||
if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) { | if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) { | ||||
coinControl->UnSelect(outpt); | coinControl->UnSelect(outpt); | ||||
} 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 { | ||||
coinControl->Select(outpt); | coinControl->Select(outpt); | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | void CoinControlDialog::updateLabels(WalletModel *model, QDialog *dialog) { | ||||
std::vector<COutPoint> vCoinControl; | std::vector<COutPoint> vCoinControl; | ||||
std::vector<COutput> vOutputs; | std::vector<COutput> vOutputs; | ||||
coinControl->ListSelected(vCoinControl); | coinControl->ListSelected(vCoinControl); | ||||
model->getOutputs(vCoinControl, vOutputs); | model->getOutputs(vCoinControl, vOutputs); | ||||
for (const COutput &out : vOutputs) { | for (const COutput &out : vOutputs) { | ||||
// unselect already spent, very unlikely scenario, this could happen | // unselect already spent, very unlikely scenario, this could happen | ||||
// when selected are spent elsewhere, like rpc or another computer | // when selected are spent elsewhere, like rpc or another computer | ||||
uint256 txhash = out.tx->GetId(); | unspentid_t txhash = out.tx->tx->GetUnspentid(); | ||||
COutPoint outpt(txhash, out.i); | COutPoint outpt(txhash, out.i); | ||||
if (model->isSpent(outpt)) { | if (model->isSpent(outpt)) { | ||||
coinControl->UnSelect(outpt); | coinControl->UnSelect(outpt); | ||||
continue; | continue; | ||||
} | } | ||||
// Quantity | // Quantity | ||||
nQuantity++; | nQuantity++; | ||||
▲ Show 20 Lines • Show All 294 Lines • ▼ Show 20 Lines | for (const std::pair<QString, std::vector<COutput>> &coins : mapCoins) { | ||||
// confirmations | // confirmations | ||||
itemOutput->setText(COLUMN_CONFIRMATIONS, | itemOutput->setText(COLUMN_CONFIRMATIONS, | ||||
QString::number(out.nDepth)); | QString::number(out.nDepth)); | ||||
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, | itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, | ||||
QVariant((qlonglong)out.nDepth)); | QVariant((qlonglong)out.nDepth)); | ||||
// transaction hash | // transaction hash | ||||
uint256 txhash = out.tx->GetId(); | txhash_t txhash = out.tx->GetHash(); | ||||
itemOutput->setText(COLUMN_TXHASH, | itemOutput->setText(COLUMN_TXHASH, | ||||
QString::fromStdString(txhash.GetHex())); | QString::fromStdString(txhash.GetHex())); | ||||
// vout index | // vout index | ||||
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); | itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); | ||||
// disable locked coins | // disable locked coins | ||||
if (model->isLockedCoin(txhash, out.i)) { | if (model->isLockedCoin(txhash, out.i)) { | ||||
COutPoint outpt(txhash, out.i); | COutPoint outpt(out.tx->tx->GetUnspentid(), out.i); | ||||
// just to be sure | // just to be sure | ||||
coinControl->UnSelect(outpt); | coinControl->UnSelect(outpt); | ||||
itemOutput->setDisabled(true); | itemOutput->setDisabled(true); | ||||
itemOutput->setIcon( | itemOutput->setIcon( | ||||
COLUMN_CHECKBOX, | COLUMN_CHECKBOX, | ||||
platformStyle->SingleColorIcon(":/icons/lock_closed")); | platformStyle->SingleColorIcon(":/icons/lock_closed")); | ||||
} | } | ||||
// set checkbox | // set checkbox | ||||
if (coinControl->IsSelected(COutPoint(txhash, out.i))) { | if (coinControl->IsSelected( | ||||
COutPoint(out.tx->tx->GetUnspentid(), out.i))) { | |||||
itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); | itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); | ||||
} | } | ||||
} | } | ||||
// amount | // amount | ||||
if (treeMode) { | if (treeMode) { | ||||
itemWalletAddress->setText(COLUMN_CHECKBOX, | itemWalletAddress->setText(COLUMN_CHECKBOX, | ||||
"(" + QString::number(nChildren) + ")"); | "(" + QString::number(nChildren) + ")"); | ||||
Show All 19 Lines |