|
|
@ -1,20 +1,25 @@ |
|
|
|
#include "tools/cabana/historylog.h" |
|
|
|
#include "tools/cabana/historylog.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <QFontDatabase> |
|
|
|
#include <QHeaderView> |
|
|
|
#include <QHeaderView> |
|
|
|
#include <QVBoxLayout> |
|
|
|
#include <QVBoxLayout> |
|
|
|
|
|
|
|
|
|
|
|
QVariant HistoryLogModel::data(const QModelIndex &index, int role) const { |
|
|
|
QVariant HistoryLogModel::data(const QModelIndex &index, int role) const { |
|
|
|
|
|
|
|
auto msg = dbc()->msg(msg_id); |
|
|
|
if (role == Qt::DisplayRole) { |
|
|
|
if (role == Qt::DisplayRole) { |
|
|
|
const auto &can_msgs = can->messages(msg_id); |
|
|
|
const auto &can_msgs = can->messages(msg_id); |
|
|
|
if (index.row() < can_msgs.size()) { |
|
|
|
if (index.row() < can_msgs.size()) { |
|
|
|
const auto &can_data = can_msgs[index.row()]; |
|
|
|
const auto &can_data = can_msgs[index.row()]; |
|
|
|
auto msg = dbc()->msg(msg_id); |
|
|
|
|
|
|
|
if (msg && index.column() < msg->sigs.size()) { |
|
|
|
if (msg && index.column() < msg->sigs.size()) { |
|
|
|
return get_raw_value((uint8_t *)can_data.dat.begin(), can_data.dat.size(), msg->sigs[index.column()]); |
|
|
|
return get_raw_value((uint8_t *)can_data.dat.begin(), can_data.dat.size(), msg->sigs[index.column()]); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return toHex(can_data.dat); |
|
|
|
return toHex(can_data.dat); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (role == Qt::FontRole) { |
|
|
|
|
|
|
|
if (index.column() == 0 && !(msg && msg->sigs.size() > 0)) { |
|
|
|
|
|
|
|
return QFontDatabase::systemFont(QFontDatabase::FixedFont); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return {}; |
|
|
|
return {}; |
|
|
|
} |
|
|
|
} |
|
|
|