From 7d811e2b8b9b2aa2c8df6450bb0a83898dca6d28 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 4 Feb 2021 12:07:16 +0900 Subject: Renaming of files in preparation for code style tools. Signed-off-by: Michele Calgaro (cherry picked from commit 286e9fe2ad29b5a1b6520efaed7ed2a54198ae17) --- plugins/stats/ChartDrawer.cc | 473 --------------------------------- plugins/stats/ChartDrawer.cpp | 473 +++++++++++++++++++++++++++++++++ plugins/stats/ChartDrawerData.cc | 100 ------- plugins/stats/ChartDrawerData.cpp | 100 +++++++ plugins/stats/Makefile.am | 4 +- plugins/stats/PeerMonitor.cc | 187 ------------- plugins/stats/PeerMonitor.cpp | 187 +++++++++++++ plugins/stats/StatsCon.cc | 113 -------- plugins/stats/StatsCon.cpp | 113 ++++++++ plugins/stats/StatsPluginPrefs.cc | 88 ------ plugins/stats/StatsPluginPrefs.cpp | 88 ++++++ plugins/stats/StatsPluginPrefsPage.cc | 29 -- plugins/stats/StatsPluginPrefsPage.cpp | 29 ++ plugins/stats/StatsSpd.cc | 138 ---------- plugins/stats/StatsSpd.cpp | 138 ++++++++++ plugins/stats/statsplugin.cc | 321 ---------------------- plugins/stats/statsplugin.cpp | 321 ++++++++++++++++++++++ 17 files changed, 1451 insertions(+), 1451 deletions(-) delete mode 100644 plugins/stats/ChartDrawer.cc create mode 100644 plugins/stats/ChartDrawer.cpp delete mode 100644 plugins/stats/ChartDrawerData.cc create mode 100644 plugins/stats/ChartDrawerData.cpp delete mode 100644 plugins/stats/PeerMonitor.cc create mode 100644 plugins/stats/PeerMonitor.cpp delete mode 100644 plugins/stats/StatsCon.cc create mode 100644 plugins/stats/StatsCon.cpp delete mode 100644 plugins/stats/StatsPluginPrefs.cc create mode 100644 plugins/stats/StatsPluginPrefs.cpp delete mode 100644 plugins/stats/StatsPluginPrefsPage.cc create mode 100644 plugins/stats/StatsPluginPrefsPage.cpp delete mode 100644 plugins/stats/StatsSpd.cc create mode 100644 plugins/stats/StatsSpd.cpp delete mode 100644 plugins/stats/statsplugin.cc create mode 100644 plugins/stats/statsplugin.cpp (limited to 'plugins/stats') diff --git a/plugins/stats/ChartDrawer.cc b/plugins/stats/ChartDrawer.cc deleted file mode 100644 index 6eb08b4..0000000 --- a/plugins/stats/ChartDrawer.cc +++ /dev/null @@ -1,473 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "ChartDrawer.h" - -#ifdef USE_SOLARIS -#include -int isinf(double x) { return !finite(x) && x==x; } -#endif - - -namespace kt { - -ChartDrawer::ChartDrawer(TQWidget *p, wgtsize_t x_max, wgtsize_t y_max, bool autom, const TQString & uname) : TQWidget(p), mXMax(x_max), mYMax(y_max), mAutoMax(autom), - mUnitName(uname), mMMode(MaxModeExact) -{ - setBackgroundColor("white"); -} - -ChartDrawer::~ChartDrawer() -{ - TQToolTip::remove(this); -} - -ChartDrawer::wgtsize_t ChartDrawer::GetXMax() const -{ - return mXMax; -} - -ChartDrawer::wgtsize_t ChartDrawer::GetYMax() const -{ - return mYMax; -} - -void ChartDrawer::SetXMax(const wgtsize_t x) -{ - mXMax = x; - - for(size_t i = 0; i < mEls.size(); i++) - { - mEls[i].pmVals -> resize(x, 0.0); - } -} - -void ChartDrawer::SetYMax(const wgtsize_t y) -{ - mYMax = y; -} - -inline ChartDrawer::wgtsize_t ChartDrawer::GetYScale() const -{ - return height() / 8; -} - - -inline ChartDrawer::wgtunit_t ChartDrawer::TrY(const ChartDrawer::wgtunit_t y) const -{ - return height() - y; -} - -void ChartDrawer::paintEvent ( TQPaintEvent *) -{ - TQPainter pnt( this ); - - DrawScale(pnt); - DrawFrame(pnt); - DrawChart(pnt); - -} - -inline ChartDrawer::wgtunit_t ChartDrawer::height() const -{ - return TQWidget::height() - 15; -} - -inline ChartDrawer::wgtunit_t ChartDrawer::width() const -{ - return TQWidget::width() - 65; -} - -void ChartDrawer::DrawFrame(TQPainter & rPnt ) -{ - TQPen op = rPnt.pen(); - rPnt.setPen(TQPen("#000", 3)); - - rPnt.drawLine(0, TrY(0), width()+3, TrY(0)); - rPnt.drawLine(width()+1, TrY(0), width()+1, TrY(TQWidget::height())); - - TQFont oldf(rPnt.font()); - TQFont newf(oldf); - newf.setWeight(TQFont::Bold); - newf.setPointSize(10); - newf.setUnderline(1); - - rPnt.setFont(newf); - rPnt.drawText(width() + 30, TrY(-7), mUnitName); - rPnt.setFont(oldf); - - rPnt.setPen(op); -} - -void ChartDrawer::DrawScale(TQPainter & rPnt ) -{ - - if(!mYMax) - { - return; - } - - TQPen op = rPnt.pen(); - TQPen ep("#eee", 1, TQt::DashLine); - TQPen lp("#666", 2, TQt::DotLine); - TQPen tp("#000"); - - rPnt.setPen(ep); - - for(wgtsize_t i = 1; i < width(); i += 10) - { - rPnt.drawLine(i, TrY(0), i, TrY(height())); - } - - for(wgtsize_t i = 0; i < height(); i += 10) - { - rPnt.drawLine(0, TrY(i), width(), TrY(i)); - } - - rPnt.setPen(lp); - rPnt.drawLine(0, TrY(height() - 10), width(), TrY(height() - 10)); - rPnt.setPen(tp); - rPnt.drawText(width() + 4, TrY(height() - 10) + 4, TQString::number (mYMax)); - - for(wgtsize_t i = 0; i < height() - 15 ; i += GetYScale()) - { - rPnt.setPen(lp); - rPnt.drawLine(0, TrY(i), width(), TrY(i)); - rPnt.setPen(tp); - rPnt.drawText(width() + 4, TrY(i) + 4, TQString::number ( (mYMax / 8.0 ) * ( i / static_cast(GetYScale() )), 'f', 1 ) ); - } - - rPnt.setPen(op); -} - -void ChartDrawer::DrawChart(TQPainter & rPnt) -{ - - TQPen op = rPnt.pen(); - - uint32_t skip_max = 0; - - for(size_t i = 0; i < mEls.size(); i++) - { - rPnt.setPen( *mEls[i].GetPen() ); - - for(size_t j = 1; j < mEls[i].pmVals -> size() - 1; j++) - { - rPnt.drawLine( - FindXScreenCoords(j-1), - TrY(FindYScreenCoords(mEls[i].pmVals -> at(j-1))), - FindXScreenCoords(j), - TrY(FindYScreenCoords(mEls[i].pmVals -> at(j))) - ); - } -// - rPnt.drawLine( - FindXScreenCoords(mEls[i].pmVals -> size() - 2), - TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 2))), - width(), - TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) - ); - - // -------------------- - // Line on top - // ------------ - TQPen myop(rPnt.pen()); - TQPen topl(myop); - topl.setStyle(Qt::DotLine); - rPnt.setPen(topl); - rPnt.drawLine(0, TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))), width(), TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) ); - rPnt.setPen(myop); - - TQFont oldf(rPnt.font()); - TQFont newf(oldf); - newf.setWeight(TQFont::Bold); - newf.setPointSize(8); - - rPnt.setFont(newf); - rPnt.drawText(5 + (i * 50), TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) + 11, TQString::number (mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1), 'f', 2 ) ); - - - //------------------ - // max - //------------------ - - if(mMarkMax[i]) - { - rPnt.setPen(topl); - std::pair max = mEls[i] . Max(); - - rPnt.drawLine( - FindXScreenCoords(max.second), TrY(0), FindXScreenCoords(max.second), TrY(height()) - ); - - rPnt.setPen(myop); - - rPnt.setFont(newf); - TQString maxv(TQString::number (max.first, 'f', 2)); - - if(FindXScreenCoords(max.second) < 35) - { - rPnt.drawText(FindXScreenCoords(max.second) + 5, TrY(height() - (10 * (i - skip_max)) ) + 10, maxv ) ; - } else { - rPnt.drawText(FindXScreenCoords(max.second) - 35 , TrY(height() - (10 * (i - skip_max)) ) + 10, maxv ) ; - } - } else { - skip_max++; - } - - rPnt.setFont(oldf); - rPnt.setPen(op); - } - - rPnt.setPen(op); -} - -inline ChartDrawer::wgtunit_t ChartDrawer::FindXScreenCoords(const double x) const -{ - return static_cast((width() / static_cast(mXMax)) * x) ; -} - -inline ChartDrawer::wgtunit_t ChartDrawer::FindYScreenCoords(const double y) const -{ - return static_cast(((height()) / static_cast(mYMax)) * y) ; -} - -void ChartDrawer::EnableAutoMax(bool a) -{ - mAutoMax = a; -} - -void ChartDrawer::AddValue(const size_t idx, const double val, bool u ) -{ - - if( idx >= mEls.size() ) - { - return; - } - - ChartDrawerData::val_t::iterator it = mEls[idx].pmVals -> begin(); - - while(it != mEls[idx] .pmVals -> end() ) - { - *it = *(it + 1); - it++; - } - -#ifdef USE_SOLARIS - if(isnand(val) || (isinf(val))) -#else - if(std::isnan(val) || (std::isinf(val))) -#endif - { - *(mEls[idx].pmVals -> end() -1) = 0.0; - } else { - *(mEls[idx].pmVals -> end() -1) = val; - } - - if(mAutoMax) - { - if( (mMMode == MaxModeTop) && (val > mYMax) ) - { - mYMax = static_cast(val) + 3; - - } else if(mMMode == MaxModeExact) { - FindSetMax(); - } - } - - if(u) - { - update(); - } - -} - -void ChartDrawer::AddValues(ChartDrawerData Cdd, const bool max) -{ - if(Cdd.pmVals -> size() != mXMax) - { - Cdd.pmVals -> resize(mXMax, 0.0); - } - - mEls.push_back(Cdd); - mMarkMax.push_back(max); - - MakeLegendTooltip(); -} - -void ChartDrawer::AddValues(ChartDrawerData Cdd, const size_t idx, const bool max) -{ - if(Cdd.pmVals -> size() != mXMax) - { - Cdd.pmVals -> resize(mXMax, 0.0); - } - - if(idx >= mEls.size()) - { - mEls.push_back(Cdd); - } else { - mEls.insert(mEls.begin() + idx, Cdd); - } - - if(idx >= mMarkMax.size()) - { - mMarkMax.push_back(max); - } else { - mMarkMax.insert(mMarkMax.begin() + idx, max); - } - - MakeLegendTooltip(); -} - -void ChartDrawer::AddValuesCnt(const TQString & rN, const bool max) -{ - mEls.push_back(ChartDrawerData(mXMax, rN)); - mMarkMax.push_back(max); - - MakeLegendTooltip(); -} - -void ChartDrawer::AddValuesCnt(const TQPen & rP, const TQString & rN, const bool max) -{ - mEls.push_back(ChartDrawerData(rP, mXMax, rN)); - mMarkMax.push_back(max); - - MakeLegendTooltip(); -} - -void ChartDrawer::SetUnitName(const TQString & rN) -{ - mUnitName = rN; -} - -TQString ChartDrawer::GetUnitName() const -{ - return mUnitName; -} - -void ChartDrawer::mouseDoubleClickEvent ( TQMouseEvent * evt ) -{ - FindSetMax(); - - emit DoubleClicked(evt); -} - -void ChartDrawer::EnableMaxDrawAt(const size_t at, const bool e) -{ - if(at >= mMarkMax.size()) - { - return; - } - - mMarkMax[at] = e; -} - -void ChartDrawer::RemoveValuesCnt(const size_t idx) -{ - if(idx >= mEls.size()) - { - return; - } - - mEls.erase(mEls.begin() + idx); - - if(idx <= mMarkMax.size()) - { - mMarkMax.erase(mMarkMax.begin() + idx); - } - - MakeLegendTooltip(); - -} - -void ChartDrawer::Zero(const size_t idx) -{ - if(idx >= mEls.size()) - { - return; - } - - std::fill(mEls[idx].pmVals -> begin(), mEls[idx].pmVals -> end(), 0.0); - - if(mAutoMax) - { - mYMax = 1; - } -} - -void ChartDrawer::MakeLegendTooltip() -{ - TQToolTip::remove(this); - - TQString helpstr(TQString("%1:

").arg(i18n("Legend"))); - TQMimeSourceFactory* factory = TQMimeSourceFactory::defaultFactory(); - std::vector img; - - for(size_t i = 0; i < mEls.size(); i++) - { - img.push_back(TQImage(16,16, 32)); - img[i].fill(TQColor(mEls[i].GetPen() -> color()).pixel()); - - for(uint8_t px = 0; px < 16; px++) - { - img[i].setPixel(px, 0, 0); //t - img[i].setPixel(0, px, 0); //l - img[i].setPixel(px, 15, 0); //b - img[i].setPixel(15, px, 0); //r - } - - factory->setImage(mEls[i].GetName().replace(' ', '_') + "-" + TQString::number(i), img[i]); - helpstr += TQString("  -  %2
").arg(mEls[i].GetName().replace(" ", "_") + "-" + TQString::number(i)).arg( mEls[i].GetName() ); - } - - TQToolTip::add(this, helpstr); -} - -void ChartDrawer::FindSetMax() -{ - wgtsize_t mymax = 1; - - for(val_t::const_iterator it = mEls.begin(); it != mEls.end(); ++it) - { - for(ChartDrawerData::val_t::const_iterator subit = it -> pmVals -> begin(); subit != it -> pmVals -> end(); ++subit) - { - if ( (*subit) > mymax ) - { - mymax = static_cast(*subit) + 3; - } - } - } - - mYMax = mymax; -} - -void ChartDrawer::SetMaxMode(const MaxMode mm) -{ - mMMode = mm; -} - -ChartDrawer::MaxMode ChartDrawer::GetMaxMode() const -{ - return mMMode; -} - -} //NS end - -#include "ChartDrawer.moc" diff --git a/plugins/stats/ChartDrawer.cpp b/plugins/stats/ChartDrawer.cpp new file mode 100644 index 0000000..6eb08b4 --- /dev/null +++ b/plugins/stats/ChartDrawer.cpp @@ -0,0 +1,473 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "ChartDrawer.h" + +#ifdef USE_SOLARIS +#include +int isinf(double x) { return !finite(x) && x==x; } +#endif + + +namespace kt { + +ChartDrawer::ChartDrawer(TQWidget *p, wgtsize_t x_max, wgtsize_t y_max, bool autom, const TQString & uname) : TQWidget(p), mXMax(x_max), mYMax(y_max), mAutoMax(autom), + mUnitName(uname), mMMode(MaxModeExact) +{ + setBackgroundColor("white"); +} + +ChartDrawer::~ChartDrawer() +{ + TQToolTip::remove(this); +} + +ChartDrawer::wgtsize_t ChartDrawer::GetXMax() const +{ + return mXMax; +} + +ChartDrawer::wgtsize_t ChartDrawer::GetYMax() const +{ + return mYMax; +} + +void ChartDrawer::SetXMax(const wgtsize_t x) +{ + mXMax = x; + + for(size_t i = 0; i < mEls.size(); i++) + { + mEls[i].pmVals -> resize(x, 0.0); + } +} + +void ChartDrawer::SetYMax(const wgtsize_t y) +{ + mYMax = y; +} + +inline ChartDrawer::wgtsize_t ChartDrawer::GetYScale() const +{ + return height() / 8; +} + + +inline ChartDrawer::wgtunit_t ChartDrawer::TrY(const ChartDrawer::wgtunit_t y) const +{ + return height() - y; +} + +void ChartDrawer::paintEvent ( TQPaintEvent *) +{ + TQPainter pnt( this ); + + DrawScale(pnt); + DrawFrame(pnt); + DrawChart(pnt); + +} + +inline ChartDrawer::wgtunit_t ChartDrawer::height() const +{ + return TQWidget::height() - 15; +} + +inline ChartDrawer::wgtunit_t ChartDrawer::width() const +{ + return TQWidget::width() - 65; +} + +void ChartDrawer::DrawFrame(TQPainter & rPnt ) +{ + TQPen op = rPnt.pen(); + rPnt.setPen(TQPen("#000", 3)); + + rPnt.drawLine(0, TrY(0), width()+3, TrY(0)); + rPnt.drawLine(width()+1, TrY(0), width()+1, TrY(TQWidget::height())); + + TQFont oldf(rPnt.font()); + TQFont newf(oldf); + newf.setWeight(TQFont::Bold); + newf.setPointSize(10); + newf.setUnderline(1); + + rPnt.setFont(newf); + rPnt.drawText(width() + 30, TrY(-7), mUnitName); + rPnt.setFont(oldf); + + rPnt.setPen(op); +} + +void ChartDrawer::DrawScale(TQPainter & rPnt ) +{ + + if(!mYMax) + { + return; + } + + TQPen op = rPnt.pen(); + TQPen ep("#eee", 1, TQt::DashLine); + TQPen lp("#666", 2, TQt::DotLine); + TQPen tp("#000"); + + rPnt.setPen(ep); + + for(wgtsize_t i = 1; i < width(); i += 10) + { + rPnt.drawLine(i, TrY(0), i, TrY(height())); + } + + for(wgtsize_t i = 0; i < height(); i += 10) + { + rPnt.drawLine(0, TrY(i), width(), TrY(i)); + } + + rPnt.setPen(lp); + rPnt.drawLine(0, TrY(height() - 10), width(), TrY(height() - 10)); + rPnt.setPen(tp); + rPnt.drawText(width() + 4, TrY(height() - 10) + 4, TQString::number (mYMax)); + + for(wgtsize_t i = 0; i < height() - 15 ; i += GetYScale()) + { + rPnt.setPen(lp); + rPnt.drawLine(0, TrY(i), width(), TrY(i)); + rPnt.setPen(tp); + rPnt.drawText(width() + 4, TrY(i) + 4, TQString::number ( (mYMax / 8.0 ) * ( i / static_cast(GetYScale() )), 'f', 1 ) ); + } + + rPnt.setPen(op); +} + +void ChartDrawer::DrawChart(TQPainter & rPnt) +{ + + TQPen op = rPnt.pen(); + + uint32_t skip_max = 0; + + for(size_t i = 0; i < mEls.size(); i++) + { + rPnt.setPen( *mEls[i].GetPen() ); + + for(size_t j = 1; j < mEls[i].pmVals -> size() - 1; j++) + { + rPnt.drawLine( + FindXScreenCoords(j-1), + TrY(FindYScreenCoords(mEls[i].pmVals -> at(j-1))), + FindXScreenCoords(j), + TrY(FindYScreenCoords(mEls[i].pmVals -> at(j))) + ); + } +// + rPnt.drawLine( + FindXScreenCoords(mEls[i].pmVals -> size() - 2), + TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 2))), + width(), + TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) + ); + + // -------------------- + // Line on top + // ------------ + TQPen myop(rPnt.pen()); + TQPen topl(myop); + topl.setStyle(Qt::DotLine); + rPnt.setPen(topl); + rPnt.drawLine(0, TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))), width(), TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) ); + rPnt.setPen(myop); + + TQFont oldf(rPnt.font()); + TQFont newf(oldf); + newf.setWeight(TQFont::Bold); + newf.setPointSize(8); + + rPnt.setFont(newf); + rPnt.drawText(5 + (i * 50), TrY(FindYScreenCoords(mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1))) + 11, TQString::number (mEls[i].pmVals -> at(mEls[i].pmVals -> size() - 1), 'f', 2 ) ); + + + //------------------ + // max + //------------------ + + if(mMarkMax[i]) + { + rPnt.setPen(topl); + std::pair max = mEls[i] . Max(); + + rPnt.drawLine( + FindXScreenCoords(max.second), TrY(0), FindXScreenCoords(max.second), TrY(height()) + ); + + rPnt.setPen(myop); + + rPnt.setFont(newf); + TQString maxv(TQString::number (max.first, 'f', 2)); + + if(FindXScreenCoords(max.second) < 35) + { + rPnt.drawText(FindXScreenCoords(max.second) + 5, TrY(height() - (10 * (i - skip_max)) ) + 10, maxv ) ; + } else { + rPnt.drawText(FindXScreenCoords(max.second) - 35 , TrY(height() - (10 * (i - skip_max)) ) + 10, maxv ) ; + } + } else { + skip_max++; + } + + rPnt.setFont(oldf); + rPnt.setPen(op); + } + + rPnt.setPen(op); +} + +inline ChartDrawer::wgtunit_t ChartDrawer::FindXScreenCoords(const double x) const +{ + return static_cast((width() / static_cast(mXMax)) * x) ; +} + +inline ChartDrawer::wgtunit_t ChartDrawer::FindYScreenCoords(const double y) const +{ + return static_cast(((height()) / static_cast(mYMax)) * y) ; +} + +void ChartDrawer::EnableAutoMax(bool a) +{ + mAutoMax = a; +} + +void ChartDrawer::AddValue(const size_t idx, const double val, bool u ) +{ + + if( idx >= mEls.size() ) + { + return; + } + + ChartDrawerData::val_t::iterator it = mEls[idx].pmVals -> begin(); + + while(it != mEls[idx] .pmVals -> end() ) + { + *it = *(it + 1); + it++; + } + +#ifdef USE_SOLARIS + if(isnand(val) || (isinf(val))) +#else + if(std::isnan(val) || (std::isinf(val))) +#endif + { + *(mEls[idx].pmVals -> end() -1) = 0.0; + } else { + *(mEls[idx].pmVals -> end() -1) = val; + } + + if(mAutoMax) + { + if( (mMMode == MaxModeTop) && (val > mYMax) ) + { + mYMax = static_cast(val) + 3; + + } else if(mMMode == MaxModeExact) { + FindSetMax(); + } + } + + if(u) + { + update(); + } + +} + +void ChartDrawer::AddValues(ChartDrawerData Cdd, const bool max) +{ + if(Cdd.pmVals -> size() != mXMax) + { + Cdd.pmVals -> resize(mXMax, 0.0); + } + + mEls.push_back(Cdd); + mMarkMax.push_back(max); + + MakeLegendTooltip(); +} + +void ChartDrawer::AddValues(ChartDrawerData Cdd, const size_t idx, const bool max) +{ + if(Cdd.pmVals -> size() != mXMax) + { + Cdd.pmVals -> resize(mXMax, 0.0); + } + + if(idx >= mEls.size()) + { + mEls.push_back(Cdd); + } else { + mEls.insert(mEls.begin() + idx, Cdd); + } + + if(idx >= mMarkMax.size()) + { + mMarkMax.push_back(max); + } else { + mMarkMax.insert(mMarkMax.begin() + idx, max); + } + + MakeLegendTooltip(); +} + +void ChartDrawer::AddValuesCnt(const TQString & rN, const bool max) +{ + mEls.push_back(ChartDrawerData(mXMax, rN)); + mMarkMax.push_back(max); + + MakeLegendTooltip(); +} + +void ChartDrawer::AddValuesCnt(const TQPen & rP, const TQString & rN, const bool max) +{ + mEls.push_back(ChartDrawerData(rP, mXMax, rN)); + mMarkMax.push_back(max); + + MakeLegendTooltip(); +} + +void ChartDrawer::SetUnitName(const TQString & rN) +{ + mUnitName = rN; +} + +TQString ChartDrawer::GetUnitName() const +{ + return mUnitName; +} + +void ChartDrawer::mouseDoubleClickEvent ( TQMouseEvent * evt ) +{ + FindSetMax(); + + emit DoubleClicked(evt); +} + +void ChartDrawer::EnableMaxDrawAt(const size_t at, const bool e) +{ + if(at >= mMarkMax.size()) + { + return; + } + + mMarkMax[at] = e; +} + +void ChartDrawer::RemoveValuesCnt(const size_t idx) +{ + if(idx >= mEls.size()) + { + return; + } + + mEls.erase(mEls.begin() + idx); + + if(idx <= mMarkMax.size()) + { + mMarkMax.erase(mMarkMax.begin() + idx); + } + + MakeLegendTooltip(); + +} + +void ChartDrawer::Zero(const size_t idx) +{ + if(idx >= mEls.size()) + { + return; + } + + std::fill(mEls[idx].pmVals -> begin(), mEls[idx].pmVals -> end(), 0.0); + + if(mAutoMax) + { + mYMax = 1; + } +} + +void ChartDrawer::MakeLegendTooltip() +{ + TQToolTip::remove(this); + + TQString helpstr(TQString("%1:

").arg(i18n("Legend"))); + TQMimeSourceFactory* factory = TQMimeSourceFactory::defaultFactory(); + std::vector img; + + for(size_t i = 0; i < mEls.size(); i++) + { + img.push_back(TQImage(16,16, 32)); + img[i].fill(TQColor(mEls[i].GetPen() -> color()).pixel()); + + for(uint8_t px = 0; px < 16; px++) + { + img[i].setPixel(px, 0, 0); //t + img[i].setPixel(0, px, 0); //l + img[i].setPixel(px, 15, 0); //b + img[i].setPixel(15, px, 0); //r + } + + factory->setImage(mEls[i].GetName().replace(' ', '_') + "-" + TQString::number(i), img[i]); + helpstr += TQString("  -  %2
").arg(mEls[i].GetName().replace(" ", "_") + "-" + TQString::number(i)).arg( mEls[i].GetName() ); + } + + TQToolTip::add(this, helpstr); +} + +void ChartDrawer::FindSetMax() +{ + wgtsize_t mymax = 1; + + for(val_t::const_iterator it = mEls.begin(); it != mEls.end(); ++it) + { + for(ChartDrawerData::val_t::const_iterator subit = it -> pmVals -> begin(); subit != it -> pmVals -> end(); ++subit) + { + if ( (*subit) > mymax ) + { + mymax = static_cast(*subit) + 3; + } + } + } + + mYMax = mymax; +} + +void ChartDrawer::SetMaxMode(const MaxMode mm) +{ + mMMode = mm; +} + +ChartDrawer::MaxMode ChartDrawer::GetMaxMode() const +{ + return mMMode; +} + +} //NS end + +#include "ChartDrawer.moc" diff --git a/plugins/stats/ChartDrawerData.cc b/plugins/stats/ChartDrawerData.cc deleted file mode 100644 index ba03261..0000000 --- a/plugins/stats/ChartDrawerData.cc +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "ChartDrawerData.h" - -namespace kt { - -ChartDrawerData::ChartDrawerData(const TQString & rN) : pmQp(new TQPen("#000", 1, TQt::SolidLine)), pmVals(new val_t(2, 0.0)), mName(rN) -{ -} - -ChartDrawerData::ChartDrawerData(const size_t s, const TQString & rN) : pmQp(new TQPen("#000", 1, TQt::SolidLine)), pmVals(new val_t(s, 0.0)), mName(rN) -{ -} - -ChartDrawerData::ChartDrawerData(const TQPen & rQp, const TQString & rN) : pmQp(new TQPen(rQp)), pmVals(new val_t(2, 0.0)), mName(rN) -{ -} - -ChartDrawerData::ChartDrawerData(const TQPen & rQp, const size_t s, const TQString & rN) : pmQp(new TQPen(rQp)), pmVals(new val_t(s, 0.0)), mName(rN) -{ -} - -ChartDrawerData::ChartDrawerData(const ChartDrawerData & rS) -{ - pmQp = new TQPen(*rS.pmQp); - pmVals = new val_t(*rS.pmVals); - mName = rS.mName; -} - -ChartDrawerData::~ChartDrawerData() -{ - delete pmQp; - delete pmVals; -} - -const ChartDrawerData::val_t * ChartDrawerData::GetVals() const -{ - return pmVals; -} - -const TQPen * ChartDrawerData::GetPen() const -{ - return pmQp; -} - -void ChartDrawerData::SetPen(const TQPen & rQp) -{ - delete pmQp; - pmQp = new TQPen(rQp); -} - -std::pair ChartDrawerData::Max() const -{ - - double max = 0.0; - size_t cpos = 0; - size_t maxpos = 0; - - for(val_t::iterator it = pmVals -> begin(); it != pmVals -> end(); it++) - { - if(max <= *it) - { - max = *it; - maxpos = cpos; - } - - cpos++; - } - - return std::make_pair(max, maxpos); -} - -TQString ChartDrawerData::GetName() const -{ - return mName; -} -void ChartDrawerData::SetName( const TQString & rN ) -{ - mName = rN; -} - -} // NS end diff --git a/plugins/stats/ChartDrawerData.cpp b/plugins/stats/ChartDrawerData.cpp new file mode 100644 index 0000000..ba03261 --- /dev/null +++ b/plugins/stats/ChartDrawerData.cpp @@ -0,0 +1,100 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "ChartDrawerData.h" + +namespace kt { + +ChartDrawerData::ChartDrawerData(const TQString & rN) : pmQp(new TQPen("#000", 1, TQt::SolidLine)), pmVals(new val_t(2, 0.0)), mName(rN) +{ +} + +ChartDrawerData::ChartDrawerData(const size_t s, const TQString & rN) : pmQp(new TQPen("#000", 1, TQt::SolidLine)), pmVals(new val_t(s, 0.0)), mName(rN) +{ +} + +ChartDrawerData::ChartDrawerData(const TQPen & rQp, const TQString & rN) : pmQp(new TQPen(rQp)), pmVals(new val_t(2, 0.0)), mName(rN) +{ +} + +ChartDrawerData::ChartDrawerData(const TQPen & rQp, const size_t s, const TQString & rN) : pmQp(new TQPen(rQp)), pmVals(new val_t(s, 0.0)), mName(rN) +{ +} + +ChartDrawerData::ChartDrawerData(const ChartDrawerData & rS) +{ + pmQp = new TQPen(*rS.pmQp); + pmVals = new val_t(*rS.pmVals); + mName = rS.mName; +} + +ChartDrawerData::~ChartDrawerData() +{ + delete pmQp; + delete pmVals; +} + +const ChartDrawerData::val_t * ChartDrawerData::GetVals() const +{ + return pmVals; +} + +const TQPen * ChartDrawerData::GetPen() const +{ + return pmQp; +} + +void ChartDrawerData::SetPen(const TQPen & rQp) +{ + delete pmQp; + pmQp = new TQPen(rQp); +} + +std::pair ChartDrawerData::Max() const +{ + + double max = 0.0; + size_t cpos = 0; + size_t maxpos = 0; + + for(val_t::iterator it = pmVals -> begin(); it != pmVals -> end(); it++) + { + if(max <= *it) + { + max = *it; + maxpos = cpos; + } + + cpos++; + } + + return std::make_pair(max, maxpos); +} + +TQString ChartDrawerData::GetName() const +{ + return mName; +} +void ChartDrawerData::SetName( const TQString & rN ) +{ + mName = rN; +} + +} // NS end diff --git a/plugins/stats/Makefile.am b/plugins/stats/Makefile.am index 26c69b7..72d7d71 100644 --- a/plugins/stats/Makefile.am +++ b/plugins/stats/Makefile.am @@ -6,8 +6,8 @@ METASOURCES = AUTO kde_module_LTLIBRARIES = ktstatsplugin.la ktstatsplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEPARTS) $(all_libraries) -ktstatsplugin_la_SOURCES = ChartDrawerData.cc ChartDrawer.cc statsspdwgt.ui statsconwgt.ui StatsSpd.cc StatsCon.cc sprefwgt.ui statspluginsettings.kcfgc \ - StatsPluginPrefsPage.cc StatsPluginPrefs.cc statsplugin.cc +ktstatsplugin_la_SOURCES = ChartDrawerData.cpp ChartDrawer.cpp statsspdwgt.ui statsconwgt.ui StatsSpd.cpp StatsCon.cpp sprefwgt.ui statspluginsettings.kcfgc \ + StatsPluginPrefsPage.cpp StatsPluginPrefs.cpp statsplugin.cpp ktstatsplugin_la_LIBADD = $(LIB_QT) ../../libktorrent/libktorrent.la diff --git a/plugins/stats/PeerMonitor.cc b/plugins/stats/PeerMonitor.cc deleted file mode 100644 index 083e158..0000000 --- a/plugins/stats/PeerMonitor.cc +++ /dev/null @@ -1,187 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "PeerMonitor.h" - -namespace kt { - -PeerMonitor::PeerMonitor(kt::TorrentInterface * pTi, std::map * pM) : kt::MonitorInterface(), TQObject(), pmTorIface(pTi), pmPeerMMgr(pM) -{ - -} - -PeerMonitor::~PeerMonitor() -{ -} - -void PeerMonitor::peerAdded (kt::PeerInterface *peer) -{ - TQMutexLocker lock(&mtx); - - mPeers.push_back( peer ); -} - -void PeerMonitor::peerRemoved (kt::PeerInterface *peer) -{ - - TQMutexLocker lock(&mtx); - - data_t::iterator it = std::find(mPeers.begin(), mPeers.end(), peer); - - if(it != mPeers.end()) - { - mPeers.erase(it); - // *it = 0; - } - -} - -void PeerMonitor::downloadStarted (kt::ChunkDownloadInterface *) -{ - -} - -void PeerMonitor::downloadRemoved (kt::ChunkDownloadInterface *) -{ - -} - -void PeerMonitor::stopped () -{ - TQMutexLocker lock(&mtx); - - std::fill(mPeers.begin(), mPeers.end(), static_cast( 0 ) ); -// mPeers.clear(); -} - -void PeerMonitor::destroyed () -{ - if(pmPeerMMgr -> find(pmTorIface -> getInfoHash()) != pmPeerMMgr -> end() ) - { - pmTorIface -> setMonitor(0); - pmPeerMMgr -> erase(pmTorIface -> getInfoHash()); - delete this; - } - -} - -double PeerMonitor::LeechersUpSpeed() -{ - TQMutexLocker lock(&mtx); - - double spd = 0.0; - - //without it'll segfault/SIGABRT on stop as in meantime the iterator from - // mPeers will be invalidated - - for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) - { - if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file < 100.0) ) - { - spd += (*it) -> getStats().download_rate; - } - } - - return spd; -} - -double PeerMonitor::LeechersDownSpeed() -{ - TQMutexLocker lock(&mtx); - - double spd = 0.0; - - - for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) - { - if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file < 100.0) ) - { - spd += (*it) -> getStats().upload_rate; - } - } - - return spd; - -} - -double PeerMonitor::SeedersUpSpeed() -{ - TQMutexLocker lock(&mtx); - - double spd = 0.0; - - - for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) - { - if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file == 100.0) ) - { - spd += (*it) -> getStats().download_rate; - } - - } - - return spd; - -} - -uint64_t PeerMonitor::GetLeechers() -{ - TQMutexLocker lock(&mtx); - - uint64_t l = 0; - - - for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) - { - if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file != 100.0) ) - { - l++; - } - - } - - return l; -} - -uint64_t PeerMonitor::GetSeeders() -{ - TQMutexLocker lock(&mtx); - - uint64_t s = 0; - - - for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) - { - if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file == 100) ) - { - s++; - } - - } - - return s; -} - -kt::TorrentInterface * PeerMonitor::GetTorIface() const -{ - return pmTorIface; -} - -} //NS end diff --git a/plugins/stats/PeerMonitor.cpp b/plugins/stats/PeerMonitor.cpp new file mode 100644 index 0000000..083e158 --- /dev/null +++ b/plugins/stats/PeerMonitor.cpp @@ -0,0 +1,187 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "PeerMonitor.h" + +namespace kt { + +PeerMonitor::PeerMonitor(kt::TorrentInterface * pTi, std::map * pM) : kt::MonitorInterface(), TQObject(), pmTorIface(pTi), pmPeerMMgr(pM) +{ + +} + +PeerMonitor::~PeerMonitor() +{ +} + +void PeerMonitor::peerAdded (kt::PeerInterface *peer) +{ + TQMutexLocker lock(&mtx); + + mPeers.push_back( peer ); +} + +void PeerMonitor::peerRemoved (kt::PeerInterface *peer) +{ + + TQMutexLocker lock(&mtx); + + data_t::iterator it = std::find(mPeers.begin(), mPeers.end(), peer); + + if(it != mPeers.end()) + { + mPeers.erase(it); + // *it = 0; + } + +} + +void PeerMonitor::downloadStarted (kt::ChunkDownloadInterface *) +{ + +} + +void PeerMonitor::downloadRemoved (kt::ChunkDownloadInterface *) +{ + +} + +void PeerMonitor::stopped () +{ + TQMutexLocker lock(&mtx); + + std::fill(mPeers.begin(), mPeers.end(), static_cast( 0 ) ); +// mPeers.clear(); +} + +void PeerMonitor::destroyed () +{ + if(pmPeerMMgr -> find(pmTorIface -> getInfoHash()) != pmPeerMMgr -> end() ) + { + pmTorIface -> setMonitor(0); + pmPeerMMgr -> erase(pmTorIface -> getInfoHash()); + delete this; + } + +} + +double PeerMonitor::LeechersUpSpeed() +{ + TQMutexLocker lock(&mtx); + + double spd = 0.0; + + //without it'll segfault/SIGABRT on stop as in meantime the iterator from + // mPeers will be invalidated + + for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) + { + if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file < 100.0) ) + { + spd += (*it) -> getStats().download_rate; + } + } + + return spd; +} + +double PeerMonitor::LeechersDownSpeed() +{ + TQMutexLocker lock(&mtx); + + double spd = 0.0; + + + for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) + { + if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file < 100.0) ) + { + spd += (*it) -> getStats().upload_rate; + } + } + + return spd; + +} + +double PeerMonitor::SeedersUpSpeed() +{ + TQMutexLocker lock(&mtx); + + double spd = 0.0; + + + for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) + { + if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file == 100.0) ) + { + spd += (*it) -> getStats().download_rate; + } + + } + + return spd; + +} + +uint64_t PeerMonitor::GetLeechers() +{ + TQMutexLocker lock(&mtx); + + uint64_t l = 0; + + + for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) + { + if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file != 100.0) ) + { + l++; + } + + } + + return l; +} + +uint64_t PeerMonitor::GetSeeders() +{ + TQMutexLocker lock(&mtx); + + uint64_t s = 0; + + + for( data_t::const_iterator it = mPeers.begin(); it != mPeers.end(); it++) + { + if((it != mPeers.end()) && *it && ( (*it) -> getStats().perc_of_file == 100) ) + { + s++; + } + + } + + return s; +} + +kt::TorrentInterface * PeerMonitor::GetTorIface() const +{ + return pmTorIface; +} + +} //NS end diff --git a/plugins/stats/StatsCon.cc b/plugins/stats/StatsCon.cc deleted file mode 100644 index 568005d..0000000 --- a/plugins/stats/StatsCon.cc +++ /dev/null @@ -1,113 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "StatsCon.h" - -namespace kt { - -StatsCon::StatsCon(TQWidget * p) : StatsConWgt(p), pmPeersConCht(new ChartDrawer(PeersConGbw, StatsPluginSettings::connectionsMeasurements())), - pmDHTCht(new ChartDrawer(DHTGbw, StatsPluginSettings::dHTMeasurements())) -{ - PeersConGbw->setColumnLayout(0, Qt::Vertical ); - PeersConGbw->layout()->setSpacing( 6 ); - PeersConGbw->layout()->setMargin( 11 ); - - pmPeersConLay = new TQVBoxLayout(PeersConGbw -> layout()); - - DHTGbw->setColumnLayout(0, Qt::Vertical ); - DHTGbw->layout()->setSpacing( 6 ); - DHTGbw->layout()->setMargin( 11 ); - - pmDHTLay = new TQVBoxLayout(DHTGbw -> layout()); - - //------------- - - pmPeersConLay -> addWidget(pmPeersConCht); - pmDHTLay -> addWidget(pmDHTCht); - - //----------- - - pmPeersConCht -> SetUnitName("n"); - - pmPeersConCht -> AddValuesCnt(TQPen("#f00"), i18n("Leechers connected")); - pmPeersConCht -> AddValuesCnt(TQPen("#900"), i18n("Leechers in swarms")); - pmPeersConCht -> AddValuesCnt(TQPen("#00f"), i18n("Seeders connected")); - pmPeersConCht -> AddValuesCnt(TQPen("#009"), i18n("Seeders in swarms")); - pmPeersConCht -> AddValuesCnt(TQPen("#0a0"), i18n("Average connected leechers per torrent")); - pmPeersConCht -> AddValuesCnt(TQPen("#060"), i18n("Average connected seeders per torrent")); - pmPeersConCht -> AddValuesCnt(TQPen("#099"), i18n("Average connected leechers per running torrent")); - pmPeersConCht -> AddValuesCnt(TQPen("#055"), i18n("Average connected seeders per running torrent")); - - - pmDHTCht -> SetUnitName("n"); - - pmDHTCht -> AddValuesCnt(TQPen("#f00"), i18n("Nodes")); - pmDHTCht -> AddValuesCnt(TQPen("#00f"), i18n("Tasks")); -} - -StatsCon::~StatsCon() -{ - delete pmPeersConCht; - delete pmDHTCht; - - delete pmPeersConLay; - delete pmDHTLay; -} - -void StatsCon::AddPeersConVal(const size_t idx, const double val) -{ - pmPeersConCht -> AddValue(idx, val , false ); -} - -void StatsCon::AddDHTVal(const size_t idx, const double val) -{ - pmDHTCht -> AddValue(idx, val, false); -} - -void StatsCon::UpdateCharts() -{ - pmPeersConCht -> update(); - pmDHTCht -> update(); -} - -void StatsCon::ZeroPeersConn(const size_t idx) -{ - pmPeersConCht -> Zero(idx); -} - -void StatsCon::ChangeConnMsmtCnt(const size_t cnt) -{ - pmPeersConCht -> SetXMax(cnt); -} - -void StatsCon::ChangeDHTMsmtCnt(const size_t cnt) -{ - pmDHTCht -> SetXMax(cnt); -} - -void StatsCon::ChangeChartsMaxMode(const ChartDrawer::MaxMode mm) -{ - pmPeersConCht -> SetMaxMode(mm); - pmDHTCht -> SetMaxMode(mm); -} - -} //NS - -#include "StatsCon.moc" diff --git a/plugins/stats/StatsCon.cpp b/plugins/stats/StatsCon.cpp new file mode 100644 index 0000000..568005d --- /dev/null +++ b/plugins/stats/StatsCon.cpp @@ -0,0 +1,113 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "StatsCon.h" + +namespace kt { + +StatsCon::StatsCon(TQWidget * p) : StatsConWgt(p), pmPeersConCht(new ChartDrawer(PeersConGbw, StatsPluginSettings::connectionsMeasurements())), + pmDHTCht(new ChartDrawer(DHTGbw, StatsPluginSettings::dHTMeasurements())) +{ + PeersConGbw->setColumnLayout(0, Qt::Vertical ); + PeersConGbw->layout()->setSpacing( 6 ); + PeersConGbw->layout()->setMargin( 11 ); + + pmPeersConLay = new TQVBoxLayout(PeersConGbw -> layout()); + + DHTGbw->setColumnLayout(0, Qt::Vertical ); + DHTGbw->layout()->setSpacing( 6 ); + DHTGbw->layout()->setMargin( 11 ); + + pmDHTLay = new TQVBoxLayout(DHTGbw -> layout()); + + //------------- + + pmPeersConLay -> addWidget(pmPeersConCht); + pmDHTLay -> addWidget(pmDHTCht); + + //----------- + + pmPeersConCht -> SetUnitName("n"); + + pmPeersConCht -> AddValuesCnt(TQPen("#f00"), i18n("Leechers connected")); + pmPeersConCht -> AddValuesCnt(TQPen("#900"), i18n("Leechers in swarms")); + pmPeersConCht -> AddValuesCnt(TQPen("#00f"), i18n("Seeders connected")); + pmPeersConCht -> AddValuesCnt(TQPen("#009"), i18n("Seeders in swarms")); + pmPeersConCht -> AddValuesCnt(TQPen("#0a0"), i18n("Average connected leechers per torrent")); + pmPeersConCht -> AddValuesCnt(TQPen("#060"), i18n("Average connected seeders per torrent")); + pmPeersConCht -> AddValuesCnt(TQPen("#099"), i18n("Average connected leechers per running torrent")); + pmPeersConCht -> AddValuesCnt(TQPen("#055"), i18n("Average connected seeders per running torrent")); + + + pmDHTCht -> SetUnitName("n"); + + pmDHTCht -> AddValuesCnt(TQPen("#f00"), i18n("Nodes")); + pmDHTCht -> AddValuesCnt(TQPen("#00f"), i18n("Tasks")); +} + +StatsCon::~StatsCon() +{ + delete pmPeersConCht; + delete pmDHTCht; + + delete pmPeersConLay; + delete pmDHTLay; +} + +void StatsCon::AddPeersConVal(const size_t idx, const double val) +{ + pmPeersConCht -> AddValue(idx, val , false ); +} + +void StatsCon::AddDHTVal(const size_t idx, const double val) +{ + pmDHTCht -> AddValue(idx, val, false); +} + +void StatsCon::UpdateCharts() +{ + pmPeersConCht -> update(); + pmDHTCht -> update(); +} + +void StatsCon::ZeroPeersConn(const size_t idx) +{ + pmPeersConCht -> Zero(idx); +} + +void StatsCon::ChangeConnMsmtCnt(const size_t cnt) +{ + pmPeersConCht -> SetXMax(cnt); +} + +void StatsCon::ChangeDHTMsmtCnt(const size_t cnt) +{ + pmDHTCht -> SetXMax(cnt); +} + +void StatsCon::ChangeChartsMaxMode(const ChartDrawer::MaxMode mm) +{ + pmPeersConCht -> SetMaxMode(mm); + pmDHTCht -> SetMaxMode(mm); +} + +} //NS + +#include "StatsCon.moc" diff --git a/plugins/stats/StatsPluginPrefs.cc b/plugins/stats/StatsPluginPrefs.cc deleted file mode 100644 index e9becd6..0000000 --- a/plugins/stats/StatsPluginPrefs.cc +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "StatsPluginPrefs.h" - -namespace kt { - -StatsPluginPrefs::StatsPluginPrefs() : PrefPageInterface(i18n("Statistics"), i18n("Statistics options"), TDEGlobal::iconLoader()->loadIcon("ktimemon",TDEIcon::NoGroup)), pmUi(0) -{ -} - -StatsPluginPrefs::~StatsPluginPrefs() -{ -} - -bool StatsPluginPrefs::apply () -{ - StatsPluginSettings::setUpdateChartsEveryGuiUpdates(pmUi -> GuiUpdatesSbw -> value()); - StatsPluginSettings::setGatherDataEveryMs(pmUi -> DataIvalSbw -> value()); - StatsPluginSettings::setPeersSpeedDataIval(pmUi -> PeersSpdUpdIvalSbw -> value()); - - StatsPluginSettings::setPeersSpeed(pmUi -> PeersSpdCbw -> isChecked()); - StatsPluginSettings::setDrawSeedersInSwarms(pmUi -> ConnSdrInSwaCbw -> isChecked()); - StatsPluginSettings::setDrawLeechersInSwarms(pmUi -> ConnLchInSwaCbw -> isChecked()); - - StatsPluginSettings::setDownloadMeasurements(pmUi -> DownloadMrmtSbw -> value()); - StatsPluginSettings::setPeersSpeedMeasurements(pmUi -> PeersSpdMrmtSbw -> value()); - StatsPluginSettings::setUploadMeasurements(pmUi -> UploadMrmtSbw -> value()); - StatsPluginSettings::setConnectionsMeasurements(pmUi -> ConnsMrmtSbw -> value()); - StatsPluginSettings::setDHTMeasurements(pmUi -> DHTMrmtSbw -> value()); - StatsPluginSettings::setMaxSpdMode(pmUi -> MaxSpdModeCbw -> currentItem()); - - StatsPluginSettings::writeConfig(); - - emit Applied(); - - return true; -} - -void StatsPluginPrefs::createWidget (TQWidget *parent) -{ - pmUi = new StatsPluginPrefsPage(parent); -} - -void StatsPluginPrefs::updateData () -{ - pmUi -> GuiUpdatesSbw -> setValue(StatsPluginSettings::updateChartsEveryGuiUpdates()); - pmUi -> DataIvalSbw -> setValue(StatsPluginSettings::gatherDataEveryMs()); - pmUi -> PeersSpdUpdIvalSbw -> setValue(StatsPluginSettings::peersSpeedDataIval()); - - pmUi -> PeersSpdCbw -> setChecked(StatsPluginSettings::peersSpeed()); - pmUi -> ConnSdrInSwaCbw -> setChecked(StatsPluginSettings::drawSeedersInSwarms()); - pmUi -> ConnLchInSwaCbw -> setChecked(StatsPluginSettings::drawLeechersInSwarms()); - - pmUi -> DownloadMrmtSbw -> setValue(StatsPluginSettings::downloadMeasurements()); - pmUi -> PeersSpdMrmtSbw -> setValue(StatsPluginSettings::peersSpeedMeasurements()); - pmUi -> UploadMrmtSbw -> setValue(StatsPluginSettings::uploadMeasurements()); - pmUi -> ConnsMrmtSbw -> setValue(StatsPluginSettings::connectionsMeasurements()); - pmUi -> DHTMrmtSbw -> setValue(StatsPluginSettings::dHTMeasurements()); - pmUi -> MaxSpdModeCbw -> setCurrentItem(StatsPluginSettings::maxSpdMode()); -} - -void StatsPluginPrefs::deleteWidget () -{ - delete pmUi; -} - - -} //NS end - -#include "StatsPluginPrefs.moc" diff --git a/plugins/stats/StatsPluginPrefs.cpp b/plugins/stats/StatsPluginPrefs.cpp new file mode 100644 index 0000000..e9becd6 --- /dev/null +++ b/plugins/stats/StatsPluginPrefs.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "StatsPluginPrefs.h" + +namespace kt { + +StatsPluginPrefs::StatsPluginPrefs() : PrefPageInterface(i18n("Statistics"), i18n("Statistics options"), TDEGlobal::iconLoader()->loadIcon("ktimemon",TDEIcon::NoGroup)), pmUi(0) +{ +} + +StatsPluginPrefs::~StatsPluginPrefs() +{ +} + +bool StatsPluginPrefs::apply () +{ + StatsPluginSettings::setUpdateChartsEveryGuiUpdates(pmUi -> GuiUpdatesSbw -> value()); + StatsPluginSettings::setGatherDataEveryMs(pmUi -> DataIvalSbw -> value()); + StatsPluginSettings::setPeersSpeedDataIval(pmUi -> PeersSpdUpdIvalSbw -> value()); + + StatsPluginSettings::setPeersSpeed(pmUi -> PeersSpdCbw -> isChecked()); + StatsPluginSettings::setDrawSeedersInSwarms(pmUi -> ConnSdrInSwaCbw -> isChecked()); + StatsPluginSettings::setDrawLeechersInSwarms(pmUi -> ConnLchInSwaCbw -> isChecked()); + + StatsPluginSettings::setDownloadMeasurements(pmUi -> DownloadMrmtSbw -> value()); + StatsPluginSettings::setPeersSpeedMeasurements(pmUi -> PeersSpdMrmtSbw -> value()); + StatsPluginSettings::setUploadMeasurements(pmUi -> UploadMrmtSbw -> value()); + StatsPluginSettings::setConnectionsMeasurements(pmUi -> ConnsMrmtSbw -> value()); + StatsPluginSettings::setDHTMeasurements(pmUi -> DHTMrmtSbw -> value()); + StatsPluginSettings::setMaxSpdMode(pmUi -> MaxSpdModeCbw -> currentItem()); + + StatsPluginSettings::writeConfig(); + + emit Applied(); + + return true; +} + +void StatsPluginPrefs::createWidget (TQWidget *parent) +{ + pmUi = new StatsPluginPrefsPage(parent); +} + +void StatsPluginPrefs::updateData () +{ + pmUi -> GuiUpdatesSbw -> setValue(StatsPluginSettings::updateChartsEveryGuiUpdates()); + pmUi -> DataIvalSbw -> setValue(StatsPluginSettings::gatherDataEveryMs()); + pmUi -> PeersSpdUpdIvalSbw -> setValue(StatsPluginSettings::peersSpeedDataIval()); + + pmUi -> PeersSpdCbw -> setChecked(StatsPluginSettings::peersSpeed()); + pmUi -> ConnSdrInSwaCbw -> setChecked(StatsPluginSettings::drawSeedersInSwarms()); + pmUi -> ConnLchInSwaCbw -> setChecked(StatsPluginSettings::drawLeechersInSwarms()); + + pmUi -> DownloadMrmtSbw -> setValue(StatsPluginSettings::downloadMeasurements()); + pmUi -> PeersSpdMrmtSbw -> setValue(StatsPluginSettings::peersSpeedMeasurements()); + pmUi -> UploadMrmtSbw -> setValue(StatsPluginSettings::uploadMeasurements()); + pmUi -> ConnsMrmtSbw -> setValue(StatsPluginSettings::connectionsMeasurements()); + pmUi -> DHTMrmtSbw -> setValue(StatsPluginSettings::dHTMeasurements()); + pmUi -> MaxSpdModeCbw -> setCurrentItem(StatsPluginSettings::maxSpdMode()); +} + +void StatsPluginPrefs::deleteWidget () +{ + delete pmUi; +} + + +} //NS end + +#include "StatsPluginPrefs.moc" diff --git a/plugins/stats/StatsPluginPrefsPage.cc b/plugins/stats/StatsPluginPrefsPage.cc deleted file mode 100644 index e641349..0000000 --- a/plugins/stats/StatsPluginPrefsPage.cc +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "StatsPluginPrefsPage.h" - -namespace kt { - -StatsPluginPrefsPage::StatsPluginPrefsPage(TQWidget *p) : sprefwgt(p) -{ -} - -}// NS END diff --git a/plugins/stats/StatsPluginPrefsPage.cpp b/plugins/stats/StatsPluginPrefsPage.cpp new file mode 100644 index 0000000..e641349 --- /dev/null +++ b/plugins/stats/StatsPluginPrefsPage.cpp @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "StatsPluginPrefsPage.h" + +namespace kt { + +StatsPluginPrefsPage::StatsPluginPrefsPage(TQWidget *p) : sprefwgt(p) +{ +} + +}// NS END diff --git a/plugins/stats/StatsSpd.cc b/plugins/stats/StatsSpd.cc deleted file mode 100644 index c8cb157..0000000 --- a/plugins/stats/StatsSpd.cc +++ /dev/null @@ -1,138 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "StatsSpd.h" - -namespace kt { - -StatsSpd::StatsSpd(TQWidget *p) : StatsSpdWgt(p), - pmDownCht(new ChartDrawer(DownSpeedGbw, StatsPluginSettings::downloadMeasurements())), - pmPeersSpdCht(new ChartDrawer(PeersSpdGbw, StatsPluginSettings::peersSpeedMeasurements())), - pmUpCht(new ChartDrawer(UpSpeedGbw, StatsPluginSettings::uploadMeasurements())) -{ - - DownSpeedGbw->setColumnLayout(0, Qt::Vertical ); - DownSpeedGbw->layout()->setSpacing( 6 ); - DownSpeedGbw->layout()->setMargin( 11 ); - - pmDSpdLay = new TQVBoxLayout(DownSpeedGbw -> layout()); - - UpSpeedGbw->setColumnLayout(0, Qt::Vertical ); - UpSpeedGbw->layout()->setSpacing( 6 ); - UpSpeedGbw->layout()->setMargin( 11 ); - - pmUSpdLay = new TQVBoxLayout(UpSpeedGbw -> layout()); - - PeersSpdGbw->setColumnLayout(0, Qt::Vertical ); - PeersSpdGbw->layout()->setSpacing( 6 ); - PeersSpdGbw->layout()->setMargin( 11 ); - - pmPeersSpdLay = new TQVBoxLayout(PeersSpdGbw -> layout()); - - //----------------- - - pmUSpdLay -> addWidget(pmUpCht); - pmDSpdLay -> addWidget(pmDownCht); - pmPeersSpdLay -> addWidget(pmPeersSpdCht); - - // ---------------- - - pmUpCht -> AddValuesCnt(TQPen("#f00"), i18n("Current")); - pmDownCht -> AddValuesCnt(TQPen("#f00"), i18n("Current")); - - pmUpCht -> AddValuesCnt(TQPen("#00f"), i18n("Average")); - pmDownCht -> AddValuesCnt(TQPen("#00f"), i18n("Average")); - - pmUpCht -> AddValuesCnt(i18n("Limit"), 0); - pmDownCht -> AddValuesCnt(i18n("Limit"), 0); - -// pmUpCht -> AddValuesCnt(TQPen("#f0f"), i18n("Current torrent")); -// pmDownCht -> AddValuesCnt(TQPen("#f0f"), i18n("Current torrent")); -// - - - pmPeersSpdCht -> AddValuesCnt(TQPen("#090"), i18n("Average from leecher")); - pmPeersSpdCht -> AddValuesCnt(TQPen("#f00"), i18n("Average to leecher")); - pmPeersSpdCht -> AddValuesCnt(TQPen("#00f"), i18n("Average from seeder")); - pmPeersSpdCht -> AddValuesCnt(TQPen("magenta"), i18n("From leechers")); - pmPeersSpdCht -> AddValuesCnt(TQPen("orange"), i18n("From seeders")); - -} - -StatsSpd::~StatsSpd() -{ - delete pmUpCht; - delete pmDownCht; - delete pmPeersSpdCht; - - delete pmUSpdLay; - delete pmDSpdLay; - delete pmPeersSpdLay; - -} - -void StatsSpd::AddUpSpdVal(const size_t idx, const double val) -{ - pmUpCht -> AddValue(idx, val, false); -} - -void StatsSpd::AddDownSpdVal(const size_t idx, const double val) -{ - pmDownCht -> AddValue(idx, val , false); -} - -void StatsSpd::AddPeersSpdVal(const size_t idx, const double val) -{ - pmPeersSpdCht -> AddValue(idx, val , false); -} - -void StatsSpd::UpdateCharts() -{ - pmUpCht -> update(); - pmDownCht -> update(); - pmPeersSpdCht -> update(); -} - -void StatsSpd::ChangeDownMsmtCnt(const size_t cnt) -{ - pmDownCht -> SetXMax(cnt); -} - -void StatsSpd::ChangePrsSpdMsmtCnt(const size_t cnt) -{ - pmPeersSpdCht -> SetXMax(cnt); -} - -void StatsSpd::ChangeUpMsmtCnt(const size_t cnt) -{ - pmUpCht -> SetXMax(cnt); -} - -void StatsSpd::ChangeChartsMaxMode(const ChartDrawer::MaxMode mm) -{ - pmUpCht -> SetMaxMode(mm); - pmDownCht -> SetMaxMode(mm); - pmPeersSpdCht -> SetMaxMode(mm); -} - - -} //NS end - -#include "StatsSpd.moc" diff --git a/plugins/stats/StatsSpd.cpp b/plugins/stats/StatsSpd.cpp new file mode 100644 index 0000000..c8cb157 --- /dev/null +++ b/plugins/stats/StatsSpd.cpp @@ -0,0 +1,138 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "StatsSpd.h" + +namespace kt { + +StatsSpd::StatsSpd(TQWidget *p) : StatsSpdWgt(p), + pmDownCht(new ChartDrawer(DownSpeedGbw, StatsPluginSettings::downloadMeasurements())), + pmPeersSpdCht(new ChartDrawer(PeersSpdGbw, StatsPluginSettings::peersSpeedMeasurements())), + pmUpCht(new ChartDrawer(UpSpeedGbw, StatsPluginSettings::uploadMeasurements())) +{ + + DownSpeedGbw->setColumnLayout(0, Qt::Vertical ); + DownSpeedGbw->layout()->setSpacing( 6 ); + DownSpeedGbw->layout()->setMargin( 11 ); + + pmDSpdLay = new TQVBoxLayout(DownSpeedGbw -> layout()); + + UpSpeedGbw->setColumnLayout(0, Qt::Vertical ); + UpSpeedGbw->layout()->setSpacing( 6 ); + UpSpeedGbw->layout()->setMargin( 11 ); + + pmUSpdLay = new TQVBoxLayout(UpSpeedGbw -> layout()); + + PeersSpdGbw->setColumnLayout(0, Qt::Vertical ); + PeersSpdGbw->layout()->setSpacing( 6 ); + PeersSpdGbw->layout()->setMargin( 11 ); + + pmPeersSpdLay = new TQVBoxLayout(PeersSpdGbw -> layout()); + + //----------------- + + pmUSpdLay -> addWidget(pmUpCht); + pmDSpdLay -> addWidget(pmDownCht); + pmPeersSpdLay -> addWidget(pmPeersSpdCht); + + // ---------------- + + pmUpCht -> AddValuesCnt(TQPen("#f00"), i18n("Current")); + pmDownCht -> AddValuesCnt(TQPen("#f00"), i18n("Current")); + + pmUpCht -> AddValuesCnt(TQPen("#00f"), i18n("Average")); + pmDownCht -> AddValuesCnt(TQPen("#00f"), i18n("Average")); + + pmUpCht -> AddValuesCnt(i18n("Limit"), 0); + pmDownCht -> AddValuesCnt(i18n("Limit"), 0); + +// pmUpCht -> AddValuesCnt(TQPen("#f0f"), i18n("Current torrent")); +// pmDownCht -> AddValuesCnt(TQPen("#f0f"), i18n("Current torrent")); +// + + + pmPeersSpdCht -> AddValuesCnt(TQPen("#090"), i18n("Average from leecher")); + pmPeersSpdCht -> AddValuesCnt(TQPen("#f00"), i18n("Average to leecher")); + pmPeersSpdCht -> AddValuesCnt(TQPen("#00f"), i18n("Average from seeder")); + pmPeersSpdCht -> AddValuesCnt(TQPen("magenta"), i18n("From leechers")); + pmPeersSpdCht -> AddValuesCnt(TQPen("orange"), i18n("From seeders")); + +} + +StatsSpd::~StatsSpd() +{ + delete pmUpCht; + delete pmDownCht; + delete pmPeersSpdCht; + + delete pmUSpdLay; + delete pmDSpdLay; + delete pmPeersSpdLay; + +} + +void StatsSpd::AddUpSpdVal(const size_t idx, const double val) +{ + pmUpCht -> AddValue(idx, val, false); +} + +void StatsSpd::AddDownSpdVal(const size_t idx, const double val) +{ + pmDownCht -> AddValue(idx, val , false); +} + +void StatsSpd::AddPeersSpdVal(const size_t idx, const double val) +{ + pmPeersSpdCht -> AddValue(idx, val , false); +} + +void StatsSpd::UpdateCharts() +{ + pmUpCht -> update(); + pmDownCht -> update(); + pmPeersSpdCht -> update(); +} + +void StatsSpd::ChangeDownMsmtCnt(const size_t cnt) +{ + pmDownCht -> SetXMax(cnt); +} + +void StatsSpd::ChangePrsSpdMsmtCnt(const size_t cnt) +{ + pmPeersSpdCht -> SetXMax(cnt); +} + +void StatsSpd::ChangeUpMsmtCnt(const size_t cnt) +{ + pmUpCht -> SetXMax(cnt); +} + +void StatsSpd::ChangeChartsMaxMode(const ChartDrawer::MaxMode mm) +{ + pmUpCht -> SetMaxMode(mm); + pmDownCht -> SetMaxMode(mm); + pmPeersSpdCht -> SetMaxMode(mm); +} + + +} //NS end + +#include "StatsSpd.moc" diff --git a/plugins/stats/statsplugin.cc b/plugins/stats/statsplugin.cc deleted file mode 100644 index 2980cb3..0000000 --- a/plugins/stats/statsplugin.cc +++ /dev/null @@ -1,321 +0,0 @@ -/*************************************************************************** - * Copyright © 2007 by Krzysztof Kundzicz * - * athantor@gmail.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "statsplugin.h" - -K_EXPORT_COMPONENT_FACTORY(ktstatsplugin, KGenericFactory("ktstatsplugin")) - -namespace kt -{ - -StatsPlugin::StatsPlugin(TQObject* parent, const char* qt_name, const TQStringList& args): - Plugin(parent, qt_name, args, "Statistics", i18n("Statistics"),"Krzysztof Kundzicz", "athantor@gmail.com", i18n("Shows transfers statistics"),"ktimemon"), pmUiSpd(0), pmUiCon(0), pmPrefsUi(0), pmUpdTmr(0) -{ - mUpAvg = std::make_pair(0.0, 0.0); - mDownAvg = std::make_pair(0.0, 0.0); - mLeechAvg = std::make_pair(0, 0); - mRunningLeechAvg = std::make_pair(0, 0); - mSeedAvg = std::make_pair(0, 0); - mRunningSeedAvg = std::make_pair(0, 0); -} - -StatsPlugin::~StatsPlugin() -{ -} - -void StatsPlugin::load() -{ - - mUpdCtr = 1; - mPeerSpdUpdCtr = 1; - - pmUiSpd = new StatsSpd(dynamic_cast(parent())); - pmUiCon = new StatsCon(dynamic_cast(parent())); - pmPrefsUi = new StatsPluginPrefs(); - pmUpdTmr = new TQTimer(this); - - connect(pmUpdTmr, TQT_SIGNAL(timeout () ), this, TQT_SLOT(UpdateData())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(RestartTimer())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(TogglePeersSpdCht())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleLchInSwmDrawing())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleSdrInSwmDrawing())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMsmtsCounts())); - connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMaxMode())); - - TogglePeersSpdCht(); - ChangeMaxMode(); - - pmUpdTmr -> start(StatsPluginSettings::gatherDataEveryMs()); - - getGUI() -> addToolWidget(pmUiSpd,"ktimemon" ,i18n("Speed statistics"), GUIInterface::DOCK_BOTTOM); - getGUI() -> addToolWidget(pmUiCon,"ktimemon" ,i18n("Connection statistics"), GUIInterface::DOCK_BOTTOM); - getGUI() -> addPrefPage (pmPrefsUi); - -} - -void StatsPlugin::unload() -{ - getGUI() -> removeToolWidget(pmUiSpd); - getGUI() -> removeToolWidget(pmUiCon); - getGUI() -> removePrefPage(pmPrefsUi); - - disconnect(pmUpdTmr, TQT_SIGNAL(timeout()), this, TQT_SLOT(UpdateData())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(RestartTimer())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(TogglePeersSpdCht())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleLchInSwmDrawing())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleSdrInSwmDrawing())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMsmtsCounts())); - disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMaxMode())); - - delete pmUiSpd; - delete pmUiCon; - delete pmPrefsUi; - delete pmUpdTmr; -} - -bool StatsPlugin::versionCheck(const TQString& rVer) const -{ - return rVer == KT_VERSION_MACRO; -} - -void StatsPlugin::guiUpdate() -{ - if(mUpdCtr >= StatsPluginSettings::updateChartsEveryGuiUpdates()) - { - pmUiSpd -> UpdateCharts(); - pmUiCon -> UpdateCharts(); - mUpdCtr = 1; - - } else { - mUpdCtr++; - } -} - -void StatsPlugin::UpdateData() -{ - uint32_t lcon = 0; - uint32_t lswa = 0; - uint32_t scon = 0; - uint32_t sswa = 0; - uint32_t rlcon = 0; - uint32_t rlswa = 0; - uint32_t rscon = 0; - uint32_t rsswa = 0; - - uint32_t ld = 0; - uint32_t lu = 0; - uint32_t sd = 0; - - //--------------------------------------- - - mDownAvg.first += getCore() -> getStats() . download_speed; - mDownAvg.second++; - - mUpAvg.first += getCore() -> getStats() . upload_speed; - mUpAvg.second++; - - pmUiSpd -> AddDownSpdVal(0, getCore() -> getStats() . download_speed / 1024.0); - pmUiSpd -> AddUpSpdVal(0, getCore() -> getStats() . upload_speed / 1024.0); - - pmUiSpd -> AddDownSpdVal(1, (mDownAvg.first / mDownAvg.second) / 1024.0 ); - pmUiSpd -> AddUpSpdVal(1, (mUpAvg.first / mUpAvg.second) / 1024.0 ); - - pmUiSpd -> AddDownSpdVal(2, getCore() -> getMaxDownloadSpeed () ); - pmUiSpd -> AddUpSpdVal(2, getCore() -> getMaxUploadSpeed ()); - -// if(getGUI()-> getCurrentTorrent()) -// { -// pmUi -> AddDownSpdVal(3, getGUI()-> getCurrentTorrent() -> getStats() . download_rate / 1024.0); -// pmUi -> AddUpSpdVal(3, getGUI()-> getCurrentTorrent() -> getStats() . upload_rate / 1024.0); -// } else { -// pmUi -> AddDownSpdVal(3, 0.0); -// pmUi -> AddUpSpdVal(3, 0.0); -// } - - // ------ - - bt::QueueManager::iterator tor = getCore() -> getQueueManager () -> begin(); - - while(tor != getCore() -> getQueueManager () -> end()) - { - lcon += (*tor) -> getStats().leechers_connected_to; - lswa += (*tor) -> getStats().leechers_total; - scon += (*tor) -> getStats().seeders_connected_to; - sswa += (*tor) -> getStats().seeders_total; - - mLeechAvg.first += lcon; - mLeechAvg.second += lswa; - mSeedAvg.first += scon; - mSeedAvg.second += sswa; - - if(StatsPluginSettings::peersSpeed() && ( mPeerSpdUpdCtr >= StatsPluginSettings::peersSpeedDataIval() ) ) - { - bt::TorrentControl * tc = dynamic_cast( *tor ); - const bt::PeerManager * pm = tc->getPeerMgr(); - if(tc && pm) - { - for(bt::PeerManager::CItr it = pm -> beginPeerList(); it != pm -> endPeerList (); ++it) - { - if(it && (*it) ) - { - if(!(*it) -> isSeeder()) - { - ld += (*it) -> getDownloadRate(); - lu += (*it) -> getUploadRate(); - } else { - sd += (*it) -> getDownloadRate(); - } - } - } - } - } - - - if( (*tor) -> getStats().started) - { - - rlcon += (*tor) -> getStats().leechers_connected_to; - rlswa += (*tor) -> getStats().leechers_total; - rscon += (*tor) -> getStats().seeders_connected_to; - rsswa += (*tor) -> getStats().seeders_total; - - mRunningLeechAvg.first += rlcon; - mRunningLeechAvg.second += rlswa; - mRunningSeedAvg.first += rscon; - mRunningSeedAvg.second += rsswa; - } - - tor++; - } - - // ------ - - if(StatsPluginSettings::peersSpeed() ) - { - if( mPeerSpdUpdCtr >= StatsPluginSettings::peersSpeedDataIval() ) - { - pmUiSpd -> AddPeersSpdVal(0, (ld / (lcon * 1.0)) / 1024.0); - pmUiSpd -> AddPeersSpdVal(1, (lu / (lcon * 1.0)) / 1024.0); - pmUiSpd -> AddPeersSpdVal(2, (sd / (lswa * 1.0)) / 1024.0); - pmUiSpd -> AddPeersSpdVal(3, ld / 1024.0); - pmUiSpd -> AddPeersSpdVal(4, sd / 1024.0); - - mPeerSpdUpdCtr = 1; - } else { - mPeerSpdUpdCtr++; - } - } - - pmUiCon -> AddPeersConVal(0, lcon); - if(StatsPluginSettings::drawLeechersInSwarms()) - { - pmUiCon -> AddPeersConVal(1, lswa); - } - pmUiCon -> AddPeersConVal(2, scon); - if(StatsPluginSettings::drawSeedersInSwarms()) - { - pmUiCon -> AddPeersConVal(3, sswa); - } - - double cnt = getCore() -> getQueueManager() -> count() * 1.0; - double rcnt = getCore() -> getQueueManager() -> getNumRunning() * 1.0; - - pmUiCon -> AddPeersConVal(4, lcon / cnt ); - pmUiCon -> AddPeersConVal(5, scon / cnt ); - pmUiCon -> AddPeersConVal(6, lcon / rcnt); - pmUiCon -> AddPeersConVal(7, scon / rcnt ); - - // ----- - - if( bt::Globals::instance().getDHT().isRunning() ) - { - pmUiCon -> AddDHTVal(0, bt::Globals::instance().getDHT(). getStats().num_peers); - pmUiCon -> AddDHTVal(1, bt::Globals::instance().getDHT(). getStats().num_tasks); - } -} - -void StatsPlugin::RestartTimer() -{ - if( (!pmUpdTmr) || (!pmUpdTmr -> isActive())) - { - return; - } - - pmUpdTmr -> stop(); - pmUpdTmr -> start(StatsPluginSettings::gatherDataEveryMs()); -} - -void StatsPlugin::TogglePeersSpdCht() -{ - if(StatsPluginSettings::peersSpeed()) - { - if(pmUiSpd -> PeersSpdGbw -> isHidden()) - { - pmUiSpd -> PeersSpdGbw -> setHidden(false); - } - } else { - if(!pmUiSpd -> PeersSpdGbw -> isHidden()) - { - pmUiSpd -> PeersSpdGbw -> setHidden(true); - } - } -} - -void StatsPlugin::ToggleLchInSwmDrawing() -{ - if(!StatsPluginSettings::drawLeechersInSwarms()) - { - pmUiCon -> ZeroPeersConn(1); - } -} - -void StatsPlugin::ToggleSdrInSwmDrawing() -{ - if(!StatsPluginSettings::drawSeedersInSwarms()) - { - pmUiCon -> ZeroPeersConn(3); - } -} - -void StatsPlugin::ChangeMsmtsCounts() -{ - pmUiSpd -> ChangeDownMsmtCnt(StatsPluginSettings::downloadMeasurements()); - pmUiSpd -> ChangePrsSpdMsmtCnt(StatsPluginSettings::peersSpeedMeasurements()); - pmUiSpd -> ChangeUpMsmtCnt(StatsPluginSettings::uploadMeasurements()); - pmUiCon -> ChangeConnMsmtCnt(StatsPluginSettings::connectionsMeasurements()); - pmUiCon -> ChangeDHTMsmtCnt(StatsPluginSettings::dHTMeasurements()); -} - -void StatsPlugin::ChangeMaxMode() -{ - if(StatsPluginSettings::maxSpdMode() == 0) - { - pmUiSpd -> ChangeChartsMaxMode(ChartDrawer::MaxModeTop); - pmUiCon -> ChangeChartsMaxMode(ChartDrawer::MaxModeTop); - - } else if (StatsPluginSettings::maxSpdMode() == 1) { - pmUiSpd -> ChangeChartsMaxMode(ChartDrawer::MaxModeExact); - pmUiCon -> ChangeChartsMaxMode(ChartDrawer::MaxModeExact); - } -} - -} // NS end - -#include "statsplugin.moc" diff --git a/plugins/stats/statsplugin.cpp b/plugins/stats/statsplugin.cpp new file mode 100644 index 0000000..2980cb3 --- /dev/null +++ b/plugins/stats/statsplugin.cpp @@ -0,0 +1,321 @@ +/*************************************************************************** + * Copyright © 2007 by Krzysztof Kundzicz * + * athantor@gmail.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "statsplugin.h" + +K_EXPORT_COMPONENT_FACTORY(ktstatsplugin, KGenericFactory("ktstatsplugin")) + +namespace kt +{ + +StatsPlugin::StatsPlugin(TQObject* parent, const char* qt_name, const TQStringList& args): + Plugin(parent, qt_name, args, "Statistics", i18n("Statistics"),"Krzysztof Kundzicz", "athantor@gmail.com", i18n("Shows transfers statistics"),"ktimemon"), pmUiSpd(0), pmUiCon(0), pmPrefsUi(0), pmUpdTmr(0) +{ + mUpAvg = std::make_pair(0.0, 0.0); + mDownAvg = std::make_pair(0.0, 0.0); + mLeechAvg = std::make_pair(0, 0); + mRunningLeechAvg = std::make_pair(0, 0); + mSeedAvg = std::make_pair(0, 0); + mRunningSeedAvg = std::make_pair(0, 0); +} + +StatsPlugin::~StatsPlugin() +{ +} + +void StatsPlugin::load() +{ + + mUpdCtr = 1; + mPeerSpdUpdCtr = 1; + + pmUiSpd = new StatsSpd(dynamic_cast(parent())); + pmUiCon = new StatsCon(dynamic_cast(parent())); + pmPrefsUi = new StatsPluginPrefs(); + pmUpdTmr = new TQTimer(this); + + connect(pmUpdTmr, TQT_SIGNAL(timeout () ), this, TQT_SLOT(UpdateData())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(RestartTimer())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(TogglePeersSpdCht())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleLchInSwmDrawing())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleSdrInSwmDrawing())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMsmtsCounts())); + connect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMaxMode())); + + TogglePeersSpdCht(); + ChangeMaxMode(); + + pmUpdTmr -> start(StatsPluginSettings::gatherDataEveryMs()); + + getGUI() -> addToolWidget(pmUiSpd,"ktimemon" ,i18n("Speed statistics"), GUIInterface::DOCK_BOTTOM); + getGUI() -> addToolWidget(pmUiCon,"ktimemon" ,i18n("Connection statistics"), GUIInterface::DOCK_BOTTOM); + getGUI() -> addPrefPage (pmPrefsUi); + +} + +void StatsPlugin::unload() +{ + getGUI() -> removeToolWidget(pmUiSpd); + getGUI() -> removeToolWidget(pmUiCon); + getGUI() -> removePrefPage(pmPrefsUi); + + disconnect(pmUpdTmr, TQT_SIGNAL(timeout()), this, TQT_SLOT(UpdateData())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(RestartTimer())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(TogglePeersSpdCht())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleLchInSwmDrawing())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ToggleSdrInSwmDrawing())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMsmtsCounts())); + disconnect(pmPrefsUi, TQT_SIGNAL(Applied()), this, TQT_SLOT(ChangeMaxMode())); + + delete pmUiSpd; + delete pmUiCon; + delete pmPrefsUi; + delete pmUpdTmr; +} + +bool StatsPlugin::versionCheck(const TQString& rVer) const +{ + return rVer == KT_VERSION_MACRO; +} + +void StatsPlugin::guiUpdate() +{ + if(mUpdCtr >= StatsPluginSettings::updateChartsEveryGuiUpdates()) + { + pmUiSpd -> UpdateCharts(); + pmUiCon -> UpdateCharts(); + mUpdCtr = 1; + + } else { + mUpdCtr++; + } +} + +void StatsPlugin::UpdateData() +{ + uint32_t lcon = 0; + uint32_t lswa = 0; + uint32_t scon = 0; + uint32_t sswa = 0; + uint32_t rlcon = 0; + uint32_t rlswa = 0; + uint32_t rscon = 0; + uint32_t rsswa = 0; + + uint32_t ld = 0; + uint32_t lu = 0; + uint32_t sd = 0; + + //--------------------------------------- + + mDownAvg.first += getCore() -> getStats() . download_speed; + mDownAvg.second++; + + mUpAvg.first += getCore() -> getStats() . upload_speed; + mUpAvg.second++; + + pmUiSpd -> AddDownSpdVal(0, getCore() -> getStats() . download_speed / 1024.0); + pmUiSpd -> AddUpSpdVal(0, getCore() -> getStats() . upload_speed / 1024.0); + + pmUiSpd -> AddDownSpdVal(1, (mDownAvg.first / mDownAvg.second) / 1024.0 ); + pmUiSpd -> AddUpSpdVal(1, (mUpAvg.first / mUpAvg.second) / 1024.0 ); + + pmUiSpd -> AddDownSpdVal(2, getCore() -> getMaxDownloadSpeed () ); + pmUiSpd -> AddUpSpdVal(2, getCore() -> getMaxUploadSpeed ()); + +// if(getGUI()-> getCurrentTorrent()) +// { +// pmUi -> AddDownSpdVal(3, getGUI()-> getCurrentTorrent() -> getStats() . download_rate / 1024.0); +// pmUi -> AddUpSpdVal(3, getGUI()-> getCurrentTorrent() -> getStats() . upload_rate / 1024.0); +// } else { +// pmUi -> AddDownSpdVal(3, 0.0); +// pmUi -> AddUpSpdVal(3, 0.0); +// } + + // ------ + + bt::QueueManager::iterator tor = getCore() -> getQueueManager () -> begin(); + + while(tor != getCore() -> getQueueManager () -> end()) + { + lcon += (*tor) -> getStats().leechers_connected_to; + lswa += (*tor) -> getStats().leechers_total; + scon += (*tor) -> getStats().seeders_connected_to; + sswa += (*tor) -> getStats().seeders_total; + + mLeechAvg.first += lcon; + mLeechAvg.second += lswa; + mSeedAvg.first += scon; + mSeedAvg.second += sswa; + + if(StatsPluginSettings::peersSpeed() && ( mPeerSpdUpdCtr >= StatsPluginSettings::peersSpeedDataIval() ) ) + { + bt::TorrentControl * tc = dynamic_cast( *tor ); + const bt::PeerManager * pm = tc->getPeerMgr(); + if(tc && pm) + { + for(bt::PeerManager::CItr it = pm -> beginPeerList(); it != pm -> endPeerList (); ++it) + { + if(it && (*it) ) + { + if(!(*it) -> isSeeder()) + { + ld += (*it) -> getDownloadRate(); + lu += (*it) -> getUploadRate(); + } else { + sd += (*it) -> getDownloadRate(); + } + } + } + } + } + + + if( (*tor) -> getStats().started) + { + + rlcon += (*tor) -> getStats().leechers_connected_to; + rlswa += (*tor) -> getStats().leechers_total; + rscon += (*tor) -> getStats().seeders_connected_to; + rsswa += (*tor) -> getStats().seeders_total; + + mRunningLeechAvg.first += rlcon; + mRunningLeechAvg.second += rlswa; + mRunningSeedAvg.first += rscon; + mRunningSeedAvg.second += rsswa; + } + + tor++; + } + + // ------ + + if(StatsPluginSettings::peersSpeed() ) + { + if( mPeerSpdUpdCtr >= StatsPluginSettings::peersSpeedDataIval() ) + { + pmUiSpd -> AddPeersSpdVal(0, (ld / (lcon * 1.0)) / 1024.0); + pmUiSpd -> AddPeersSpdVal(1, (lu / (lcon * 1.0)) / 1024.0); + pmUiSpd -> AddPeersSpdVal(2, (sd / (lswa * 1.0)) / 1024.0); + pmUiSpd -> AddPeersSpdVal(3, ld / 1024.0); + pmUiSpd -> AddPeersSpdVal(4, sd / 1024.0); + + mPeerSpdUpdCtr = 1; + } else { + mPeerSpdUpdCtr++; + } + } + + pmUiCon -> AddPeersConVal(0, lcon); + if(StatsPluginSettings::drawLeechersInSwarms()) + { + pmUiCon -> AddPeersConVal(1, lswa); + } + pmUiCon -> AddPeersConVal(2, scon); + if(StatsPluginSettings::drawSeedersInSwarms()) + { + pmUiCon -> AddPeersConVal(3, sswa); + } + + double cnt = getCore() -> getQueueManager() -> count() * 1.0; + double rcnt = getCore() -> getQueueManager() -> getNumRunning() * 1.0; + + pmUiCon -> AddPeersConVal(4, lcon / cnt ); + pmUiCon -> AddPeersConVal(5, scon / cnt ); + pmUiCon -> AddPeersConVal(6, lcon / rcnt); + pmUiCon -> AddPeersConVal(7, scon / rcnt ); + + // ----- + + if( bt::Globals::instance().getDHT().isRunning() ) + { + pmUiCon -> AddDHTVal(0, bt::Globals::instance().getDHT(). getStats().num_peers); + pmUiCon -> AddDHTVal(1, bt::Globals::instance().getDHT(). getStats().num_tasks); + } +} + +void StatsPlugin::RestartTimer() +{ + if( (!pmUpdTmr) || (!pmUpdTmr -> isActive())) + { + return; + } + + pmUpdTmr -> stop(); + pmUpdTmr -> start(StatsPluginSettings::gatherDataEveryMs()); +} + +void StatsPlugin::TogglePeersSpdCht() +{ + if(StatsPluginSettings::peersSpeed()) + { + if(pmUiSpd -> PeersSpdGbw -> isHidden()) + { + pmUiSpd -> PeersSpdGbw -> setHidden(false); + } + } else { + if(!pmUiSpd -> PeersSpdGbw -> isHidden()) + { + pmUiSpd -> PeersSpdGbw -> setHidden(true); + } + } +} + +void StatsPlugin::ToggleLchInSwmDrawing() +{ + if(!StatsPluginSettings::drawLeechersInSwarms()) + { + pmUiCon -> ZeroPeersConn(1); + } +} + +void StatsPlugin::ToggleSdrInSwmDrawing() +{ + if(!StatsPluginSettings::drawSeedersInSwarms()) + { + pmUiCon -> ZeroPeersConn(3); + } +} + +void StatsPlugin::ChangeMsmtsCounts() +{ + pmUiSpd -> ChangeDownMsmtCnt(StatsPluginSettings::downloadMeasurements()); + pmUiSpd -> ChangePrsSpdMsmtCnt(StatsPluginSettings::peersSpeedMeasurements()); + pmUiSpd -> ChangeUpMsmtCnt(StatsPluginSettings::uploadMeasurements()); + pmUiCon -> ChangeConnMsmtCnt(StatsPluginSettings::connectionsMeasurements()); + pmUiCon -> ChangeDHTMsmtCnt(StatsPluginSettings::dHTMeasurements()); +} + +void StatsPlugin::ChangeMaxMode() +{ + if(StatsPluginSettings::maxSpdMode() == 0) + { + pmUiSpd -> ChangeChartsMaxMode(ChartDrawer::MaxModeTop); + pmUiCon -> ChangeChartsMaxMode(ChartDrawer::MaxModeTop); + + } else if (StatsPluginSettings::maxSpdMode() == 1) { + pmUiSpd -> ChangeChartsMaxMode(ChartDrawer::MaxModeExact); + pmUiCon -> ChangeChartsMaxMode(ChartDrawer::MaxModeExact); + } +} + +} // NS end + +#include "statsplugin.moc" -- cgit v1.2.1