Skip to content

Commit a0d6179

Browse files
committed
Add PeerTableQmlModel
The upstream PeerTableModel does not expose its startAutoRefresh and stopAutoRefresh methods as invokable so the PeerTableQmlModel is introduced to make these methods invokable in qml.
1 parent 593b7e7 commit a0d6179

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

qml/bitcoin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <qml/models/options_model.h>
3636
#include <qml/models/peerdetailsmodel.h>
3737
#include <qml/models/peerlistsortproxy.h>
38+
#include <qml/models/peertableqmlmodel.h>
3839
#include <qml/models/sendrecipient.h>
3940
#include <qml/models/walletlistmodel.h>
4041
#include <qml/models/walletqmlmodel.h>
@@ -289,7 +290,7 @@ int QmlGuiMain(int argc, char* argv[])
289290
node->startShutdown();
290291
});
291292

292-
PeerTableModel peer_model{*node, nullptr};
293+
PeerTableQmlModel peer_model{*node, nullptr};
293294
PeerListSortProxy peer_model_sort_proxy{nullptr};
294295
peer_model_sort_proxy.setSourceModel(&peer_model);
295296

qml/models/peertableqmlmodel.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2025 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <qml/models/peertableqmlmodel.h>
6+
7+
PeerTableQmlModel::PeerTableQmlModel(interfaces::Node& node, QObject* parent)
8+
: PeerTableModel(node, parent)
9+
{
10+
}
11+
12+
void PeerTableQmlModel::startAutoRefresh()
13+
{
14+
PeerTableModel::startAutoRefresh();
15+
}
16+
17+
void PeerTableQmlModel::stopAutoRefresh()
18+
{
19+
PeerTableModel::stopAutoRefresh();
20+
}

qml/models/peertableqmlmodel.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright (c) 2025 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H
6+
#define BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H
7+
8+
#include <bitcoin/src/qt/peertablemodel.h>
9+
10+
#include <QObject>
11+
12+
/**
13+
* QML-friendly wrapper for PeerTableModel that exposes methods as invokable
14+
* from QML. This allows QML code to call startAutoRefresh() and stopAutoRefresh().
15+
*/
16+
class PeerTableQmlModel : public PeerTableModel
17+
{
18+
Q_OBJECT
19+
20+
public:
21+
explicit PeerTableQmlModel(interfaces::Node& node, QObject* parent = nullptr);
22+
23+
Q_INVOKABLE void startAutoRefresh();
24+
Q_INVOKABLE void stopAutoRefresh();
25+
};
26+
27+
#endif // BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H

0 commit comments

Comments
 (0)