aboutsummaryrefslogtreecommitdiff
path: root/src/qt/walletmodel.cpp
diff options
context:
space:
mode:
authorCozz Lovan <cozzlovan@yahoo.com>2014-07-26 21:05:11 +0200
committerCozz Lovan <cozzlovan@yahoo.com>2014-08-11 18:47:02 +0200
commit939ed97373fdea0e8ecb173f1c22eb53b9f90bb6 (patch)
treece3d6651e29d593f422d4d199ba323e4b4ee5c10 /src/qt/walletmodel.cpp
parent8b11d3de7aa4fc3f6c4e7bf292495850034ded2c (diff)
Add boolean HaveWatchonly and signal NotifyWatchonlyChanged
Diffstat (limited to 'src/qt/walletmodel.cpp')
-rw-r--r--src/qt/walletmodel.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 0ad123f39d..30c9ecc96b 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -36,6 +36,7 @@ WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *p
cachedNumBlocks(0)
{
fProcessingQueuedTransactions = false;
+ fHaveWatchOnly = wallet->HaveWatchOnly();
addressTableModel = new AddressTableModel(wallet, this);
transactionTableModel = new TransactionTableModel(wallet, this);
@@ -81,6 +82,11 @@ qint64 WalletModel::getImmatureBalance() const
return wallet->GetImmatureBalance();
}
+bool WalletModel::haveWatchOnly() const
+{
+ return fHaveWatchOnly;
+}
+
qint64 WalletModel::getWatchBalance() const
{
return wallet->GetWatchOnlyBalance();
@@ -144,9 +150,15 @@ void WalletModel::checkBalanceChanged()
qint64 newBalance = getBalance();
qint64 newUnconfirmedBalance = getUnconfirmedBalance();
qint64 newImmatureBalance = getImmatureBalance();
- qint64 newWatchOnlyBalance = getWatchBalance();
- qint64 newWatchUnconfBalance = getWatchUnconfirmedBalance();
- qint64 newWatchImmatureBalance = getWatchImmatureBalance();
+ qint64 newWatchOnlyBalance = 0;
+ qint64 newWatchUnconfBalance = 0;
+ qint64 newWatchImmatureBalance = 0;
+ if (haveWatchOnly())
+ {
+ newWatchOnlyBalance = getWatchBalance();
+ newWatchUnconfBalance = getWatchUnconfirmedBalance();
+ newWatchImmatureBalance = getWatchImmatureBalance();
+ }
if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance ||
cachedWatchOnlyBalance != newWatchOnlyBalance || cachedWatchUnconfBalance != newWatchUnconfBalance || cachedWatchImmatureBalance != newWatchImmatureBalance)
@@ -185,6 +197,12 @@ void WalletModel::updateAddressBook(const QString &address, const QString &label
addressTableModel->updateEntry(address, label, isMine, purpose, status);
}
+void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
+{
+ fHaveWatchOnly = fHaveWatchonly;
+ emit notifyWatchonlyChanged(fHaveWatchonly);
+}
+
bool WalletModel::validateAddress(const QString &address)
{
CBitcoinAddress addressParsed(address.toStdString());
@@ -499,6 +517,12 @@ static void ShowProgress(WalletModel *walletmodel, const std::string &title, int
}
}
+static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
+{
+ QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
+ Q_ARG(bool, fHaveWatchonly));
+}
+
void WalletModel::subscribeToCoreSignals()
{
// Connect signals to wallet
@@ -506,6 +530,7 @@ void WalletModel::subscribeToCoreSignals()
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));
+ wallet->NotifyWatchonlyChanged.connect(boost::bind(NotifyWatchonlyChanged, this, _1));
}
void WalletModel::unsubscribeFromCoreSignals()
@@ -515,6 +540,7 @@ void WalletModel::unsubscribeFromCoreSignals()
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));
+ wallet->NotifyWatchonlyChanged.disconnect(boost::bind(NotifyWatchonlyChanged, this, _1));
}
// WalletModel::UnlockContext implementation