Skip to content

Commit

Permalink
Fixes to the QT code to allow the use of robin hood in the wallet model
Browse files Browse the repository at this point in the history
  • Loading branch information
teamswipp committed Sep 1, 2020
1 parent eece840 commit 4ba08d6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
10 changes: 9 additions & 1 deletion src/qt/addeditadrenalinenode.cpp
@@ -1,3 +1,8 @@
// Copyright (c) 2015-2020 The Neutron Developers
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "addeditadrenalinenode.h"
#include "ui_addeditadrenalinenode.h"

Expand Down Expand Up @@ -66,14 +71,17 @@ void AddEditAdrenalineNode::on_okButton_clicked()
{
CScript scriptPubKey;
scriptPubKey.SetDestination(account.vchPubKey.GetID());
for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin();
for (auto it = pwalletMain->mapWallet.begin();
it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid();
++it)
{
const CWalletTx& wtx = (*it).second;

BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
if (txout.scriptPubKey == scriptPubKey)
bKeyUsed = true;
}
}
}

Expand Down
33 changes: 22 additions & 11 deletions src/qt/transactiontablemodel.cpp
@@ -1,3 +1,8 @@
// Copyright (c) 2015-2020 The Neutron Developers
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "transactiontablemodel.h"
#include "guiutil.h"
#include "transactionrecord.h"
Expand All @@ -21,12 +26,12 @@

// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignRight|Qt::AlignVCenter
};
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignLeft|Qt::AlignVCenter,
Qt::AlignRight|Qt::AlignVCenter
};

// Comparison operator for sort/binary search of model tx list
struct TxLessThan
Expand Down Expand Up @@ -71,7 +76,7 @@ class TransactionTablePriv
cachedWallet.clear();
{
LOCK(wallet->cs_wallet);
for(std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it)
for(auto it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it)
{
if(TransactionRecord::showTransaction(it->second))
cachedWallet.append(TransactionRecord::decomposeTransaction(wallet, it->second));
Expand All @@ -91,14 +96,16 @@ class TransactionTablePriv
LOCK(wallet->cs_wallet);

// Find transaction in wallet
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
auto mi = wallet->mapWallet.find(hash);
bool inWallet = mi != wallet->mapWallet.end();

// Find bounds of this transaction in model
QList<TransactionRecord>::iterator lower = qLowerBound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());

QList<TransactionRecord>::iterator upper = qUpperBound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());

int lowerIndex = (lower - cachedWallet.begin());
int upperIndex = (upper - cachedWallet.begin());
bool inModel = (lower != upper);
Expand Down Expand Up @@ -185,7 +192,7 @@ class TransactionTablePriv
{
{
LOCK(wallet->cs_wallet);
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
auto mi = wallet->mapWallet.find(rec->hash);

if(mi != wallet->mapWallet.end())
{
Expand All @@ -205,7 +212,7 @@ class TransactionTablePriv
{
{
LOCK(wallet->cs_wallet);
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
auto mi = wallet->mapWallet.find(rec->hash);
if(mi != wallet->mapWallet.end())
{
return TransactionDesc::toHTML(wallet, mi->second);
Expand Down Expand Up @@ -473,18 +480,21 @@ QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord *wtx)
QString TransactionTableModel::formatTooltip(const TransactionRecord *rec) const
{
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);

if(rec->type==TransactionRecord::RecvFromOther || rec->type==TransactionRecord::SendToOther ||
rec->type==TransactionRecord::SendToAddress || rec->type==TransactionRecord::RecvWithAddress)
{
tooltip += QString(" ") + formatTxToAddress(rec, true);
}

return tooltip;
}

QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
{
if(!index.isValid())
return QVariant();

TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());

switch(role)
Expand Down Expand Up @@ -581,7 +591,8 @@ QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientat
else if (role == Qt::TextAlignmentRole)
{
return column_alignments[section];
} else if (role == Qt::ToolTipRole)
}
else if (role == Qt::ToolTipRole)
{
switch(section)
{
Expand Down

0 comments on commit 4ba08d6

Please sign in to comment.