Browse Source

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

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

20
src/gui/properties/peerlistdelegate.h

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

Loading…
Cancel
Save