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

View file

@ -70,10 +70,6 @@ const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
#endif #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) : BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
enableWallet(false), enableWallet(false),

View file

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