From a163be0ae1d71b1fbac6b6ed55e97b9aa9b0e971 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 7 Jan 2019 12:53:12 +0000 Subject: [PATCH] GUI: WalletModel: Track asset type collection --- src/qt/walletmodel.cpp | 15 +++++++++++++++ src/qt/walletmodel.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 5a6e650aba..50015163a1 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -56,6 +56,11 @@ WalletModel::~WalletModel() unsubscribeFromCoreSignals(); } +std::set WalletModel::getAssetTypes() const +{ + return cached_asset_types; +} + void WalletModel::updateStatus() { EncryptionStatus newEncryptionStatus = getEncryptionStatus(); @@ -95,6 +100,16 @@ void WalletModel::checkBalanceChanged(const interfaces::WalletBalances& new_bala if(new_balances.balanceChanged(m_cached_balances)) { m_cached_balances = new_balances; Q_EMIT balanceChanged(new_balances); + + std::set new_asset_types; + for (const auto& assetamount : new_balances.balance + new_balances.unconfirmed_balance) { + if (!assetamount.second) continue; + new_asset_types.insert(assetamount.first); + } + if (new_asset_types != cached_asset_types) { + cached_asset_types = new_asset_types; + Q_EMIT assetTypesChanged(); + } } } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index b22728c69b..815e6df3d1 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -140,6 +140,7 @@ public: TransactionTableModel *getTransactionTableModel(); RecentRequestsTableModel *getRecentRequestsTableModel(); + std::set getAssetTypes() const; EncryptionStatus getEncryptionStatus() const; // Check address for validity @@ -230,6 +231,7 @@ private: // Cache some values to be able to detect changes interfaces::WalletBalances m_cached_balances; + std::set cached_asset_types; EncryptionStatus cachedEncryptionStatus; int cachedNumBlocks; @@ -243,6 +245,9 @@ Q_SIGNALS: // Signal that balance in wallet changed void balanceChanged(const interfaces::WalletBalances& balances); + // Signal that the set of possessed asset types changed + void assetTypesChanged(); + // Encryption status of wallet changed void encryptionStatusChanged();