10#include <QPainterPath> 
   16#define DESIRED_SAMPLES         800 
   32    timer = 
new QTimer(
this);
 
   52    int sampleCount = samples.size();
 
   57        for(
int i = 0; i < sampleCount; ++i) {
 
   59            int y = 
YMARGIN + h - (int)(h * samples.at(i) / 
fMax);
 
   68    QPainter painter(
this);
 
   69    painter.fillRect(rect(), Qt::black);
 
   71    if(
fMax <= 0.0f) 
return;
 
   73    QColor axisCol(Qt::gray);
 
   75    painter.setPen(axisCol);
 
   79    int base = floor(log10(
fMax));
 
   80    float val = pow(10.0f, base);
 
   82    const QString units = tr(
"kB/s");
 
   83    const float yMarginText = 2.0;
 
   86    painter.setPen(axisCol);
 
   87    painter.drawText(
XMARGIN, 
YMARGIN + h - h * val / 
fMax-yMarginText, QString(
"%1 %2").arg(val).arg(units));
 
   88    for(
float y = val; y < 
fMax; y += val) {
 
   93    if(
fMax / val <= 3.0f) {
 
   94        axisCol = axisCol.darker();
 
   95        val = pow(10.0f, base - 1);
 
   96        painter.setPen(axisCol);
 
   97        painter.drawText(
XMARGIN, 
YMARGIN + h - h * val / 
fMax-yMarginText, QString(
"%1 %2").arg(val).arg(units));
 
   99        for(
float y = val; y < 
fMax; y += val, 
count++) {
 
  108    painter.setRenderHint(QPainter::Antialiasing);
 
  112        painter.fillPath(p, QColor(0, 255, 0, 128));
 
  113        painter.setPen(Qt::green);
 
  119        painter.fillPath(p, QColor(255, 0, 0, 128));
 
  120        painter.setPen(Qt::red);
 
  131    float in_rate_kilobytes_per_sec = 
static_cast<float>(bytesIn - 
nLastBytesIn) / 
timer->interval();
 
  132    float out_rate_kilobytes_per_sec = 
static_cast<float>(bytesOut - 
nLastBytesOut) / 
timer->interval();
 
  133    vSamplesIn.push_front(in_rate_kilobytes_per_sec);
 
  134    vSamplesOut.push_front(out_rate_kilobytes_per_sec);
 
  147        if(f > tmax) tmax = f;
 
  150        if(f > tmax) tmax = f;
 
  161    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.