diff options
author | Cozz Lovan <cozzlovan@yahoo.com> | 2014-03-19 00:26:14 +0100 |
---|---|---|
committer | Cozz Lovan <cozzlovan@yahoo.com> | 2014-04-02 03:48:07 +0200 |
commit | 392783697c21a0c4cf3db6b0946d3d44d7fed537 (patch) | |
tree | 9f0808ba972d629af5cae087b57c398bbd015b95 /src/qt/walletmodel.cpp | |
parent | 397521d632b4a49e61c8ea2246135f9cc00e57c4 (diff) |
[Qt] rescan progress
Diffstat (limited to 'src/qt/walletmodel.cpp')
-rw-r--r-- | src/qt/walletmodel.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index eae448fee4..424c9ee279 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -419,8 +419,17 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, Q_ARG(int, status)); } +// queue notifications to show a non freezing progress dialog e.g. for rescan +static bool fQueueNotifications = false; +static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications; static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status) { + if (fQueueNotifications) + { + vQueueNotifications.push_back(make_pair(hash, status)); + return; + } + QString strHash = QString::fromStdString(hash.GetHex()); qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status); @@ -429,12 +438,32 @@ static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, Q_ARG(int, status)); } +static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress) +{ + // emits signal "showProgress" + QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection, + Q_ARG(QString, QString::fromStdString(title)), + Q_ARG(int, nProgress)); + + if (nProgress == 0) + fQueueNotifications = true; + + if (nProgress == 100) + { + fQueueNotifications = false; + BOOST_FOREACH(const PAIRTYPE(uint256, ChangeType)& notification, vQueueNotifications) + NotifyTransactionChanged(walletmodel, NULL, notification.first, notification.second); + std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear + } +} + void WalletModel::subscribeToCoreSignals() { // Connect signals to wallet wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); + wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2)); } void WalletModel::unsubscribeFromCoreSignals() @@ -443,6 +472,7 @@ void WalletModel::unsubscribeFromCoreSignals() wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1)); wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6)); wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3)); + wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2)); } // WalletModel::UnlockContext implementation |