qt: Remove hidden columns in coin control dialog

This commit is contained in:
João Barbosa 2018-11-28 12:19:04 +00:00
parent 600b85bb41
commit 1c28feb7d0
3 changed files with 17 additions and 14 deletions

View file

@ -129,8 +129,6 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
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);
ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transaction hash in this column, but don't show it
ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but don't show it
// default view is sorted by amount desc // default view is sorted by amount desc
sortView(COLUMN_AMOUNT, Qt::DescendingOrder); sortView(COLUMN_AMOUNT, Qt::DescendingOrder);
@ -203,10 +201,10 @@ void CoinControlDialog::showMenu(const QPoint &point)
contextMenuItem = item; contextMenuItem = item;
// disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu // disable some items (like Copy Transaction ID, lock, unlock) for tree roots in context menu
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) 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)
{ {
copyTransactionHashAction->setEnabled(true); copyTransactionHashAction->setEnabled(true);
if (model->wallet().isLockedCoin(COutPoint(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()))) if (model->wallet().isLockedCoin(COutPoint(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt())))
{ {
lockAction->setEnabled(false); lockAction->setEnabled(false);
unlockAction->setEnabled(true); unlockAction->setEnabled(true);
@ -256,7 +254,7 @@ void CoinControlDialog::copyAddress()
// context menu action: copy transaction id // context menu action: copy transaction id
void CoinControlDialog::copyTransactionHash() void CoinControlDialog::copyTransactionHash()
{ {
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH)); GUIUtil::setClipboard(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString());
} }
// context menu action: lock coin // context menu action: lock coin
@ -265,7 +263,7 @@ 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(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt());
model->wallet().lockCoin(outpt); model->wallet().lockCoin(outpt);
contextMenuItem->setDisabled(true); contextMenuItem->setDisabled(true);
contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed")); contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
@ -275,7 +273,7 @@ void CoinControlDialog::lockCoin()
// context menu action: unlock coin // context menu action: unlock coin
void CoinControlDialog::unlockCoin() void CoinControlDialog::unlockCoin()
{ {
COutPoint outpt(uint256S(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); COutPoint outpt(uint256S(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), contextMenuItem->data(COLUMN_ADDRESS, VOutRole).toUInt());
model->wallet().unlockCoin(outpt); model->wallet().unlockCoin(outpt);
contextMenuItem->setDisabled(false); contextMenuItem->setDisabled(false);
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
@ -371,9 +369,9 @@ void CoinControlDialog::radioListMode(bool checked)
// checkbox clicked by user // checkbox clicked by user
void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column) void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column)
{ {
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) 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)
{ {
COutPoint outpt(uint256S(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt()); COutPoint outpt(uint256S(item->data(COLUMN_ADDRESS, TxHashRole).toString().toStdString()), item->data(COLUMN_ADDRESS, VOutRole).toUInt());
if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked) if (item->checkState(COLUMN_CHECKBOX) == Qt::Unchecked)
coinControl()->UnSelect(outpt); coinControl()->UnSelect(outpt);
@ -693,10 +691,10 @@ void CoinControlDialog::updateView()
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain)); itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain));
// transaction hash // transaction hash
itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(output.hash.GetHex())); itemOutput->setData(COLUMN_ADDRESS, TxHashRole, QString::fromStdString(output.hash.GetHex()));
// vout index // vout index
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(output.n)); itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.n);
// disable locked coins // disable locked coins
if (model->wallet().isLockedCoin(output)) if (model->wallet().isLockedCoin(output))

View file

@ -80,9 +80,14 @@ private:
COLUMN_ADDRESS, COLUMN_ADDRESS,
COLUMN_DATE, COLUMN_DATE,
COLUMN_CONFIRMATIONS, COLUMN_CONFIRMATIONS,
COLUMN_TXHASH,
COLUMN_VOUT_INDEX,
}; };
enum
{
TxHashRole = Qt::UserRole,
VOutRole
};
friend class CCoinControlWidgetItem; friend class CCoinControlWidgetItem;
private Q_SLOTS: private Q_SLOTS:

View file

@ -402,7 +402,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="columnCount"> <property name="columnCount">
<number>10</number> <number>6</number>
</property> </property>
<attribute name="headerShowSortIndicator" stdset="0"> <attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool> <bool>true</bool>