Changeset View
Changeset View
Standalone View
Standalone View
src/qt/clientmodel.cpp
Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | |||||
void ClientModel::updateBanlist() { | void ClientModel::updateBanlist() { | ||||
banTableModel->refresh(); | banTableModel->refresh(); | ||||
} | } | ||||
// Handlers for core signals | // Handlers for core signals | ||||
static void ShowProgress(ClientModel *clientmodel, const std::string &title, | static void ShowProgress(ClientModel *clientmodel, const std::string &title, | ||||
int nProgress) { | int nProgress) { | ||||
// emits signal "showProgress" | // emits signal "showProgress" | ||||
QMetaObject::invokeMethod(clientmodel, "showProgress", Qt::QueuedConnection, | bool invoked = QMetaObject::invokeMethod( | ||||
Q_ARG(QString, QString::fromStdString(title)), | clientmodel, "showProgress", Qt::QueuedConnection, | ||||
Q_ARG(int, nProgress)); | Q_ARG(QString, QString::fromStdString(title)), Q_ARG(int, nProgress)); | ||||
assert(invoked); | |||||
} | } | ||||
static void NotifyNumConnectionsChanged(ClientModel *clientmodel, | static void NotifyNumConnectionsChanged(ClientModel *clientmodel, | ||||
int newNumConnections) { | int newNumConnections) { | ||||
// Too noisy: qDebug() << "NotifyNumConnectionsChanged: " + | // Too noisy: qDebug() << "NotifyNumConnectionsChanged: " + | ||||
// QString::number(newNumConnections); | // QString::number(newNumConnections); | ||||
QMetaObject::invokeMethod(clientmodel, "updateNumConnections", | bool invoked = QMetaObject::invokeMethod( | ||||
Qt::QueuedConnection, | clientmodel, "updateNumConnections", Qt::QueuedConnection, | ||||
Q_ARG(int, newNumConnections)); | Q_ARG(int, newNumConnections)); | ||||
assert(invoked); | |||||
} | } | ||||
static void NotifyNetworkActiveChanged(ClientModel *clientmodel, | static void NotifyNetworkActiveChanged(ClientModel *clientmodel, | ||||
bool networkActive) { | bool networkActive) { | ||||
QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", | bool invoked = QMetaObject::invokeMethod(clientmodel, "updateNetworkActive", | ||||
Qt::QueuedConnection, Q_ARG(bool, networkActive)); | Qt::QueuedConnection, | ||||
Q_ARG(bool, networkActive)); | |||||
assert(invoked); | |||||
} | } | ||||
static void NotifyAlertChanged(ClientModel *clientmodel) { | static void NotifyAlertChanged(ClientModel *clientmodel) { | ||||
qDebug() << "NotifyAlertChanged"; | qDebug() << "NotifyAlertChanged"; | ||||
QMetaObject::invokeMethod(clientmodel, "updateAlert", Qt::QueuedConnection); | bool invoked = QMetaObject::invokeMethod(clientmodel, "updateAlert", | ||||
Qt::QueuedConnection); | |||||
assert(invoked); | |||||
} | } | ||||
static void BannedListChanged(ClientModel *clientmodel) { | static void BannedListChanged(ClientModel *clientmodel) { | ||||
qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__); | qDebug() << QString("%1: Requesting update for peer banlist").arg(__func__); | ||||
QMetaObject::invokeMethod(clientmodel, "updateBanlist", | bool invoked = QMetaObject::invokeMethod(clientmodel, "updateBanlist", | ||||
Qt::QueuedConnection); | Qt::QueuedConnection); | ||||
assert(invoked); | |||||
} | } | ||||
static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, | static void BlockTipChanged(ClientModel *clientmodel, bool initialSync, | ||||
int height, int64_t blockTime, | int height, int64_t blockTime, | ||||
double verificationProgress, bool fHeader) { | double verificationProgress, bool fHeader) { | ||||
// lock free async UI updates in case we have a new block tip | // lock free async UI updates in case we have a new block tip | ||||
// during initial sync, only update the UI if the last update | // during initial sync, only update the UI if the last update | ||||
// was > 250ms (MODEL_UPDATE_DELAY) ago | // was > 250ms (MODEL_UPDATE_DELAY) ago | ||||
Show All 11 Lines | if (fHeader) { | ||||
clientmodel->cachedBestHeaderHeight = height; | clientmodel->cachedBestHeaderHeight = height; | ||||
clientmodel->cachedBestHeaderTime = blockTime; | clientmodel->cachedBestHeaderTime = blockTime; | ||||
} | } | ||||
// if we are in-sync or if we notify a header update, update the UI | // if we are in-sync or if we notify a header update, update the UI | ||||
// regardless of last update time | // regardless of last update time | ||||
if (fHeader || !initialSync || | if (fHeader || !initialSync || | ||||
now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { | now - nLastUpdateNotification > MODEL_UPDATE_DELAY) { | ||||
// pass an async signal to the UI thread | // pass an async signal to the UI thread | ||||
QMetaObject::invokeMethod( | bool invoked = QMetaObject::invokeMethod( | ||||
clientmodel, "numBlocksChanged", Qt::QueuedConnection, | clientmodel, "numBlocksChanged", Qt::QueuedConnection, | ||||
Q_ARG(int, height), | Q_ARG(int, height), | ||||
Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)), | Q_ARG(QDateTime, QDateTime::fromTime_t(blockTime)), | ||||
Q_ARG(double, verificationProgress), Q_ARG(bool, fHeader)); | Q_ARG(double, verificationProgress), Q_ARG(bool, fHeader)); | ||||
assert(invoked); | |||||
nLastUpdateNotification = now; | nLastUpdateNotification = now; | ||||
} | } | ||||
} | } | ||||
void ClientModel::subscribeToCoreSignals() { | void ClientModel::subscribeToCoreSignals() { | ||||
// Connect signals to client | // Connect signals to client | ||||
m_handler_show_progress = m_node.handleShowProgress(std::bind( | m_handler_show_progress = m_node.handleShowProgress(std::bind( | ||||
ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); | ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); | ||||
Show All 38 Lines |