cabana: insert new chart at the top (#25981)

* small cleanup

* new chart insert at the top
This commit is contained in:
Dean Lee
2022-10-07 02:20:49 +08:00
committed by GitHub
parent 8b33ee9750
commit 4cd3753d98
4 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ void ChartsWidget::addChart(const QString &id, const QString &sig_name) {
const QString char_name = id + sig_name;
if (charts.find(char_name) == charts.end()) {
auto chart = new ChartWidget(id, sig_name, this);
main_layout->addWidget(chart);
main_layout->insertWidget(0, chart);
charts[char_name] = chart;
}
}
+1
View File
@@ -5,6 +5,7 @@
MainWindow::MainWindow() : QWidget() {
QVBoxLayout *main_layout = new QVBoxLayout(this);
QHBoxLayout *h_layout = new QHBoxLayout();
main_layout->addLayout(h_layout);
+11 -11
View File
@@ -14,20 +14,11 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
for (const auto &name : dbc_names) {
combo->addItem(QString::fromStdString(name));
}
connect(combo, &QComboBox::currentTextChanged, [=](const QString &dbc) {
parser->openDBC(dbc);
});
// For test purpose
combo->setCurrentText("toyota_nodsu_pt_generated");
dbc_file_layout->addWidget(combo);
dbc_file_layout->addStretch();
QPushButton *save_btn = new QPushButton(tr("Save DBC"), this);
QObject::connect(save_btn, &QPushButton::clicked, [=]() {
// TODO: save DBC to file
});
dbc_file_layout->addWidget(save_btn);
main_layout->addLayout(dbc_file_layout);
filter = new QLineEdit(this);
@@ -44,14 +35,23 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
table_widget->setColumnWidth(2, 80);
table_widget->setHorizontalHeaderLabels({tr("Name"), tr("ID"), tr("Count"), tr("Bytes")});
table_widget->horizontalHeader()->setStretchLastSection(true);
main_layout->addWidget(table_widget);
QObject::connect(parser, &Parser::updated, this, &MessagesWidget::updateState);
QObject::connect(save_btn, &QPushButton::clicked, [=]() {
// TODO: save DBC to file
});
QObject::connect(combo, &QComboBox::currentTextChanged, [=](const QString &dbc) {
parser->openDBC(dbc);
});
QObject::connect(table_widget, &QTableWidget::itemSelectionChanged, [=]() {
const CanData *c = &(parser->can_msgs[table_widget->selectedItems()[1]->text()]);
parser->setCurrentMsg(c->id);
emit msgChanged(c);
});
main_layout->addWidget(table_widget);
connect(parser, &Parser::updated, this, &MessagesWidget::updateState);
// For test purpose
combo->setCurrentText("toyota_nodsu_pt_generated");
}
void MessagesWidget::updateState() {
-1
View File
@@ -12,7 +12,6 @@
#include "opendbc/can/common_dbc.h"
#include "tools/replay/replay.h"
const int DATA_LIST_SIZE = 50;
const int FPS = 20;
const static int LOG_SIZE = 25;