mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge #14784: qt: Use WalletModel* instead of the wallet name as map key
91b0c5b096
qt: Use WalletModel* instead of wallet name in console window (João Barbosa)b2ce86c3ad
qt: Use WalletModel* instead of wallet name in main window (João Barbosa)d2a1adffeb
qt: Factor out WalletModel::getDisplayName() (João Barbosa) Pull request description: This a small refactor that doesn't change behavior. This is also necessary if in the future we allow renaming wallets. Tree-SHA512: 1820d0ff28e84b1d862097f1f55b52f94520fa50c9b1939d235a448a48159748c3bbf99b19e4cb1ff4f91efc008c0971b4c25a91f645f9d43792c8aeaa93cf9e
This commit is contained in:
commit
9c71998771
9 changed files with 65 additions and 66 deletions
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -431,7 +431,7 @@ void BitcoinApplication::addWallet(WalletModel* walletModel)
|
||||||
window->addWallet(walletModel);
|
window->addWallet(walletModel);
|
||||||
|
|
||||||
if (m_wallet_models.empty()) {
|
if (m_wallet_models.empty()) {
|
||||||
window->setCurrentWallet(walletModel->getWalletName());
|
window->setCurrentWallet(walletModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_BIP70
|
#ifdef ENABLE_BIP70
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -569,10 +569,9 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
|
||||||
{
|
{
|
||||||
if(!walletFrame)
|
if(!walletFrame)
|
||||||
return false;
|
return false;
|
||||||
const QString name = walletModel->getWalletName();
|
const QString display_name = walletModel->getDisplayName();
|
||||||
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
|
|
||||||
setWalletActionsEnabled(true);
|
setWalletActionsEnabled(true);
|
||||||
m_wallet_selector->addItem(display_name, name);
|
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
|
||||||
if (m_wallet_selector->count() == 2) {
|
if (m_wallet_selector->count() == 2) {
|
||||||
m_wallet_selector_label_action->setVisible(true);
|
m_wallet_selector_label_action->setVisible(true);
|
||||||
m_wallet_selector_action->setVisible(true);
|
m_wallet_selector_action->setVisible(true);
|
||||||
|
@ -584,8 +583,7 @@ bool BitcoinGUI::addWallet(WalletModel *walletModel)
|
||||||
bool BitcoinGUI::removeWallet(WalletModel* walletModel)
|
bool BitcoinGUI::removeWallet(WalletModel* walletModel)
|
||||||
{
|
{
|
||||||
if (!walletFrame) return false;
|
if (!walletFrame) return false;
|
||||||
QString name = walletModel->getWalletName();
|
int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));
|
||||||
int index = m_wallet_selector->findData(name);
|
|
||||||
m_wallet_selector->removeItem(index);
|
m_wallet_selector->removeItem(index);
|
||||||
if (m_wallet_selector->count() == 0) {
|
if (m_wallet_selector->count() == 0) {
|
||||||
setWalletActionsEnabled(false);
|
setWalletActionsEnabled(false);
|
||||||
|
@ -594,20 +592,20 @@ bool BitcoinGUI::removeWallet(WalletModel* walletModel)
|
||||||
m_wallet_selector_action->setVisible(false);
|
m_wallet_selector_action->setVisible(false);
|
||||||
}
|
}
|
||||||
rpcConsole->removeWallet(walletModel);
|
rpcConsole->removeWallet(walletModel);
|
||||||
return walletFrame->removeWallet(name);
|
return walletFrame->removeWallet(walletModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitcoinGUI::setCurrentWallet(const QString& name)
|
bool BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
|
||||||
{
|
{
|
||||||
if(!walletFrame)
|
if(!walletFrame)
|
||||||
return false;
|
return false;
|
||||||
return walletFrame->setCurrentWallet(name);
|
return walletFrame->setCurrentWallet(wallet_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
|
bool BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
|
||||||
{
|
{
|
||||||
QString internal_name = m_wallet_selector->itemData(index).toString();
|
WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();
|
||||||
return setCurrentWallet(internal_name);
|
return setCurrentWallet(wallet_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::removeAllWallets()
|
void BitcoinGUI::removeAllWallets()
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ public Q_SLOTS:
|
||||||
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
|
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
bool setCurrentWallet(const QString& name);
|
bool setCurrentWallet(WalletModel* wallet_model);
|
||||||
bool setCurrentWalletBySelectorIndex(int index);
|
bool setCurrentWalletBySelectorIndex(int index);
|
||||||
/** Set the UI status indicators based on the currently selected wallet.
|
/** Set the UI status indicators based on the currently selected wallet.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
explicit RPCExecutor(interfaces::Node& node) : m_node(node) {}
|
explicit RPCExecutor(interfaces::Node& node) : m_node(node) {}
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void request(const QString &command, const QString &walletID);
|
void request(const QString &command, const WalletModel* wallet_model);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void reply(int category, const QString &command);
|
void reply(int category, const QString &command);
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
|
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const std::string *walletID)
|
bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const WalletModel* wallet_model)
|
||||||
{
|
{
|
||||||
std::vector< std::vector<std::string> > stack;
|
std::vector< std::vector<std::string> > stack;
|
||||||
stack.push_back(std::vector<std::string>());
|
stack.push_back(std::vector<std::string>());
|
||||||
|
@ -306,8 +306,8 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
|
||||||
std::string method = stack.back()[0];
|
std::string method = stack.back()[0];
|
||||||
std::string uri;
|
std::string uri;
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (walletID) {
|
if (wallet_model) {
|
||||||
QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(*walletID));
|
QByteArray encodedName = QUrl::toPercentEncoding(wallet_model->getWalletName());
|
||||||
uri = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
|
uri = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -387,7 +387,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCExecutor::request(const QString &command, const QString &walletID)
|
void RPCExecutor::request(const QString &command, const WalletModel* wallet_model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -418,9 +418,7 @@ void RPCExecutor::request(const QString &command, const QString &walletID)
|
||||||
" example: getblock(getblockhash(0),true)[tx][0]\n\n")));
|
" example: getblock(getblockhash(0),true)[tx][0]\n\n")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::string wallet_id = walletID.toStdString();
|
if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, wallet_model)) {
|
||||||
if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, walletID.isNull() ? nullptr : &wallet_id))
|
|
||||||
{
|
|
||||||
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
|
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -698,10 +696,8 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
void RPCConsole::addWallet(WalletModel * const walletModel)
|
void RPCConsole::addWallet(WalletModel * const walletModel)
|
||||||
{
|
{
|
||||||
const QString name = walletModel->getWalletName();
|
// use name for text and wallet model for 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(walletModel->getDisplayName(), QVariant::fromValue(walletModel));
|
||||||
QString display_name = name.isEmpty() ? "["+tr("default wallet")+"]" : name;
|
|
||||||
ui->WalletSelector->addItem(display_name, name);
|
|
||||||
if (ui->WalletSelector->count() == 2 && !isVisible()) {
|
if (ui->WalletSelector->count() == 2 && !isVisible()) {
|
||||||
// First wallet added, set to default so long as the window isn't presently visible (and potentially in use)
|
// First wallet added, set to default so long as the window isn't presently visible (and potentially in use)
|
||||||
ui->WalletSelector->setCurrentIndex(1);
|
ui->WalletSelector->setCurrentIndex(1);
|
||||||
|
@ -714,8 +710,7 @@ void RPCConsole::addWallet(WalletModel * const walletModel)
|
||||||
|
|
||||||
void RPCConsole::removeWallet(WalletModel * const walletModel)
|
void RPCConsole::removeWallet(WalletModel * const walletModel)
|
||||||
{
|
{
|
||||||
const QString name = walletModel->getWalletName();
|
ui->WalletSelector->removeItem(ui->WalletSelector->findData(QVariant::fromValue(walletModel)));
|
||||||
ui->WalletSelector->removeItem(ui->WalletSelector->findData(name));
|
|
||||||
if (ui->WalletSelector->count() == 2) {
|
if (ui->WalletSelector->count() == 2) {
|
||||||
ui->WalletSelector->setVisible(false);
|
ui->WalletSelector->setVisible(false);
|
||||||
ui->WalletSelectorLabel->setVisible(false);
|
ui->WalletSelectorLabel->setVisible(false);
|
||||||
|
@ -910,25 +905,25 @@ void RPCConsole::on_lineEdit_returnPressed()
|
||||||
|
|
||||||
cmdBeforeBrowsing = QString();
|
cmdBeforeBrowsing = QString();
|
||||||
|
|
||||||
QString walletID;
|
WalletModel* wallet_model{nullptr};
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
const int wallet_index = ui->WalletSelector->currentIndex();
|
const int wallet_index = ui->WalletSelector->currentIndex();
|
||||||
if (wallet_index > 0) {
|
if (wallet_index > 0) {
|
||||||
walletID = (QString)ui->WalletSelector->itemData(wallet_index).value<QString>();
|
wallet_model = ui->WalletSelector->itemData(wallet_index).value<WalletModel*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_last_wallet_id != walletID) {
|
if (m_last_wallet_model != wallet_model) {
|
||||||
if (walletID.isNull()) {
|
if (wallet_model) {
|
||||||
message(CMD_REQUEST, tr("Executing command without any wallet"));
|
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(wallet_model->getWalletName()));
|
||||||
} else {
|
} else {
|
||||||
message(CMD_REQUEST, tr("Executing command using \"%1\" wallet").arg(walletID));
|
message(CMD_REQUEST, tr("Executing command without any wallet"));
|
||||||
}
|
}
|
||||||
m_last_wallet_id = walletID;
|
m_last_wallet_model = wallet_model;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
|
message(CMD_REQUEST, QString::fromStdString(strFilteredCmd));
|
||||||
Q_EMIT cmdRequest(cmd, walletID);
|
Q_EMIT cmdRequest(cmd, m_last_wallet_model);
|
||||||
|
|
||||||
cmd = QString::fromStdString(strFilteredCmd);
|
cmd = QString::fromStdString(strFilteredCmd);
|
||||||
|
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -41,9 +41,9 @@ public:
|
||||||
explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent);
|
explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent);
|
||||||
~RPCConsole();
|
~RPCConsole();
|
||||||
|
|
||||||
static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr);
|
static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr);
|
||||||
static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr) {
|
static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr) {
|
||||||
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, walletID);
|
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, wallet_model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setClientModel(ClientModel *model);
|
void setClientModel(ClientModel *model);
|
||||||
|
@ -133,7 +133,7 @@ public Q_SLOTS:
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
// For RPC command executor
|
// For RPC command executor
|
||||||
void stopExecutor();
|
void stopExecutor();
|
||||||
void cmdRequest(const QString &command, const QString &walletID);
|
void cmdRequest(const QString &command, const WalletModel* wallet_model);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startExecutor();
|
void startExecutor();
|
||||||
|
@ -165,7 +165,7 @@ private:
|
||||||
int consoleFontSize = 0;
|
int consoleFontSize = 0;
|
||||||
QCompleter *autoCompleter = nullptr;
|
QCompleter *autoCompleter = nullptr;
|
||||||
QThread thread;
|
QThread thread;
|
||||||
QString m_last_wallet_id;
|
WalletModel* m_last_wallet_model{nullptr};
|
||||||
|
|
||||||
/** Update UI with latest network info from model. */
|
/** Update UI with latest network info from model. */
|
||||||
void updateNetworkState();
|
void updateNetworkState();
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString name = walletModel->getWalletName();
|
if (mapWalletViews.count(walletModel) > 0) {
|
||||||
if (mapWalletViews.count(name) > 0) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
walletStack->addWidget(walletView);
|
walletStack->addWidget(walletView);
|
||||||
mapWalletViews[name] = walletView;
|
mapWalletViews[walletModel] = walletView;
|
||||||
|
|
||||||
// Ensure a walletView is able to show the main window
|
// Ensure a walletView is able to show the main window
|
||||||
connect(walletView, &WalletView::showNormalIfMinimized, [this]{
|
connect(walletView, &WalletView::showNormalIfMinimized, [this]{
|
||||||
|
@ -77,24 +76,24 @@ bool WalletFrame::addWallet(WalletModel *walletModel)
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.value(name);
|
WalletView *walletView = mapWalletViews.value(wallet_model);
|
||||||
walletStack->setCurrentWidget(walletView);
|
walletStack->setCurrentWidget(walletView);
|
||||||
assert(walletView);
|
assert(walletView);
|
||||||
walletView->updateEncryptionStatus();
|
walletView->updateEncryptionStatus();
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
WalletView *walletView = mapWalletViews.take(name);
|
WalletView *walletView = mapWalletViews.take(wallet_model);
|
||||||
walletStack->removeWidget(walletView);
|
walletStack->removeWidget(walletView);
|
||||||
delete walletView;
|
delete walletView;
|
||||||
return true;
|
return true;
|
||||||
|
@ -102,7 +101,7 @@ bool WalletFrame::removeWallet(const QString &name)
|
||||||
|
|
||||||
void WalletFrame::removeAllWallets()
|
void WalletFrame::removeAllWallets()
|
||||||
{
|
{
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
walletStack->removeWidget(i.value());
|
walletStack->removeWidget(i.value());
|
||||||
mapWalletViews.clear();
|
mapWalletViews.clear();
|
||||||
|
@ -120,35 +119,35 @@ bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient)
|
||||||
void WalletFrame::showOutOfSyncWarning(bool fShow)
|
void WalletFrame::showOutOfSyncWarning(bool fShow)
|
||||||
{
|
{
|
||||||
bOutOfSync = fShow;
|
bOutOfSync = fShow;
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
i.value()->showOutOfSyncWarning(fShow);
|
i.value()->showOutOfSyncWarning(fShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoOverviewPage()
|
void WalletFrame::gotoOverviewPage()
|
||||||
{
|
{
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
i.value()->gotoOverviewPage();
|
i.value()->gotoOverviewPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoHistoryPage()
|
void WalletFrame::gotoHistoryPage()
|
||||||
{
|
{
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
i.value()->gotoHistoryPage();
|
i.value()->gotoHistoryPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoReceiveCoinsPage()
|
void WalletFrame::gotoReceiveCoinsPage()
|
||||||
{
|
{
|
||||||
QMap<QString, WalletView*>::const_iterator i;
|
QMap<WalletModel*, WalletView*>::const_iterator i;
|
||||||
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
i.value()->gotoReceiveCoinsPage();
|
i.value()->gotoReceiveCoinsPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WalletFrame::gotoSendCoinsPage(QString addr)
|
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)
|
for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i)
|
||||||
i.value()->gotoSendCoinsPage(addr);
|
i.value()->gotoSendCoinsPage(addr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ public:
|
||||||
void setClientModel(ClientModel *clientModel);
|
void setClientModel(ClientModel *clientModel);
|
||||||
|
|
||||||
bool addWallet(WalletModel *walletModel);
|
bool addWallet(WalletModel *walletModel);
|
||||||
bool setCurrentWallet(const QString& name);
|
bool setCurrentWallet(WalletModel* wallet_model);
|
||||||
bool removeWallet(const QString &name);
|
bool removeWallet(WalletModel* wallet_model);
|
||||||
void removeAllWallets();
|
void removeAllWallets();
|
||||||
|
|
||||||
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
bool handlePaymentRequest(const SendCoinsRecipient& recipient);
|
||||||
|
@ -53,7 +53,7 @@ private:
|
||||||
QStackedWidget *walletStack;
|
QStackedWidget *walletStack;
|
||||||
BitcoinGUI *gui;
|
BitcoinGUI *gui;
|
||||||
ClientModel *clientModel;
|
ClientModel *clientModel;
|
||||||
QMap<QString, WalletView*> mapWalletViews;
|
QMap<WalletModel*, WalletView*> mapWalletViews;
|
||||||
|
|
||||||
bool bOutOfSync;
|
bool bOutOfSync;
|
||||||
|
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -578,6 +578,12 @@ QString WalletModel::getWalletName() const
|
||||||
return QString::fromStdString(m_wallet->getWalletName());
|
return QString::fromStdString(m_wallet->getWalletName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString WalletModel::getDisplayName() const
|
||||||
|
{
|
||||||
|
const QString name = getWalletName();
|
||||||
|
return name.isEmpty() ? "["+tr("default wallet")+"]" : name;
|
||||||
|
}
|
||||||
|
|
||||||
bool WalletModel::isMultiwallet()
|
bool WalletModel::isMultiwallet()
|
||||||
{
|
{
|
||||||
return m_node.getWallets().size() > 1;
|
return m_node.getWallets().size() > 1;
|
||||||
|
|
|
@ -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
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -219,6 +219,7 @@ public:
|
||||||
interfaces::Wallet& wallet() const { return *m_wallet; }
|
interfaces::Wallet& wallet() const { return *m_wallet; }
|
||||||
|
|
||||||
QString getWalletName() const;
|
QString getWalletName() const;
|
||||||
|
QString getDisplayName() const;
|
||||||
|
|
||||||
bool isMultiwallet();
|
bool isMultiwallet();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue