Merge #14828: qt: Remove hidden columns in coin control dialog
1c28feb7d
qt: Remove hidden columns in coin control dialog (João Barbosa)
Pull request description:
Instead of having hidden columns, store the data in specific roles.
Overlaps with #14817, fixes #11811.
Tree-SHA512: e86e9ca426b9146ac28997ca1920dbae6cc4e2e494ff94fe131d605cd6c013183fc5de10036c886a4d6dcae497ac4067de3791be0ef9c88f7ce9f57f7bd97422
This commit is contained in:
commit
64fc7c0c1b
3 changed files with 17 additions and 14 deletions
|
@ -129,8 +129,6 @@ CoinControlDialog::CoinControlDialog(const PlatformStyle *_platformStyle, QWidge
|
|||
ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 320);
|
||||
ui->treeWidget->setColumnWidth(COLUMN_DATE, 130);
|
||||
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
|
||||
sortView(COLUMN_AMOUNT, Qt::DescendingOrder);
|
||||
|
@ -203,10 +201,10 @@ void CoinControlDialog::showMenu(const QPoint &point)
|
|||
contextMenuItem = item;
|
||||
|
||||
// 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);
|
||||
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);
|
||||
unlockAction->setEnabled(true);
|
||||
|
@ -256,7 +254,7 @@ void CoinControlDialog::copyAddress()
|
|||
// context menu action: copy transaction id
|
||||
void CoinControlDialog::copyTransactionHash()
|
||||
{
|
||||
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH));
|
||||
GUIUtil::setClipboard(contextMenuItem->data(COLUMN_ADDRESS, TxHashRole).toString());
|
||||
}
|
||||
|
||||
// context menu action: lock coin
|
||||
|
@ -265,7 +263,7 @@ void CoinControlDialog::lockCoin()
|
|||
if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked)
|
||||
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);
|
||||
contextMenuItem->setDisabled(true);
|
||||
contextMenuItem->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/icons/lock_closed"));
|
||||
|
@ -275,7 +273,7 @@ void CoinControlDialog::lockCoin()
|
|||
// context menu action: unlock coin
|
||||
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);
|
||||
contextMenuItem->setDisabled(false);
|
||||
contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon());
|
||||
|
@ -371,9 +369,9 @@ void CoinControlDialog::radioListMode(bool checked)
|
|||
// checkbox clicked by user
|
||||
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)
|
||||
coinControl()->UnSelect(outpt);
|
||||
|
@ -693,10 +691,10 @@ void CoinControlDialog::updateView()
|
|||
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)out.depth_in_main_chain));
|
||||
|
||||
// transaction hash
|
||||
itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(output.hash.GetHex()));
|
||||
itemOutput->setData(COLUMN_ADDRESS, TxHashRole, QString::fromStdString(output.hash.GetHex()));
|
||||
|
||||
// vout index
|
||||
itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(output.n));
|
||||
itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.n);
|
||||
|
||||
// disable locked coins
|
||||
if (model->wallet().isLockedCoin(output))
|
||||
|
|
|
@ -80,9 +80,14 @@ private:
|
|||
COLUMN_ADDRESS,
|
||||
COLUMN_DATE,
|
||||
COLUMN_CONFIRMATIONS,
|
||||
COLUMN_TXHASH,
|
||||
COLUMN_VOUT_INDEX,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TxHashRole = Qt::UserRole,
|
||||
VOutRole
|
||||
};
|
||||
|
||||
friend class CCoinControlWidgetItem;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
|
|
@ -402,7 +402,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>10</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
|
|
Loading…
Reference in a new issue