Skip to content

Commit d2a1adf

Browse files
committed
qt: Factor out WalletModel::getDisplayName()
1 parent 9c64278 commit d2a1adf

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

src/qt/bitcoingui.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
570570
if(!walletFrame)
571571
return false;
572572
const QString name = walletModel->getWalletName();
573-
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
573+
const QString display_name = walletModel->getDisplayName();
574574
setWalletActionsEnabled(true);
575575
m_wallet_selector->addItem(display_name, name);
576576
if (m_wallet_selector->count() == 2) {

src/qt/rpcconsole.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ void RPCConsole::addWallet(WalletModel * const walletModel)
700700
{
701701
const QString name = walletModel->getWalletName();
702702
// use name for text and internal data object (to allow to move to a wallet id later)
703-
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
703+
const QString display_name = walletModel->getDisplayName();
704704
ui->WalletSelector->addItem(display_name, name);
705705
if (ui->WalletSelector->count() == 2 && !isVisible()) {
706706
// First wallet added, set to default so long as the window isn't presently visible (and potentially in use)

src/qt/walletmodel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011-2018 The Bitcoin Core developers
1+
// Copyright (c) 2011-2019 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -578,6 +578,12 @@ QString WalletModel::getWalletName() const
578578
return QString::fromStdString(m_wallet->getWalletName());
579579
}
580580

581+
QString WalletModel::getDisplayName() const
582+
{
583+
const QString name = getWalletName();
584+
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
585+
}
586+
581587
bool WalletModel::isMultiwallet()
582588
{
583589
return m_node.getWallets().size() > 1;

src/qt/walletmodel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2011-2018 The Bitcoin Core developers
1+
// Copyright (c) 2011-2019 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -219,6 +219,7 @@ class WalletModel : public QObject
219219
interfaces::Wallet& wallet() const { return *m_wallet; }
220220

221221
QString getWalletName() const;
222+
QString getDisplayName() const;
222223

223224
bool isMultiwallet();
224225

0 commit comments

Comments
 (0)