diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-04-03 11:50:29 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-04-03 11:51:02 +0200 |
commit | 9bd1bdd08cd4e90f5004c40f2f3cee0f250b0811 (patch) | |
tree | a650058b6950caf5d67dc468964b6eeeb158dc0c /src/qt/walletmodel.cpp | |
parent | 8556b0298d6b7101b063862fb4ab6b4a67dd2361 (diff) | |
parent | 392783697c21a0c4cf3db6b0946d3d44d7fed537 (diff) |
Merge pull request #3928
3927836 [Qt] rescan progress (Cozz Lovan)
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 |