mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 19:23:26 -03:00
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) {
|
for (CWalletRef pwallet : vpwallets) {
|
||||||
WalletModel * const walletModel = new WalletModel(platformStyle, pwallet, optionsModel);
|
WalletModel * const walletModel = new WalletModel(platformStyle, pwallet, optionsModel);
|
||||||
|
|
||||||
QString WalletName = QString::fromStdString(pwallet->GetName());
|
window->addWallet(walletModel);
|
||||||
if (WalletName.endsWith(".dat")) {
|
|
||||||
WalletName.truncate(WalletName.size() - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
window->addWallet(WalletName, walletModel);
|
|
||||||
if (fFirstWallet) {
|
if (fFirstWallet) {
|
||||||
window->setCurrentWallet(WalletName);
|
window->setCurrentWallet(walletModel->getWalletName());
|
||||||
fFirstWallet = false;
|
fFirstWallet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -538,10 +538,11 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
|
bool BitcoinGUI::addWallet(WalletModel *walletModel)
|
||||||
{
|
{
|
||||||
if(!walletFrame)
|
if(!walletFrame)
|
||||||
return false;
|
return false;
|
||||||
|
const QString name = walletModel->getWalletName();
|
||||||
setWalletActionsEnabled(true);
|
setWalletActionsEnabled(true);
|
||||||
m_wallet_selector->addItem(name);
|
m_wallet_selector->addItem(name);
|
||||||
if (m_wallet_selector->count() == 2) {
|
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_label);
|
||||||
appToolBar->addWidget(m_wallet_selector);
|
appToolBar->addWidget(m_wallet_selector);
|
||||||
}
|
}
|
||||||
rpcConsole->addWallet(name, walletModel);
|
rpcConsole->addWallet(walletModel);
|
||||||
return walletFrame->addWallet(name, walletModel);
|
return walletFrame->addWallet(walletModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitcoinGUI::setCurrentWallet(const QString& name)
|
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
|
The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
|
||||||
functionality.
|
functionality.
|
||||||
*/
|
*/
|
||||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
bool addWallet(WalletModel *walletModel);
|
||||||
void removeAllWallets();
|
void removeAllWallets();
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
bool enableWallet;
|
bool enableWallet;
|
||||||
|
|
|
@ -688,8 +688,9 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#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)
|
// use name for text and internal data object (to allow to move to a wallet id later)
|
||||||
ui->WalletSelector->addItem(name, name);
|
ui->WalletSelector->addItem(name, name);
|
||||||
if (ui->WalletSelector->count() == 2 && !isVisible()) {
|
if (ui->WalletSelector->count() == 2 && !isVisible()) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClientModel(ClientModel *model);
|
void setClientModel(ClientModel *model);
|
||||||
void addWallet(const QString name, WalletModel * const walletModel);
|
void addWallet(WalletModel * const walletModel);
|
||||||
|
|
||||||
enum MessageClass {
|
enum MessageClass {
|
||||||
MC_ERROR,
|
MC_ERROR,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <qt/walletframe.h>
|
#include <qt/walletframe.h>
|
||||||
|
#include <qt/walletmodel.h>
|
||||||
|
|
||||||
#include <qt/bitcoingui.h>
|
#include <qt/bitcoingui.h>
|
||||||
#include <qt/walletview.h>
|
#include <qt/walletview.h>
|
||||||
|
@ -39,10 +40,16 @@ void WalletFrame::setClientModel(ClientModel *_clientModel)
|
||||||
this->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;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString name = walletModel->getWalletName();
|
||||||
|
if (mapWalletViews.count(name) > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
WalletView *walletView = new WalletView(platformStyle, this);
|
WalletView *walletView = new WalletView(platformStyle, this);
|
||||||
walletView->setBitcoinGUI(gui);
|
walletView->setBitcoinGUI(gui);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
|
|
||||||
void setClientModel(ClientModel *clientModel);
|
void setClientModel(ClientModel *clientModel);
|
||||||
|
|
||||||
bool addWallet(const QString& name, WalletModel *walletModel);
|
bool addWallet(WalletModel *walletModel);
|
||||||
bool setCurrentWallet(const QString& name);
|
bool setCurrentWallet(const QString& name);
|
||||||
bool removeWallet(const QString &name);
|
bool removeWallet(const QString &name);
|
||||||
void removeAllWallets();
|
void removeAllWallets();
|
||||||
|
|
Loading…
Add table
Reference in a new issue