SpeedPlotView: Simplify code using PointData struct

This commit is contained in:
Anton Lashkov 2016-02-27 14:22:43 +04:00
parent b599a8e2fb
commit 8a6866d409
3 changed files with 64 additions and 100 deletions

View file

@ -138,17 +138,20 @@ void SpeedWidget::update()
BitTorrent::SessionStatus btStatus = BitTorrent::Session::instance()->status();
m_plot->pushXPoint(QDateTime::currentDateTime().toTime_t());
m_plot->pushYPoint(SpeedPlotView::UP, btStatus.uploadRate());
m_plot->pushYPoint(SpeedPlotView::DOWN, btStatus.downloadRate());
m_plot->pushYPoint(SpeedPlotView::PAYLOAD_UP, btStatus.payloadUploadRate());
m_plot->pushYPoint(SpeedPlotView::PAYLOAD_DOWN, btStatus.payloadDownloadRate());
m_plot->pushYPoint(SpeedPlotView::OVERHEAD_UP, btStatus.ipOverheadUploadRate());
m_plot->pushYPoint(SpeedPlotView::OVERHEAD_DOWN, btStatus.ipOverheadDownloadRate());
m_plot->pushYPoint(SpeedPlotView::DHT_UP, btStatus.dhtUploadRate());
m_plot->pushYPoint(SpeedPlotView::DHT_DOWN, btStatus.dhtDownloadRate());
m_plot->pushYPoint(SpeedPlotView::TRACKER_UP, btStatus.trackerUploadRate());
m_plot->pushYPoint(SpeedPlotView::TRACKER_DOWN, btStatus.trackerDownloadRate());
SpeedPlotView::PointData point;
point.x = QDateTime::currentDateTime().toTime_t();
point.y[SpeedPlotView::UP] = btStatus.uploadRate();
point.y[SpeedPlotView::DOWN] = btStatus.downloadRate();
point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate();
point.y[SpeedPlotView::PAYLOAD_DOWN] = btStatus.payloadDownloadRate();
point.y[SpeedPlotView::OVERHEAD_UP] = btStatus.ipOverheadUploadRate();
point.y[SpeedPlotView::OVERHEAD_DOWN] = btStatus.ipOverheadDownloadRate();
point.y[SpeedPlotView::DHT_UP] = btStatus.dhtUploadRate();
point.y[SpeedPlotView::DHT_DOWN] = btStatus.dhtDownloadRate();
point.y[SpeedPlotView::TRACKER_UP] = btStatus.trackerUploadRate();
point.y[SpeedPlotView::TRACKER_DOWN] = btStatus.trackerDownloadRate();
m_plot->pushPoint(point);
QMetaObject::invokeMethod(this, "graphUpdate", Qt::QueuedConnection);
Utils::Misc::msleep(1000);