Browse Source

Fix downloaded/uploaded columns were not highlighted properly when selected.

Refactor
adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
2b2b3a4fe7
  1. 18
      src/gui/properties/peerlistdelegate.h

18
src/gui/properties/peerlistdelegate.h

@ -67,14 +67,16 @@ public: @@ -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: @@ -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));
}
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: @@ -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

Loading…
Cancel
Save