12#include <QPainterPath>
17#define DESIRED_SAMPLES 800
23 : QWidget(parent), timer(nullptr), fMax(0.0f), nMins(0), vSamplesIn(),
24 vSamplesOut(), nLastBytesIn(0), nLastBytesOut(0), clientModel(nullptr) {
25 timer =
new QTimer(
this);
42 int sampleCount = samples.size();
43 if (sampleCount > 0) {
47 for (
int i = 0; i < sampleCount; ++i) {
49 int y =
YMARGIN + h - (int)(h * samples.at(i) /
fMax);
57 QPainter painter(
this);
58 painter.fillRect(rect(), Qt::black);
64 QColor axisCol(Qt::gray);
66 painter.setPen(axisCol);
70 int base = floor(log10(
fMax));
71 float val = pow(10.0f, base);
73 const QString units = tr(
"KB/s");
74 const float yMarginText = 2.0;
77 painter.setPen(axisCol);
79 QString(
"%1 %2").arg(val).arg(units));
80 for (
float y = val; y <
fMax; y += val) {
86 if (
fMax / val <= 3.0f) {
87 axisCol = axisCol.darker();
88 val = pow(10.0f, base - 1);
89 painter.setPen(axisCol);
91 QString(
"%1 %2").arg(val).arg(units));
93 for (
float y = val; y <
fMax; y += val,
count++) {
95 if (
count % 10 == 0) {
103 painter.setRenderHint(QPainter::Antialiasing);
107 painter.fillPath(p, QColor(0, 255, 0, 128));
108 painter.setPen(Qt::green);
114 painter.fillPath(p, QColor(255, 0, 0, 128));
115 painter.setPen(Qt::red);
162 timer->setInterval(msecsPerSample);
Model for Bitcoin network client.
interfaces::Node & node() const
virtual int64_t getTotalBytesRecv()=0
Get total bytes recv.
virtual int64_t getTotalBytesSent()=0
Get total bytes sent.