diff --git a/qml/bitcoin.cpp b/qml/bitcoin.cpp index 513e3c8b07..6bf1d09288 100644 --- a/qml/bitcoin.cpp +++ b/qml/bitcoin.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -289,7 +290,7 @@ int QmlGuiMain(int argc, char* argv[]) node->startShutdown(); }); - PeerTableModel peer_model{*node, nullptr}; + PeerTableQmlModel peer_model{*node, nullptr}; PeerListSortProxy peer_model_sort_proxy{nullptr}; peer_model_sort_proxy.setSourceModel(&peer_model); diff --git a/qml/models/peertableqmlmodel.cpp b/qml/models/peertableqmlmodel.cpp new file mode 100644 index 0000000000..c9a22953b2 --- /dev/null +++ b/qml/models/peertableqmlmodel.cpp @@ -0,0 +1,20 @@ +// Copyright (c) 2025 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +PeerTableQmlModel::PeerTableQmlModel(interfaces::Node& node, QObject* parent) + : PeerTableModel(node, parent) +{ +} + +void PeerTableQmlModel::startAutoRefresh() +{ + PeerTableModel::startAutoRefresh(); +} + +void PeerTableQmlModel::stopAutoRefresh() +{ + PeerTableModel::stopAutoRefresh(); +} diff --git a/qml/models/peertableqmlmodel.h b/qml/models/peertableqmlmodel.h new file mode 100644 index 0000000000..01a9b95357 --- /dev/null +++ b/qml/models/peertableqmlmodel.h @@ -0,0 +1,27 @@ +// Copyright (c) 2025 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H +#define BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H + +#include + +#include + +/** + * QML-friendly wrapper for PeerTableModel that exposes methods as invokable + * from QML. This allows QML code to call startAutoRefresh() and stopAutoRefresh(). + */ +class PeerTableQmlModel : public PeerTableModel +{ + Q_OBJECT + +public: + explicit PeerTableQmlModel(interfaces::Node& node, QObject* parent = nullptr); + + Q_INVOKABLE void startAutoRefresh(); + Q_INVOKABLE void stopAutoRefresh(); +}; + +#endif // BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H