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

* support extra info

* support undo/redo

* fix undo/redo

* cleanup

* fix regexp

* refactor dbcmanager

* replace text in headerview

* fix binary::refresh

* cleanup

* use QRegularExpression

* add desc validation

* edit val description in table

* cleanup
old-commit-hash: ac0dbf74bc835faa46beab4bbb948c95597e4e67
This commit is contained in:
Dean Lee
2023-02-18 11:31:54 +08:00
committed by GitHub
parent 5d594850cf
commit 972e91463c
24 changed files with 376 additions and 166 deletions
+10 -11
View File
@@ -12,7 +12,6 @@
#include "tools/cabana/commands.h"
#include "tools/cabana/signaledit.h"
#include "tools/cabana/streams/abstractstream.h"
// BinaryView
@@ -170,7 +169,7 @@ void BinaryView::highlightPosition(const QPoint &pos) {
auto item = (BinaryViewModel::Item *)index.internalPointer();
const Signal *sig = item->sigs.isEmpty() ? nullptr : item->sigs.back();
highlight(sig);
QToolTip::showText(pos, sig ? sig->name.c_str() : "", this, rect());
QToolTip::showText(pos, sig ? sig->name : "", this, rect());
}
}
@@ -246,22 +245,22 @@ std::tuple<int, int, bool> BinaryView::getSelection(QModelIndex index) {
void BinaryViewModel::refresh() {
beginResetModel();
items.clear();
if ((dbc_msg = dbc()->msg(*msg_id))) {
if (auto dbc_msg = dbc()->msg(*msg_id)) {
row_count = dbc_msg->size;
items.resize(row_count * column_count);
for (auto sig : dbc_msg->getSignals()) {
auto [start, end] = getSignalRange(sig);
for (auto &sig : dbc_msg->sigs) {
auto [start, end] = getSignalRange(&sig);
for (int j = start; j <= end; ++j) {
int bit_index = sig->is_little_endian ? bigEndianBitIndex(j) : j;
int bit_index = sig.is_little_endian ? bigEndianBitIndex(j) : j;
int idx = column_count * (bit_index / 8) + bit_index % 8;
if (idx >= items.size()) {
qWarning() << "signal " << sig->name.c_str() << "out of bounds.start_bit:" << sig->start_bit << "size:" << sig->size;
qWarning() << "signal " << sig.name << "out of bounds.start_bit:" << sig.start_bit << "size:" << sig.size;
break;
}
if (j == start) sig->is_little_endian ? items[idx].is_lsb = true : items[idx].is_msb = true;
if (j == end) sig->is_little_endian ? items[idx].is_msb = true : items[idx].is_lsb = true;
items[idx].bg_color = getColor(sig);
items[idx].sigs.push_back(sig);
if (j == start) sig.is_little_endian ? items[idx].is_lsb = true : items[idx].is_msb = true;
if (j == end) sig.is_little_endian ? items[idx].is_msb = true : items[idx].is_lsb = true;
items[idx].bg_color = getColor(&sig);
items[idx].sigs.push_back(&sig);
}
}
} else {