Bitcoin Core  24.99.0
P2P Digital Currency
trafficgraphwidget.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2022 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_QT_TRAFFICGRAPHWIDGET_H
6 #define BITCOIN_QT_TRAFFICGRAPHWIDGET_H
7 
8 #include <QWidget>
9 #include <QQueue>
10 
11 #include <chrono>
12 
13 class ClientModel;
14 
15 QT_BEGIN_NAMESPACE
16 class QPaintEvent;
17 class QTimer;
18 QT_END_NAMESPACE
19 
20 class TrafficGraphWidget : public QWidget
21 {
22  Q_OBJECT
23 
24 public:
25  explicit TrafficGraphWidget(QWidget *parent = nullptr);
26  void setClientModel(ClientModel *model);
27  std::chrono::minutes getGraphRange() const;
28 
29 protected:
30  void paintEvent(QPaintEvent *) override;
31 
32 public Q_SLOTS:
33  void updateRates();
34  void setGraphRange(std::chrono::minutes new_range);
35  void clear();
36 
37 private:
38  void paintPath(QPainterPath &path, QQueue<float> &samples);
39 
40  QTimer* timer{nullptr};
41  float fMax{0.0f};
42  std::chrono::minutes m_range{0};
43  QQueue<float> vSamplesIn;
44  QQueue<float> vSamplesOut;
45  quint64 nLastBytesIn{0};
46  quint64 nLastBytesOut{0};
48 };
49 
50 #endif // BITCOIN_QT_TRAFFICGRAPHWIDGET_H
Model for Bitcoin network client.
Definition: clientmodel.h:55
std::chrono::minutes m_range
void paintEvent(QPaintEvent *) override
ClientModel * clientModel
TrafficGraphWidget(QWidget *parent=nullptr)
std::chrono::minutes getGraphRange() const
void setClientModel(ClientModel *model)
QQueue< float > vSamplesOut
void paintPath(QPainterPath &path, QQueue< float > &samples)
void setGraphRange(std::chrono::minutes new_range)
QQueue< float > vSamplesIn