Qt: Get wallet name from WalletModel rather than passing it around
This commit is contained in:
parent
12d8d2681e
commit
b6d04fc7cc
7 changed files with 20 additions and 16 deletions
|
@ -487,14 +487,9 @@ void BitcoinApplication::initializeResult(bool success)
|
|||
for (CWalletRef pwallet : vpwallets) {
|
||||
WalletModel * const walletModel = new WalletModel(platformStyle, pwallet, optionsModel);
|
||||
|
||||
QString WalletName = QString::fromStdString(pwallet->GetName());
|
||||
if (WalletName.endsWith(".dat")) {
|
||||
WalletName.truncate(WalletName.size() - 4);
|
||||
}
|
||||
|
||||
window->addWallet(WalletName, walletModel);
|
||||
window->addWallet(walletModel);
|
||||
if (fFirstWallet) {
|
||||
window->setCurrentWallet(WalletName);
|
||||
window->setCurrentWallet(walletModel->getWalletName());
|
||||
fFirstWallet = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -538,10 +538,11 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
|
||||
bool BitcoinGUI::addWallet(WalletModel *walletModel)
|
||||
{
|
||||
if(!walletFrame)
|
||||
return false;
|
||||
const QString name = walletModel->getWalletName();
|
||||
setWalletActionsEnabled(true);
|
||||
m_wallet_selector->addItem(name);
|
||||
if (m_wallet_selector->count() == 2) {
|
||||
|
@ -551,8 +552,8 @@ bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
|
|||
appToolBar->addWidget(m_wallet_selector_label);
|
||||
appToolBar->addWidget(m_wallet_selector);
|
||||
}
|
||||
rpcConsole->addWallet(name, walletModel);
|
||||
return walletFrame->addWallet(name, walletModel);
|
||||
rpcConsole->addWallet(walletModel);
|
||||
return walletFrame->addWallet(walletModel);
|
||||
}
|
||||
|
||||
bool BitcoinGUI::setCurrentWallet(const QString& name)
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
|
||||
functionality.
|
||||
*/
|
||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
||||
bool addWallet(WalletModel *walletModel);
|
||||
void removeAllWallets();
|
||||
#endif // ENABLE_WALLET
|
||||
bool enableWallet;
|
||||
|
|
|
@ -688,8 +688,9 @@ void RPCConsole::setClientModel(ClientModel *model)
|
|||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
void RPCConsole::addWallet(const QString name, WalletModel * const walletModel)
|
||||
void RPCConsole::addWallet(WalletModel * const walletModel)
|
||||
{
|
||||
const QString name = walletModel->getWalletName();
|
||||
// use name for text and internal data object (to allow to move to a wallet id later)
|
||||
ui->WalletSelector->addItem(name, name);
|
||||
if (ui->WalletSelector->count() == 2 && !isVisible()) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
}
|
||||
|
||||
void setClientModel(ClientModel *model);
|
||||
void addWallet(const QString name, WalletModel * const walletModel);
|
||||
void addWallet(WalletModel * const walletModel);
|
||||
|
||||
enum MessageClass {
|
||||
MC_ERROR,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <qt/walletframe.h>
|
||||
#include <qt/walletmodel.h>
|
||||
|
||||
#include <qt/bitcoingui.h>
|
||||
#include <qt/walletview.h>
|
||||
|
@ -39,10 +40,16 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
|
|||
this->clientModel = _clientModel;
|
||||
}
|
||||
|
||||
bool WalletFrame::addWallet(const QString& name, WalletModel *walletModel)
|
||||
bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||
{
|
||||
if (!gui || !clientModel || !walletModel || mapWalletViews.count(name) > 0)
|
||||
if (!gui || !clientModel || !walletModel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString name = walletModel->getWalletName();
|
||||
if (mapWalletViews.count(name) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
WalletView *walletView = new WalletView(platformStyle, this);
|
||||
walletView->setBitcoinGUI(gui);
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
void setClientModel(ClientModel *clientModel);
|
||||
|
||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
||||
bool addWallet(WalletModel *walletModel);
|
||||
bool setCurrentWallet(const QString& name);
|
||||
bool removeWallet(const QString &name);
|
||||
void removeAllWallets();
|
||||
|
|
Loading…
Reference in a new issue