@@ -54,6 +54,30 @@ struct TxLessThan
54
54
}
55
55
};
56
56
57
+ // queue notifications to show a non freezing progress dialog e.g. for rescan
58
+ struct TransactionNotification
59
+ {
60
+ public:
61
+ TransactionNotification () {}
62
+ TransactionNotification (uint256 _hash, ChangeType _status, bool _showTransaction):
63
+ hash (_hash), status(_status), showTransaction(_showTransaction) {}
64
+
65
+ void invoke (QObject *ttm)
66
+ {
67
+ QString strHash = QString::fromStdString (hash.GetHex ());
68
+ qDebug () << " NotifyTransactionChanged: " + strHash + " status= " + QString::number (status);
69
+ bool invoked = QMetaObject::invokeMethod (ttm, " updateTransaction" , Qt::QueuedConnection,
70
+ Q_ARG (QString, strHash),
71
+ Q_ARG (int , status),
72
+ Q_ARG (bool , showTransaction));
73
+ assert (invoked);
74
+ }
75
+ private:
76
+ uint256 hash;
77
+ ChangeType status;
78
+ bool showTransaction;
79
+ };
80
+
57
81
// Private implementation
58
82
class TransactionTablePriv
59
83
{
@@ -71,6 +95,12 @@ class TransactionTablePriv
71
95
*/
72
96
QList<TransactionRecord> cachedWallet;
73
97
98
+ bool fQueueNotifications = false ;
99
+ std::vector< TransactionNotification > vQueueNotifications;
100
+
101
+ void NotifyTransactionChanged (const uint256 &hash, ChangeType status);
102
+ void ShowProgress (const std::string &title, int nProgress);
103
+
74
104
/* Query entire wallet anew from core.
75
105
*/
76
106
void refreshWallet (interfaces::Wallet& wallet)
@@ -674,34 +704,7 @@ void TransactionTableModel::updateDisplayUnit()
674
704
Q_EMIT dataChanged (index (0 , Amount), index (priv->size ()-1 , Amount));
675
705
}
676
706
677
- // queue notifications to show a non freezing progress dialog e.g. for rescan
678
- struct TransactionNotification
679
- {
680
- public:
681
- TransactionNotification () {}
682
- TransactionNotification (uint256 _hash, ChangeType _status, bool _showTransaction):
683
- hash (_hash), status(_status), showTransaction(_showTransaction) {}
684
-
685
- void invoke (QObject *ttm)
686
- {
687
- QString strHash = QString::fromStdString (hash.GetHex ());
688
- qDebug () << " NotifyTransactionChanged: " + strHash + " status= " + QString::number (status);
689
- bool invoked = QMetaObject::invokeMethod (ttm, " updateTransaction" , Qt::QueuedConnection,
690
- Q_ARG (QString, strHash),
691
- Q_ARG (int , status),
692
- Q_ARG (bool , showTransaction));
693
- assert (invoked);
694
- }
695
- private:
696
- uint256 hash;
697
- ChangeType status;
698
- bool showTransaction;
699
- };
700
-
701
- static bool fQueueNotifications = false ;
702
- static std::vector< TransactionNotification > vQueueNotifications;
703
-
704
- static void NotifyTransactionChanged (TransactionTableModel *ttm, const uint256 &hash, ChangeType status)
707
+ void TransactionTablePriv::NotifyTransactionChanged (const uint256 &hash, ChangeType status)
705
708
{
706
709
// Find transaction in wallet
707
710
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
@@ -714,10 +717,10 @@ static void NotifyTransactionChanged(TransactionTableModel *ttm, const uint256 &
714
717
vQueueNotifications.push_back (notification);
715
718
return ;
716
719
}
717
- notification.invoke (ttm );
720
+ notification.invoke (parent );
718
721
}
719
722
720
- static void ShowProgress (TransactionTableModel *ttm, const std::string &title, int nProgress)
723
+ void TransactionTablePriv:: ShowProgress (const std::string &title, int nProgress)
721
724
{
722
725
if (nProgress == 0 )
723
726
fQueueNotifications = true ;
@@ -726,27 +729,27 @@ static void ShowProgress(TransactionTableModel *ttm, const std::string &title, i
726
729
{
727
730
fQueueNotifications = false ;
728
731
if (vQueueNotifications.size () > 10 ) { // prevent balloon spam, show maximum 10 balloons
729
- bool invoked = QMetaObject::invokeMethod (ttm , " setProcessingQueuedTransactions" , Qt::QueuedConnection, Q_ARG (bool , true ));
732
+ bool invoked = QMetaObject::invokeMethod (parent , " setProcessingQueuedTransactions" , Qt::QueuedConnection, Q_ARG (bool , true ));
730
733
assert (invoked);
731
734
}
732
735
for (unsigned int i = 0 ; i < vQueueNotifications.size (); ++i)
733
736
{
734
737
if (vQueueNotifications.size () - i <= 10 ) {
735
- bool invoked = QMetaObject::invokeMethod (ttm , " setProcessingQueuedTransactions" , Qt::QueuedConnection, Q_ARG (bool , false ));
738
+ bool invoked = QMetaObject::invokeMethod (parent , " setProcessingQueuedTransactions" , Qt::QueuedConnection, Q_ARG (bool , false ));
736
739
assert (invoked);
737
740
}
738
741
739
- vQueueNotifications[i].invoke (ttm );
742
+ vQueueNotifications[i].invoke (parent );
740
743
}
741
- std::vector<TransactionNotification >(). swap (vQueueNotifications); // clear
744
+ vQueueNotifications. clear ();
742
745
}
743
746
}
744
747
745
748
void TransactionTableModel::subscribeToCoreSignals ()
746
749
{
747
750
// Connect signals to wallet
748
- m_handler_transaction_changed = walletModel->wallet ().handleTransactionChanged (std::bind (NotifyTransactionChanged, this , std::placeholders::_1, std::placeholders::_2));
749
- m_handler_show_progress = walletModel->wallet ().handleShowProgress (std::bind (ShowProgress, this , std::placeholders::_1, std::placeholders::_2));
751
+ m_handler_transaction_changed = walletModel->wallet ().handleTransactionChanged (std::bind (&TransactionTablePriv:: NotifyTransactionChanged, priv , std::placeholders::_1, std::placeholders::_2));
752
+ m_handler_show_progress = walletModel->wallet ().handleShowProgress (std::bind (&TransactionTablePriv:: ShowProgress, priv , std::placeholders::_1, std::placeholders::_2));
750
753
}
751
754
752
755
void TransactionTableModel::unsubscribeFromCoreSignals ()
0 commit comments