From a90100a0b745a1447ebd7381c0d370b21b067bde Mon Sep 17 00:00:00 2001 From: thalieht Date: Wed, 22 Jun 2016 20:53:14 +0300 Subject: [PATCH] PeerList: allow to hide zero values for the "uploaded" and "downloaded" columns --- src/gui/properties/peerlistdelegate.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/properties/peerlistdelegate.h b/src/gui/properties/peerlistdelegate.h index defab38c2..959d6fe7b 100644 --- a/src/gui/properties/peerlistdelegate.h +++ b/src/gui/properties/peerlistdelegate.h @@ -35,6 +35,7 @@ #include #include "base/utils/misc.h" #include "base/utils/string.h" +#include "base/preferences.h" class PeerListDelegate: public QItemDelegate { Q_OBJECT @@ -50,6 +51,7 @@ public: void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { painter->save(); + const bool hideValues = Preferences::instance()->getHideZeroValues(); QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option); switch(index.column()) { case PORT: @@ -58,10 +60,14 @@ public: QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString()); break; case TOT_DOWN: - case TOT_UP: + case TOT_UP: { + qlonglong size = index.data().toLongLong(); + if (hideValues && (size <= 0)) + break; QItemDelegate::drawBackground(painter, opt, index); opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(index.data().toLongLong())); + QItemDelegate::drawDisplay(painter, opt, option.rect, Utils::Misc::friendlyUnit(size)); + } break; case DOWN_SPEED: case UP_SPEED:{