Qt: Load all wallets into WalletModels

This commit is contained in:
Luke Dashjr 2016-09-09 09:25:13 +00:00 committed by Jonas Schnelli
parent ed6ae8059c
commit 3dba3c3ac1
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D
3 changed files with 21 additions and 15 deletions

View file

@ -251,7 +251,7 @@ private:
QTimer *pollShutdownTimer;
#ifdef ENABLE_WALLET
PaymentServer* paymentServer;
WalletModel *walletModel;
std::vector<WalletModel*> m_wallet_models;
#endif
int returnValue;
const PlatformStyle *platformStyle;
@ -333,7 +333,7 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
pollShutdownTimer(0),
#ifdef ENABLE_WALLET
paymentServer(0),
walletModel(0),
m_wallet_models(),
#endif
returnValue(0)
{
@ -451,8 +451,10 @@ void BitcoinApplication::requestShutdown()
#ifdef ENABLE_WALLET
window->removeAllWallets();
delete walletModel;
walletModel = 0;
for (WalletModel *walletModel : m_wallet_models) {
delete walletModel;
}
m_wallet_models.clear();
#endif
delete clientModel;
clientModel = 0;
@ -481,16 +483,25 @@ void BitcoinApplication::initializeResult(bool success)
window->setClientModel(clientModel);
#ifdef ENABLE_WALLET
// TODO: Expose secondary wallets
if (!vpwallets.empty())
{
walletModel = new WalletModel(platformStyle, vpwallets[0], optionsModel);
bool fFirstWallet = true;
for (CWalletRef pwallet : vpwallets) {
WalletModel * const walletModel = new WalletModel(platformStyle, pwallet, optionsModel);
window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel);
window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET);
QString WalletName = QString::fromStdString(pwallet->GetName());
if (WalletName.endsWith(".dat")) {
WalletName.truncate(WalletName.size() - 4);
}
window->addWallet(WalletName, walletModel);
if (fFirstWallet) {
window->setCurrentWallet(WalletName);
fFirstWallet = false;
}
connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)),
paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray)));
m_wallet_models.push_back(walletModel);
}
#endif

View file

@ -70,10 +70,6 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
#endif
;
/** Display name for default wallet name. Uses tilde to avoid name
* collisions in the future with additional wallets */
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent),
enableWallet(false),

View file

@ -46,7 +46,6 @@ class BitcoinGUI : public QMainWindow
Q_OBJECT
public:
static const QString DEFAULT_WALLET;
static const std::string DEFAULT_UIPLATFORM;
explicit BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);