cabana: right align signal values & fixed text overflow (#27444)

right align the signal values
old-commit-hash: 608ac253df
beeps
Dean Lee 2 years ago committed by GitHub
parent b7b61c1faa
commit 3e89cf5db8
  1. 9
      tools/cabana/signaledit.cc

@ -338,6 +338,15 @@ void SignalItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
text = painter->fontMetrics().elidedText(text, Qt::ElideRight, text_rect.width()); text = painter->fontMetrics().elidedText(text, Qt::ElideRight, text_rect.width());
painter->drawText(text_rect, option.displayAlignment, text); painter->drawText(text_rect, option.displayAlignment, text);
painter->restore(); painter->restore();
} else if (index.column() == 1 && item && item->type == SignalModel::Item::Sig) {
// draw signal value
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight());
}
painter->setPen((option.state & QStyle::State_Selected ? option.palette.highlightedText() : option.palette.text()).color());
QRect rc = option.rect.adjusted(0, 0, -70, 0);
auto text = painter->fontMetrics().elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, rc.width());
painter->drawText(rc, Qt::AlignRight | Qt::AlignVCenter, text);
} else { } else {
QStyledItemDelegate::paint(painter, option, index); QStyledItemDelegate::paint(painter, option, index);
} }

Loading…
Cancel
Save