mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
qt: Use WalletModel* instead of wallet name in main window
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2018 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -46,8 +46,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString name = walletModel->getWalletName();
|
||||
if (mapWalletViews.count(name) > 0) {
|
||||
if (mapWalletViews.count(walletModel) > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -65,7 +64,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||
}
|
||||
|
||||
walletStack->addWidget(walletView);
|
||||
mapWalletViews[name] = walletView;
|
||||
mapWalletViews[walletModel] = walletView;
|
||||
|
||||
// Ensure a walletView is able to show the main window
|
||||
connect(walletView, &WalletView::showNormalIfMinimized, [this]{
|
||||
@@ -77,24 +76,24 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalletFrame::setCurrentWallet(const QString& name)
|
||||
bool WalletFrame::setCurrentWallet(WalletModel* wallet_model)
|
||||
{
|
||||
if (mapWalletViews.count(name) == 0)
|
||||
if (mapWalletViews.count(wallet_model) == 0)
|
||||
return false;
|
||||
|
||||
WalletView *walletView = mapWalletViews.value(name);
|
||||
WalletView *walletView = mapWalletViews.value(wallet_model);
|
||||
walletStack->setCurrentWidget(walletView);
|
||||
assert(walletView);
|
||||
walletView->updateEncryptionStatus();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WalletFrame::removeWallet(const QString &name)
|
||||
bool WalletFrame::removeWallet(WalletModel* wallet_model)
|
||||
{
|
||||
if (mapWalletViews.count(name) == 0)
|
||||
if (mapWalletViews.count(wallet_model) == 0)
|
||||
return false;
|
||||
|
||||
WalletView *walletView = mapWalletViews.take(name);
|
||||
WalletView *walletView = mapWalletViews.take(wallet_model);
|
||||
walletStack->removeWidget(walletView);
|
||||
delete walletView;
|
||||
return true;
|
||||
@@ -102,7 +101,7 @@ bool WalletFrame::removeWallet(const QString &name)
|
||||
|
||||
void WalletFrame::removeAllWallets()
|
||||
{
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
walletStack->removeWidget(i.value());
|
||||
mapWalletViews.clear();
|
||||
@@ -120,35 +119,35 @@ bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
||||
void WalletFrame::showOutOfSyncWarning(bool fShow)
|
||||
{
|
||||
bOutOfSync = fShow;
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
i.value()->showOutOfSyncWarning(fShow);
|
||||
}
|
||||
|
||||
void WalletFrame::gotoOverviewPage()
|
||||
{
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
i.value()->gotoOverviewPage();
|
||||
}
|
||||
|
||||
void WalletFrame::gotoHistoryPage()
|
||||
{
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
i.value()->gotoHistoryPage();
|
||||
}
|
||||
|
||||
void WalletFrame::gotoReceiveCoinsPage()
|
||||
{
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
i.value()->gotoReceiveCoinsPage();
|
||||
}
|
||||
|
||||
void WalletFrame::gotoSendCoinsPage(QString addr)
|
||||
{
|
||||
QMap<QString, WalletView*>::const_iterator i;
|
||||
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||
i.value()->gotoSendCoinsPage(addr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user