1
1
mirror of https://github.com/bitcoin/bitcoin.git synced 2024-05-17 23:56:39 +00:00

qt: Revamp ClientModel code to handle NetworkActiveChanged core signal

No behavior change.
This commit is contained in:
Hennadii Stepanov 2022-04-10 17:57:10 +02:00
parent 639563d7fe
commit bfe5140c50
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F
2 changed files with 4 additions and 14 deletions

View File

@ -148,11 +148,6 @@ uint256 ClientModel::getBestBlockHash()
return m_cached_tip_blocks; return m_cached_tip_blocks;
} }
void ClientModel::updateNetworkActive(bool networkActive)
{
Q_EMIT networkActiveChanged(networkActive);
}
void ClientModel::updateAlert() void ClientModel::updateAlert()
{ {
Q_EMIT alertsChanged(getStatusBarWarnings()); Q_EMIT alertsChanged(getStatusBarWarnings());
@ -231,13 +226,6 @@ void ClientModel::updateBanlist()
} }
// Handlers for core signals // Handlers for core signals
static void NotifyNetworkActiveChanged(ClientModel *clientmodel, bool networkActive)
{
bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", Qt::QueuedConnection,
Q_ARG(bool, networkActive));
assert(invoked);
}
static void NotifyAlertChanged(ClientModel *clientmodel) static void NotifyAlertChanged(ClientModel *clientmodel)
{ {
qDebug() << "NotifyAlertChanged"; qDebug() << "NotifyAlertChanged";
@ -292,7 +280,10 @@ void ClientModel::subscribeToCoreSignals()
[this](int new_num_connections) { [this](int new_num_connections) {
Q_EMIT numConnectionsChanged(new_num_connections); Q_EMIT numConnectionsChanged(new_num_connections);
}); });
m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(std::bind(NotifyNetworkActiveChanged, this, std::placeholders::_1)); m_handler_notify_network_active_changed = m_node.handleNotifyNetworkActiveChanged(
[this](bool network_active) {
Q_EMIT networkActiveChanged(network_active);
});
m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this)); m_handler_notify_alert_changed = m_node.handleNotifyAlertChanged(std::bind(NotifyAlertChanged, this));
m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this)); m_handler_banned_list_changed = m_node.handleBannedListChanged(std::bind(BannedListChanged, this));
m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, false)); m_handler_notify_block_tip = m_node.handleNotifyBlockTip(std::bind(BlockTipChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, false));

View File

@ -122,7 +122,6 @@ Q_SIGNALS:
void showProgress(const QString &title, int nProgress); void showProgress(const QString &title, int nProgress);
public Q_SLOTS: public Q_SLOTS:
void updateNetworkActive(bool networkActive);
void updateAlert(); void updateAlert();
void updateBanlist(); void updateBanlist();
}; };