Skip to content

Commit 39630be

Browse files
committed
right align the signal values
1 parent dc4ebeb commit 39630be

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/cabana/signaledit.cc

+9
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,15 @@ void SignalItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
338338
text = painter->fontMetrics().elidedText(text, Qt::ElideRight, text_rect.width());
339339
painter->drawText(text_rect, option.displayAlignment, text);
340340
painter->restore();
341+
} else if (index.column() == 1 && item && item->type == SignalModel::Item::Sig) {
342+
// draw signal value
343+
if (option.state & QStyle::State_Selected) {
344+
painter->fillRect(option.rect, option.palette.highlight());
345+
}
346+
painter->setPen((option.state & QStyle::State_Selected ? option.palette.highlightedText() : option.palette.text()).color());
347+
QRect rc = option.rect.adjusted(0, 0, -70, 0);
348+
auto text = painter->fontMetrics().elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, rc.width());
349+
painter->drawText(rc, Qt::AlignRight | Qt::AlignVCenter, text);
341350
} else {
342351
QStyledItemDelegate::paint(painter, option, index);
343352
}

0 commit comments

Comments
 (0)