mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-06-27 07:22:05 +08:00
cabana: double click on an item in FindSimilarBitsDlg to open the message in detailView (#26930)
* double click to open message
* remove qDebug
old-commit-hash: 53ec07edbd
This commit is contained in:
@@ -281,5 +281,6 @@ void MainWindow::setOption() {
|
||||
|
||||
void MainWindow::findSimilarBits() {
|
||||
FindSimilarBitsDlg dlg(this);
|
||||
QObject::connect(&dlg, &FindSimilarBitsDlg::openMessage, messages_widget, &MessagesWidget::selectMessage);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
|
||||
QObject::connect(dbc(), &DBCManager::DBCFileChanged, model, &MessageListModel::sortMessages);
|
||||
QObject::connect(dbc(), &DBCManager::msgUpdated, model, &MessageListModel::sortMessages);
|
||||
QObject::connect(dbc(), &DBCManager::msgRemoved, model, &MessageListModel::sortMessages);
|
||||
QObject::connect(model, &MessageListModel::modelReset, [this]() { selectMessage(current_msg_id); });
|
||||
QObject::connect(table_widget->selectionModel(), &QItemSelectionModel::currentChanged, [=](const QModelIndex ¤t, const QModelIndex &previous) {
|
||||
if (current.isValid() && current.row() < model->msgs.size()) {
|
||||
if (model->msgs[current.row()] != current_msg_id) {
|
||||
@@ -47,10 +48,12 @@ MessagesWidget::MessagesWidget(QWidget *parent) : QWidget(parent) {
|
||||
}
|
||||
}
|
||||
});
|
||||
QObject::connect(model, &MessageListModel::modelReset, [this]() {
|
||||
if (int row = model->msgs.indexOf(current_msg_id); row != -1)
|
||||
table_widget->selectionModel()->setCurrentIndex(model->index(row, 0), QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
||||
});
|
||||
}
|
||||
|
||||
void MessagesWidget::selectMessage(const QString &msg_id) {
|
||||
if (int row = model->msgs.indexOf(msg_id); row != -1) {
|
||||
table_widget->selectionModel()->setCurrentIndex(model->index(row, 0), QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
}
|
||||
|
||||
// MessageListModel
|
||||
|
||||
@@ -31,6 +31,8 @@ class MessagesWidget : public QWidget {
|
||||
|
||||
public:
|
||||
MessagesWidget(QWidget *parent);
|
||||
void selectMessage(const QString &message_id);
|
||||
|
||||
signals:
|
||||
void msgSelectionChanged(const QString &message_id);
|
||||
|
||||
|
||||
@@ -59,12 +59,19 @@ FindSimilarBitsDlg::FindSimilarBitsDlg(QWidget *parent) : QDialog(parent) {
|
||||
main_layout->addLayout(form_layout);
|
||||
|
||||
table = new QTableWidget(this);
|
||||
table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
table->horizontalHeader()->setStretchLastSection(true);
|
||||
main_layout->addWidget(table);
|
||||
|
||||
setMinimumSize({700, 500});
|
||||
QObject::connect(search_btn, &QPushButton::clicked, this, &FindSimilarBitsDlg::find);
|
||||
QObject::connect(table, &QTableWidget::doubleClicked, [this](const QModelIndex &index) {
|
||||
if (index.isValid()) {
|
||||
emit openMessage(bus_combo->currentText() + ":" + table->item(index.row(), 0)->text());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void FindSimilarBitsDlg::find() {
|
||||
@@ -91,7 +98,6 @@ QList<FindSimilarBitsDlg::mismatched_struct> FindSimilarBitsDlg::calcBits(uint8_
|
||||
QHash<uint32_t, QVector<uint32_t>> mismatches;
|
||||
QHash<uint32_t, uint32_t> msg_count;
|
||||
auto events = can->events();
|
||||
qDebug() << bus << selected_address << byte_idx << bit_idx;
|
||||
int bit_to_find = -1;
|
||||
for (auto e : *events) {
|
||||
if (e->which == cereal::Event::Which::CAN) {
|
||||
|
||||
@@ -7,9 +7,14 @@
|
||||
#include <QTableWidget>
|
||||
|
||||
class FindSimilarBitsDlg : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FindSimilarBitsDlg(QWidget *parent);
|
||||
|
||||
signals:
|
||||
void openMessage(const QString &msg_id);
|
||||
|
||||
private:
|
||||
struct mismatched_struct {
|
||||
uint32_t address, byte_idx, bit_idx, mismatches, total;
|
||||
|
||||
Reference in New Issue
Block a user