mirror of https://github.com/commaai/openpilot.git
Cabana: double click on logs cell to open the chart (#26833)
old-commit-hash: ab797588f8
This commit is contained in:
parent
7f783e79d5
commit
d37a669449
|
@ -145,8 +145,9 @@ ChartView *ChartsWidget::findChart(const QString &id, const Signal *sig) {
|
|||
|
||||
void ChartsWidget::showChart(const QString &id, const Signal *sig, bool show, bool merge) {
|
||||
setUpdatesEnabled(false);
|
||||
if (show) {
|
||||
ChartView *chart = merge && charts.size() > 0 ? charts.back() : nullptr;
|
||||
ChartView *chart = findChart(id, sig);
|
||||
if (show && !chart) {
|
||||
chart = merge && charts.size() > 0 ? charts.back() : nullptr;
|
||||
if (!chart) {
|
||||
chart = new ChartView(this);
|
||||
chart->chart()->setTheme(use_dark_theme ? QChart::QChart::ChartThemeDark : QChart::ChartThemeLight);
|
||||
|
@ -163,7 +164,7 @@ void ChartsWidget::showChart(const QString &id, const Signal *sig, bool show, bo
|
|||
charts.push_back(chart);
|
||||
}
|
||||
chart->addSeries(id, sig);
|
||||
} else if (ChartView *chart = findChart(id, sig)) {
|
||||
} else if (!show && chart) {
|
||||
chart->removeSeries(id, sig);
|
||||
}
|
||||
updateToolBar();
|
||||
|
|
|
@ -108,6 +108,9 @@ DetailWidget::DetailWidget(ChartsWidget *charts, QWidget *parent) : charts(chart
|
|||
});
|
||||
QObject::connect(tabbar, &QTabBar::tabCloseRequested, tabbar, &QTabBar::removeTab);
|
||||
QObject::connect(charts, &ChartsWidget::seriesChanged, this, &DetailWidget::updateChartState);
|
||||
QObject::connect(history_log, &LogsWidget::openChart, [this](const QString &id, const Signal *sig) {
|
||||
this->charts->showChart(id, sig, true, false);
|
||||
});
|
||||
QObject::connect(undo_stack, &QUndoStack::indexChanged, [this]() {
|
||||
if (undo_stack->count() > 0)
|
||||
dbcMsgChanged();
|
||||
|
|
|
@ -22,6 +22,8 @@ QVariant HistoryLogModel::data(const QModelIndex &index, int role) const {
|
|||
return !sigs.empty() ? QString::number(m.sig_values[index.column() - 1]) : m.data;
|
||||
} else if (role == Qt::FontRole && index.column() == 1 && sigs.empty()) {
|
||||
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||
} else if (role == Qt::ToolTipRole && index.column() > 0 && !sigs.empty()) {
|
||||
return tr("double click to open the chart");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -182,6 +184,7 @@ LogsWidget::LogsWidget(QWidget *parent) : QWidget(parent) {
|
|||
logs->setModel(model);
|
||||
main_layout->addWidget(logs);
|
||||
|
||||
QObject::connect(logs, &QTableView::doubleClicked, this, &LogsWidget::doubleClicked);
|
||||
QObject::connect(signals_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilter()));
|
||||
QObject::connect(comp_box, SIGNAL(currentIndexChanged(int)), this, SLOT(setFilter()));
|
||||
QObject::connect(value_edit, &QLineEdit::textChanged, this, &LogsWidget::setFilter);
|
||||
|
@ -218,3 +221,12 @@ void LogsWidget::setFilter() {
|
|||
}
|
||||
model->setFilter(signals_cb->currentIndex(), value_edit->text(), cmp);
|
||||
}
|
||||
|
||||
void LogsWidget::doubleClicked(const QModelIndex &index) {
|
||||
if (index.isValid()) {
|
||||
if (model->sigs.size() > 0 && index.column() > 0) {
|
||||
emit openChart(model->msg_id, model->sigs[index.column()-1]);
|
||||
}
|
||||
can->seekTo(model->messages[index.row()].mono_time / (double)1e9 - can->routeStartTime());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,10 +60,14 @@ public:
|
|||
void setMessage(const QString &message_id);
|
||||
void updateState() { model->updateState(); }
|
||||
|
||||
signals:
|
||||
void openChart(const QString &msg_id, const Signal *sig);
|
||||
|
||||
private slots:
|
||||
void setFilter();
|
||||
|
||||
private:
|
||||
void doubleClicked(const QModelIndex &index);
|
||||
void showEvent(QShowEvent *event) override { model->setMessage(model->msg_id); };
|
||||
|
||||
HistoryLog *logs;
|
||||
|
|
Loading…
Reference in New Issue