8 #include <boost/bind.hpp> 19 #define DEFAULT_SAMPLE_HEIGHT 1.1f 29 timer =
new QTimer(
this);
52 int sampleCount = queue.size(), x =
XMARGIN + w, y;
55 for(
int i = 0; i < sampleCount; ++i) {
57 y =
YMARGIN + h - (int)(h * chooser(queue.at(i)) /
fMax);
78 QPainter painter(
this);
79 painter.fillRect(rect(), Qt::black);
81 if(
fMax <= 0.0
f)
return;
83 QColor axisCol(Qt::gray);
85 painter.setPen(axisCol);
90 float val = pow(10.0
f,
base);
92 const QString units = tr(
"KB/s");
93 const float yMarginText = 2.0;
96 painter.setPen(axisCol);
97 painter.drawText(
XMARGIN,
YMARGIN + h - h * val /
fMax-yMarginText, QString(
"%1 %2").arg(val).arg(units));
98 for(
float y = val; y <
fMax; y += val) {
103 if(
fMax / val <= 3.0
f) {
104 axisCol = axisCol.darker();
105 val = pow(10.0
f,
base - 1);
106 painter.setPen(axisCol);
107 painter.drawText(
XMARGIN,
YMARGIN + h - h * val /
fMax-yMarginText, QString(
"%1 %2").arg(val).arg(units));
109 for(
float y = val; y <
fMax; y += val,
count++) {
122 paintPath(pIn, queue, boost::bind(chooseIn,_1));
123 painter.fillPath(pIn, QColor(0, 255, 0, 128));
124 painter.setPen(Qt::green);
125 painter.drawPath(pIn);
128 paintPath(pOut, queue, boost::bind(chooseOut,_1));
129 painter.fillPath(pOut, QColor(255, 0, 0, 128));
130 painter.setPen(Qt::red);
131 painter.drawPath(pOut);
144 if(sample.
in > tmax) tmax = sample.
in;
145 if(sample.
out > tmax) tmax = sample.
out;
void setLastBytes(quint64 nLastBytesIn, quint64 nLastBytesOut)
static const int SMALLEST_SAMPLE_PERIOD
void switchRange(GraphRange newRange)
quint64 getTotalBytesRecv() const
bool update(const TrafficSample &trafficSample)
static const int DESIRED_DATA_SAMPLES
SampleQueue getCurrentRangeQueueWithAverageBandwidth()
QQueue< TrafficSample > SampleQueue
quint64 getTotalBytesSent() const