Merge bitcoin-core/gui#590: refactor: Declare WalletModel member functions with const

f70ee34c71 qt, refactor: Declare `WalletModel` member functions with `const` (Hennadii Stepanov)

Pull request description:

  After bitcoin/bitcoin#12830 the `WalletModel` class has two member functions: be7a5f2fc4/src/qt/walletmodel.h (L81) and be7a5f2fc4/src/qt/walletmodel.h (L154)

  This PR drops the former one as redundant, and declares `WalletModel` member functions with the `const` qualifier where appropriate.

ACKs for top commit:
  promag:
    Code review ACK f70ee34c71.
  kristapsk:
    cr ACK f70ee34c71
  w0xlt:
    Code Review ACK f70ee34c71

Tree-SHA512: 43e6661822c667229ea860fb94c2e3154c33773dbd9fca1f6f76cc31c5875a1a0e8caa65ddfc20dec2a43e29e7b2469b3b6fa148fe7ec000ded518b4958b2b38
This commit is contained in:
Hennadii Stepanov 2022-05-09 22:31:00 +02:00
commit b9219b233f
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F
2 changed files with 14 additions and 16 deletions

View File

@ -145,7 +145,7 @@ void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
Q_EMIT notifyWatchonlyChanged(fHaveWatchonly); Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
} }
bool WalletModel::validateAddress(const QString &address) bool WalletModel::validateAddress(const QString& address) const
{ {
return IsValidDestinationString(address.toStdString()); return IsValidDestinationString(address.toStdString());
} }
@ -284,22 +284,22 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
return SendCoinsReturn(OK); return SendCoinsReturn(OK);
} }
OptionsModel *WalletModel::getOptionsModel() OptionsModel* WalletModel::getOptionsModel() const
{ {
return optionsModel; return optionsModel;
} }
AddressTableModel *WalletModel::getAddressTableModel() AddressTableModel* WalletModel::getAddressTableModel() const
{ {
return addressTableModel; return addressTableModel;
} }
TransactionTableModel *WalletModel::getTransactionTableModel() TransactionTableModel* WalletModel::getTransactionTableModel() const
{ {
return transactionTableModel; return transactionTableModel;
} }
RecentRequestsTableModel *WalletModel::getRecentRequestsTableModel() RecentRequestsTableModel* WalletModel::getRecentRequestsTableModel() const
{ {
return recentRequestsTableModel; return recentRequestsTableModel;
} }
@ -557,7 +557,7 @@ bool WalletModel::bumpFee(uint256 hash, uint256& new_hash)
return true; return true;
} }
bool WalletModel::displayAddress(std::string sAddress) bool WalletModel::displayAddress(std::string sAddress) const
{ {
CTxDestination dest = DecodeDestination(sAddress); CTxDestination dest = DecodeDestination(sAddress);
bool res = false; bool res = false;
@ -585,7 +585,7 @@ QString WalletModel::getDisplayName() const
return name.isEmpty() ? "["+tr("default wallet")+"]" : name; return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
} }
bool WalletModel::isMultiwallet() bool WalletModel::isMultiwallet() const
{ {
return m_node.walletLoader().getWallets().size() > 1; return m_node.walletLoader().getWallets().size() > 1;
} }

View File

@ -77,15 +77,15 @@ public:
Unlocked // wallet->IsCrypted() && !wallet->IsLocked() Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
}; };
OptionsModel *getOptionsModel(); OptionsModel* getOptionsModel() const;
AddressTableModel *getAddressTableModel(); AddressTableModel* getAddressTableModel() const;
TransactionTableModel *getTransactionTableModel(); TransactionTableModel* getTransactionTableModel() const;
RecentRequestsTableModel *getRecentRequestsTableModel(); RecentRequestsTableModel* getRecentRequestsTableModel() const;
EncryptionStatus getEncryptionStatus() const; EncryptionStatus getEncryptionStatus() const;
// Check address for validity // Check address for validity
bool validateAddress(const QString &address); bool validateAddress(const QString& address) const;
// Return status record for SendCoins, contains error id + information // Return status record for SendCoins, contains error id + information
struct SendCoinsReturn struct SendCoinsReturn
@ -137,7 +137,7 @@ public:
UnlockContext requestUnlock(); UnlockContext requestUnlock();
bool bumpFee(uint256 hash, uint256& new_hash); bool bumpFee(uint256 hash, uint256& new_hash);
bool displayAddress(std::string sAddress); bool displayAddress(std::string sAddress) const;
static bool isWalletEnabled(); static bool isWalletEnabled();
@ -149,9 +149,7 @@ public:
QString getWalletName() const; QString getWalletName() const;
QString getDisplayName() const; QString getDisplayName() const;
bool isMultiwallet(); bool isMultiwallet() const;
AddressTableModel* getAddressTableModel() const { return addressTableModel; }
void refresh(bool pk_hash_only = false); void refresh(bool pk_hash_only = false);