Skip to content

Commit 1c28feb

Browse files
committed
qt: Remove hidden columns in coin control dialog
1 parent 600b85b commit 1c28feb

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

src/qt/coincontroldialog.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
129129
ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 320);
130130
ui->treeWidget->setColumnWidth(COLUMN_DATE, 130);
131131
ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 110);
132-
ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transaction hash in this column, but don't show it
133-
ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but don't show it
134132

135133
// default view is sorted by amount desc
136134
sortView(COLUMN_AMOUNT, Qt::DescendingOrder);
@@ -203,10 +201,10 @@ void CoinControlDialog::showMenu(const QPoint &point)
203201
contextMenuItem = item;
204202

205203
// disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu
206-
if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means it is a child node, so it is not a parent node in tree mode)
204+
if (item->data(COLUMN_ADDRESS, TxHashRole).toString().length() == 64) // transaction hash is 64 characters (this means it is a child node, so it is not a parent node in tree mode)
207205
{
208206
copyTransactionHashAction->setEnabled(true);
209-
if (model->wallet().isLockedCoin(COutPoint(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())))
207+
if (model->wallet().isLockedCoin(COutPoint(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt())))
210208
{
211209
lockAction->setEnabled(false);
212210
unlockAction->setEnabled(true);
@@ -256,7 +254,7 @@ void CoinControlDialog::copyAddress()
256254
// context menu action: copy transaction id
257255
void CoinControlDialog::copyTransactionHash()
258256
{
259-
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH));
257+
GUIUtil::setClipboard(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString());
260258
}
261259

262260
// context menu action: lock coin
@@ -265,7 +263,7 @@ void CoinControlDialog::lockCoin()
265263
if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked)
266264
contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
267265

268-
COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
266+
COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt());
269267
model->wallet().lockCoin(outpt);
270268
contextMenuItem->setDisabled(true);
271269
contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
@@ -275,7 +273,7 @@ void CoinControlDialog::lockCoin()
275273
// context menu action: unlock coin
276274
void CoinControlDialog::unlockCoin()
277275
{
278-
COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt());
276+
COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt());
279277
model->wallet().unlockCoin(outpt);
280278
contextMenuItem->setDisabled(false);
281279
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
@@ -371,9 +369,9 @@ void CoinControlDialog::radioListMode(bool checked)
371369
// checkbox clicked by user
372370
void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
373371
{
374-
if (column == COLUMN_CHECKBOX && item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means it is a child node, so it is not a parent node in tree mode)
372+
if (column == COLUMN_CHECKBOX && item->data(COLUMN_ADDRESS, TxHashRole).toString().length() == 64) // transaction hash is 64 characters (this means it is a child node, so it is not a parent node in tree mode)
375373
{
376-
COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt());
374+
COutPoint outpt(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt());
377375

378376
if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked)
379377
coinControl()->UnSelect(outpt);
@@ -693,10 +691,10 @@ void CoinControlDialog::updateView()
693691
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain));
694692

695693
// transaction hash
696-
itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(output.hash.GetHex()));
694+
itemOutput->setData(COLUMN_ADDRESS, TxHashRole, QString::fromStdString(output.hash.GetHex()));
697695

698696
// vout index
699-
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(output.n));
697+
itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.n);
700698

701699
// disable locked coins
702700
if (model->wallet().isLockedCoin(output))

src/qt/coincontroldialog.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ class CoinControlDialog : public QDialog
8080
COLUMN_ADDRESS,
8181
COLUMN_DATE,
8282
COLUMN_CONFIRMATIONS,
83-
COLUMN_TXHASH,
84-
COLUMN_VOUT_INDEX,
8583
};
84+
85+
enum
86+
{
87+
TxHashRole = Qt::UserRole,
88+
VOutRole
89+
};
90+
8691
friend class CCoinControlWidgetItem;
8792

8893
private Q_SLOTS:

src/qt/forms/coincontroldialog.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@
402402
<bool>false</bool>
403403
</property>
404404
<property name="columnCount">
405-
<number>10</number>
405+
<number>6</number>
406406
</property>
407407
<attribute name="headerShowSortIndicator" stdset="0">
408408
<bool>true</bool>

0 commit comments

Comments
 (0)