|
|
@ -599,29 +599,31 @@ void SignalView::updateState(const QHash<MessageId, CanData> *msgs) { |
|
|
|
max_value_width = std::max(max_value_width, fontMetrics().width(item->sig_val)); |
|
|
|
max_value_width = std::max(max_value_width, fontMetrics().width(item->sig_val)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// update visible sparkline
|
|
|
|
|
|
|
|
QSize size(tree->columnWidth(1) - delegate->button_size.width(), delegate->button_size.height()); |
|
|
|
|
|
|
|
int min_max_width = std::min(size.width() - 10, QFontMetrics(delegate->minmax_font).width("-000.00") + 5); |
|
|
|
|
|
|
|
int value_width = std::min<int>(max_value_width, size.width() * 0.35); |
|
|
|
|
|
|
|
size -= {value_width + min_max_width, style()->pixelMetric(QStyle::PM_FocusFrameVMargin) * 2}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndex top = tree->indexAt(QPoint(0, 0)); |
|
|
|
QModelIndex top = tree->indexAt(QPoint(0, 0)); |
|
|
|
QModelIndex bottom = tree->indexAt(tree->viewport()->rect().bottomLeft()); |
|
|
|
if (top.isValid()) { |
|
|
|
int start_row = top.parent().isValid() ? top.parent().row() + 1 : top.row(); |
|
|
|
// update visible sparkline
|
|
|
|
int end_row = model->rowCount() - 1; |
|
|
|
int first_visible_row = top.parent().isValid() ? top.parent().row() + 1 : top.row(); |
|
|
|
if (bottom.isValid()) { |
|
|
|
int last_visible_row = model->rowCount() - 1; |
|
|
|
end_row = bottom.parent().isValid() ? bottom.parent().row() : bottom.row(); |
|
|
|
QModelIndex bottom = tree->indexAt(tree->viewport()->rect().bottomLeft()); |
|
|
|
} |
|
|
|
if (bottom.isValid()) { |
|
|
|
QFutureSynchronizer<void> synchronizer; |
|
|
|
last_visible_row = bottom.parent().isValid() ? bottom.parent().row() : bottom.row(); |
|
|
|
for (int i = start_row; i <= end_row; ++i) { |
|
|
|
} |
|
|
|
auto item = model->getItem(model->index(i, 1)); |
|
|
|
|
|
|
|
auto &s = item->sparkline; |
|
|
|
QSize size(tree->columnWidth(1) - delegate->button_size.width(), delegate->button_size.height()); |
|
|
|
if (s.last_ts != last_msg.ts || s.size() != size || s.time_range != settings.sparkline_range) { |
|
|
|
int min_max_width = std::min(size.width() - 10, QFontMetrics(delegate->minmax_font).width("-000.00") + 5); |
|
|
|
synchronizer.addFuture(QtConcurrent::run( |
|
|
|
int value_width = std::min<int>(max_value_width, size.width() * 0.35); |
|
|
|
&s, &Sparkline::update, model->msg_id, item->sig, last_msg.ts, settings.sparkline_range, size)); |
|
|
|
size -= {value_width + min_max_width, style()->pixelMetric(QStyle::PM_FocusFrameVMargin) * 2}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFutureSynchronizer<void> synchronizer; |
|
|
|
|
|
|
|
for (int i = first_visible_row; i <= last_visible_row; ++i) { |
|
|
|
|
|
|
|
auto item = model->getItem(model->index(i, 1)); |
|
|
|
|
|
|
|
auto &s = item->sparkline; |
|
|
|
|
|
|
|
if (s.last_ts != last_msg.ts || s.size() != size || s.time_range != settings.sparkline_range) { |
|
|
|
|
|
|
|
synchronizer.addFuture(QtConcurrent::run( |
|
|
|
|
|
|
|
&s, &Sparkline::update, model->msg_id, item->sig, last_msg.ts, settings.sparkline_range, size)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
synchronizer.waitForFinished(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < model->rowCount(); ++i) { |
|
|
|
for (int i = 0; i < model->rowCount(); ++i) { |
|
|
|
emit model->dataChanged(model->index(i, 1), model->index(i, 1), {Qt::DisplayRole}); |
|
|
|
emit model->dataChanged(model->index(i, 1), model->index(i, 1), {Qt::DisplayRole}); |
|
|
|