Bitcoin Core  22.99.0
P2P Digital Currency
trafficgraphwidget.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2020 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;
41  float fMax;
42  std::chrono::minutes m_range{0};
43  QQueue<float> vSamplesIn;
44  QQueue<float> vSamplesOut;
45  quint64 nLastBytesIn;
46  quint64 nLastBytesOut;
48 };
49 
50 #endif // BITCOIN_QT_TRAFFICGRAPHWIDGET_H
TrafficGraphWidget::paintPath
void paintPath(QPainterPath &path, QQueue< float > &samples)
Definition: trafficgraphwidget.cpp:47
TrafficGraphWidget::clientModel
ClientModel * clientModel
Definition: trafficgraphwidget.h:47
TrafficGraphWidget::getGraphRange
std::chrono::minutes getGraphRange() const
Definition: trafficgraphwidget.cpp:45
TrafficGraphWidget::vSamplesOut
QQueue< float > vSamplesOut
Definition: trafficgraphwidget.h:44
TrafficGraphWidget::timer
QTimer * timer
Definition: trafficgraphwidget.h:40
TrafficGraphWidget::paintEvent
void paintEvent(QPaintEvent *) override
Definition: trafficgraphwidget.cpp:63
TrafficGraphWidget::vSamplesIn
QQueue< float > vSamplesIn
Definition: trafficgraphwidget.h:43
TrafficGraphWidget::setClientModel
void setClientModel(ClientModel *model)
Definition: trafficgraphwidget.cpp:36
TrafficGraphWidget::TrafficGraphWidget
TrafficGraphWidget(QWidget *parent=nullptr)
Definition: trafficgraphwidget.cpp:22
TrafficGraphWidget::setGraphRange
void setGraphRange(std::chrono::minutes new_range)
Definition: trafficgraphwidget.cpp:153
TrafficGraphWidget::clear
void clear()
Definition: trafficgraphwidget.cpp:163
ClientModel
Model for Bitcoin network client.
Definition: clientmodel.h:47
TrafficGraphWidget::m_range
std::chrono::minutes m_range
Definition: trafficgraphwidget.h:42
TrafficGraphWidget::fMax
float fMax
Definition: trafficgraphwidget.h:41
TrafficGraphWidget::nLastBytesIn
quint64 nLastBytesIn
Definition: trafficgraphwidget.h:45
TrafficGraphWidget::updateRates
void updateRates()
Definition: trafficgraphwidget.cpp:122
TrafficGraphWidget::nLastBytesOut
quint64 nLastBytesOut
Definition: trafficgraphwidget.h:46
TrafficGraphWidget
Definition: trafficgraphwidget.h:20