@ -78,7 +78,7 @@ public:
qDebug ( ) < < " TransactionTablePriv::refreshWallet " ;
qDebug ( ) < < " TransactionTablePriv::refreshWallet " ;
cachedWallet . clear ( ) ;
cachedWallet . clear ( ) ;
{
{
LOCK ( wallet - > cs_wallet ) ;
LOCK2 ( cs_main , wallet - > cs_wallet ) ;
for ( std : : map < uint256 , CWalletTx > : : iterator it = wallet - > mapWallet . begin ( ) ; it ! = wallet - > mapWallet . end ( ) ; + + it )
for ( std : : map < uint256 , CWalletTx > : : iterator it = wallet - > mapWallet . begin ( ) ; it ! = wallet - > mapWallet . end ( ) ; + + it )
{
{
if ( TransactionRecord : : showTransaction ( it - > second ) )
if ( TransactionRecord : : showTransaction ( it - > second ) )
@ -96,7 +96,7 @@ public:
{
{
qDebug ( ) < < " TransactionTablePriv::updateWallet : " + QString : : fromStdString ( hash . ToString ( ) ) + " " + QString : : number ( status ) ;
qDebug ( ) < < " TransactionTablePriv::updateWallet : " + QString : : fromStdString ( hash . ToString ( ) ) + " " + QString : : number ( status ) ;
{
{
LOCK ( wallet - > cs_wallet ) ;
LOCK2 ( cs_main , wallet - > cs_wallet ) ;
// Find transaction in wallet
// Find transaction in wallet
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( hash ) ;
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( hash ) ;
@ -190,10 +190,9 @@ public:
// If a status update is needed (blocks came in since last check),
// If a status update is needed (blocks came in since last check),
// update the status of this transaction from the wallet. Otherwise,
// update the status of this transaction from the wallet. Otherwise,
// simply re-use the cached status.
// simply re-use the cached status.
LOCK2 ( cs_main , wallet - > cs_wallet ) ;
if ( rec - > statusUpdateNeeded ( ) )
if ( rec - > statusUpdateNeeded ( ) )
{
{
{
LOCK ( wallet - > cs_wallet ) ;
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( rec - > hash ) ;
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( rec - > hash ) ;
if ( mi ! = wallet - > mapWallet . end ( ) )
if ( mi ! = wallet - > mapWallet . end ( ) )
@ -201,7 +200,6 @@ public:
rec - > updateStatus ( mi - > second ) ;
rec - > updateStatus ( mi - > second ) ;
}
}
}
}
}
return rec ;
return rec ;
}
}
else
else
@ -213,7 +211,7 @@ public:
QString describe ( TransactionRecord * rec , int unit )
QString describe ( TransactionRecord * rec , int unit )
{
{
{
{
LOCK ( wallet - > cs_wallet ) ;
LOCK2 ( cs_main , wallet - > cs_wallet ) ;
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( rec - > hash ) ;
std : : map < uint256 , CWalletTx > : : iterator mi = wallet - > mapWallet . find ( rec - > hash ) ;
if ( mi ! = wallet - > mapWallet . end ( ) )
if ( mi ! = wallet - > mapWallet . end ( ) )
{
{
@ -228,17 +226,12 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren
QAbstractTableModel ( parent ) ,
QAbstractTableModel ( parent ) ,
wallet ( wallet ) ,
wallet ( wallet ) ,
walletModel ( parent ) ,
walletModel ( parent ) ,
priv ( new TransactionTablePriv ( wallet , this ) ) ,
priv ( new TransactionTablePriv ( wallet , this ) )
cachedNumBlocks ( 0 )
{
{
columns < < QString ( ) < < tr ( " Date " ) < < tr ( " Type " ) < < tr ( " Address " ) < < tr ( " Amount " ) ;
columns < < QString ( ) < < tr ( " Date " ) < < tr ( " Type " ) < < tr ( " Address " ) < < tr ( " Amount " ) ;
priv - > refreshWallet ( ) ;
priv - > refreshWallet ( ) ;
QTimer * timer = new QTimer ( this ) ;
connect ( timer , SIGNAL ( timeout ( ) ) , this , SLOT ( updateConfirmations ( ) ) ) ;
timer - > start ( MODEL_UPDATE_DELAY ) ;
connect ( walletModel - > getOptionsModel ( ) , SIGNAL ( displayUnitChanged ( int ) ) , this , SLOT ( updateDisplayUnit ( ) ) ) ;
connect ( walletModel - > getOptionsModel ( ) , SIGNAL ( displayUnitChanged ( int ) ) , this , SLOT ( updateDisplayUnit ( ) ) ) ;
}
}
@ -257,9 +250,6 @@ void TransactionTableModel::updateTransaction(const QString &hash, int status)
void TransactionTableModel : : updateConfirmations ( )
void TransactionTableModel : : updateConfirmations ( )
{
{
if ( chainActive . Height ( ) ! = cachedNumBlocks )
{
cachedNumBlocks = chainActive . Height ( ) ;
// Blocks came in since last poll.
// Blocks came in since last poll.
// Invalidate status (number of confirmations) and (possibly) description
// Invalidate status (number of confirmations) and (possibly) description
// for all rows. Qt is smart enough to only actually request the data for the
// for all rows. Qt is smart enough to only actually request the data for the
@ -267,7 +257,6 @@ void TransactionTableModel::updateConfirmations()
emit dataChanged ( index ( 0 , Status ) , index ( priv - > size ( ) - 1 , Status ) ) ;
emit dataChanged ( index ( 0 , Status ) , index ( priv - > size ( ) - 1 , Status ) ) ;
emit dataChanged ( index ( 0 , ToAddress ) , index ( priv - > size ( ) - 1 , ToAddress ) ) ;
emit dataChanged ( index ( 0 , ToAddress ) , index ( priv - > size ( ) - 1 , ToAddress ) ) ;
}
}
}
int TransactionTableModel : : rowCount ( const QModelIndex & parent ) const
int TransactionTableModel : : rowCount ( const QModelIndex & parent ) const
{
{