Skip to content

Commit ab52888

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 ab52888

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <qml/models/peertableqmlmodel.h>
2+
3+
PeerTableQmlModel::PeerTableQmlModel(interfaces::Node& node, QObject* parent)
4+
: PeerTableModel(node, parent)
5+
{
6+
}
7+
8+
void PeerTableQmlModel::startAutoRefresh()
9+
{
10+
PeerTableModel::startAutoRefresh();
11+
}
12+
13+
void PeerTableQmlModel::stopAutoRefresh()
14+
{
15+
PeerTableModel::stopAutoRefresh();
16+
}

qml/models/peertableqmlmodel.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H
2+
#define BITCOIN_QML_MODELS_PEERTABLEQMLMODEL_H
3+
4+
#include <bitcoin/src/qt/peertablemodel.h>
5+
6+
#include <QObject>
7+
8+
/**
9+
* QML-friendly wrapper for PeerTableModel that exposes methods as invokable
10+
* from QML. This allows QML code to call startAutoRefresh() and stopAutoRefresh().
11+
*/
12+
class PeerTableQmlModel : public PeerTableModel
13+
{
14+
Q_OBJECT
15+
16+
public:
17+
explicit PeerTableQmlModel(interfaces::Node& node, QObject* parent = nullptr);
18+
19+
Q_INVOKABLE void startAutoRefresh();
20+
Q_INVOKABLE void stopAutoRefresh();
21+
};
22+
23+
#endif // PEERTABLEQMLMODEL_H

0 commit comments

Comments
 (0)