mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-28 00:43:52 +08:00
cabana: fill rows with Qt::BDiagPattern if messag size is incorrect (#27750)
This commit is contained in:
@@ -273,6 +273,10 @@ void BinaryViewModel::refresh() {
|
||||
row_count = can->lastMessage(msg_id).dat.size();
|
||||
items.resize(row_count * column_count);
|
||||
}
|
||||
int valid_rows = std::min(can->lastMessage(msg_id).dat.size(), row_count);
|
||||
for (int i = 0; i < valid_rows * column_count; ++i) {
|
||||
items[i].valid = true;
|
||||
}
|
||||
endResetModel();
|
||||
updateState();
|
||||
}
|
||||
@@ -307,9 +311,6 @@ void BinaryViewModel::updateState() {
|
||||
items[i * column_count + 8].val = toHex(binary[i]);
|
||||
items[i * column_count + 8].bg_color = last_msg.colors[i];
|
||||
}
|
||||
for (int i = binary.size() * column_count; i < items.size(); ++i) {
|
||||
items[i].val = "-";
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.size(); ++i) {
|
||||
if (i >= prev_items.size() || prev_items[i].val != items[i].val || prev_items[i].bg_color != items[i].bg_color) {
|
||||
@@ -376,6 +377,9 @@ void BinaryItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
}
|
||||
}
|
||||
|
||||
if (!item->valid) {
|
||||
painter->fillRect(option.rect, QBrush(Qt::darkGray, Qt::BDiagPattern));
|
||||
}
|
||||
painter->drawText(option.rect, Qt::AlignCenter, item->val);
|
||||
if (item->is_msb || item->is_lsb) {
|
||||
painter->setFont(small_font);
|
||||
|
||||
@@ -42,8 +42,9 @@ public:
|
||||
QColor bg_color = QColor(102, 86, 169, 0);
|
||||
bool is_msb = false;
|
||||
bool is_lsb = false;
|
||||
QString val = "-";
|
||||
QString val;
|
||||
QList<const cabana::Signal *> sigs;
|
||||
bool valid = false;
|
||||
};
|
||||
std::vector<Item> items;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user