diff --git a/src/gui/properties/peerlistdelegate.h b/src/gui/properties/peerlistdelegate.h index 82c2d70c3..fe2ec9b3b 100644 --- a/src/gui/properties/peerlistdelegate.h +++ b/src/gui/properties/peerlistdelegate.h @@ -67,14 +67,16 @@ public: ~PeerListDelegate() {} - void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const + void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override { painter->save(); + const bool hideValues = Preferences::instance()->getHideZeroValues(); QStyleOptionViewItem opt = QItemDelegate::setOptions(index, option); + QItemDelegate::drawBackground(painter, opt, index); + switch(index.column()) { case PORT: { - QItemDelegate::drawBackground(painter, opt, index); opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, option.rect, index.data().toString()); } @@ -84,23 +86,21 @@ public: 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(size)); } break; case DOWN_SPEED: case UP_SPEED:{ - QItemDelegate::drawBackground(painter, opt, index); qreal speed = index.data().toDouble(); + if (speed == 0.0) + break; opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; - if (speed > 0.0) - QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); + QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::Misc::friendlyUnit(speed, true)); } break; case PROGRESS: case RELEVANCE: { - QItemDelegate::drawBackground(painter, opt, index); qreal progress = index.data().toDouble(); opt.displayAlignment = Qt::AlignRight | Qt::AlignVCenter; QItemDelegate::drawDisplay(painter, opt, opt.rect, Utils::String::fromDouble(progress*100.0, 1)+"%"); @@ -109,15 +109,15 @@ public: default: QItemDelegate::paint(painter, option, index); } + painter->restore(); } - QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const + QWidget* createEditor(QWidget*, const QStyleOptionViewItem &, const QModelIndex &) const override { // No editor here - return 0; + return nullptr; } - }; #endif // PEERLISTDELEGATE_H