Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cabana: add support for load&save extra dbc info #27203

Merged
merged 27 commits into from
Feb 18, 2023
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge master
deanlee committed Feb 17, 2023
commit ac538dc5a492d7550d39b192a4d1b4724676c6f9
25 changes: 15 additions & 10 deletions tools/cabana/util.cc
Original file line number Diff line number Diff line change
@@ -73,27 +73,32 @@ MessageBytesDelegate::MessageBytesDelegate(QObject *parent) : QStyledItemDelegat
}

void MessageBytesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
auto byte_list = index.data(Qt::DisplayRole).toString().split(" ");
QStyleOptionViewItemV4 opt = option;
initStyleOption(&opt, index);

auto byte_list = opt.text.split(" ");
if (byte_list.size() <= 1) {
QStyledItemDelegate::paint(painter, option, index);
return;
}

auto role = option.state & QStyle::State_Selected ? QPalette::HighlightedText: QPalette::Text;
painter->setPen(option.palette.color(role));
auto color_role = option.state & QStyle::State_Selected ? QPalette::HighlightedText: QPalette::Text;
painter->setPen(option.palette.color(color_role));
painter->setFont(fixed_font);
int space = painter->boundingRect(option.rect, option.displayAlignment, " ").width();
QRect pos = painter->boundingRect(option.rect, option.displayAlignment, "00");
pos.moveLeft(pos.x() + space);
QRect space = painter->boundingRect(opt.rect, opt.displayAlignment, " ");
QRect pos = painter->boundingRect(opt.rect, opt.displayAlignment, "00");
pos.moveLeft(pos.x() + space.width());

int m = space.width() / 2;
const QMargins margins(m, m, m, m);

int m = space / 2;
auto colors = index.data(Qt::UserRole).value<QVector<QColor>>();
for (int i = 0; i < byte_list.size(); ++i) {
if (i < colors.size()) {
painter->fillRect(pos.adjusted(-m, -m, m, m), colors[i]);
painter->fillRect(pos.marginsAdded(margins), colors[i]);
}
painter->drawText(pos, option.displayAlignment, byte_list[i]);
pos.moveLeft(pos.right() + space);
painter->drawText(pos, opt.displayAlignment, byte_list[i]);
pos.moveLeft(pos.right() + space.width());
}
}

You are viewing a condensed version of this merge commit. You can view the full changes here.