diff --git a/mainwindow.cpp b/mainwindow.cpp index 9a03725..814e9e1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -172,6 +172,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->btnCollapseAll, &QAbstractButton::clicked, this, &MainWindow::collapseAllRows); connect(ui->tableSimpleSender, SIGNAL(cellChanged(int,int)), this, SLOT(onSenderCellChanged(int,int))); + ui->tableSimpleSender->setVisible(false); lbStatusConnected.setText(tr("Connected to 0 buses")); lbHelp.setText(tr("Press F1 on any screen for help")); @@ -396,7 +397,7 @@ void MainWindow::readSettings() ui->canFramesView->setColumnWidth(5, settings.value("Main/BusColumn", 40).toUInt()); //bus ui->canFramesView->setColumnWidth(6, settings.value("Main/LengthColumn", 40).toUInt()); //length ui->canFramesView->setColumnWidth(7, settings.value("Main/AsciiColumn", 50).toUInt()); //ascii - //ui->canFramesView->setColumnWidth(8, settings.value("Main/DataColumn", 225).toUInt()); //data + ui->canFramesView->setColumnWidth(8, settings.value("Main/DataColumn", 400).toUInt()); //data } if (settings.value("Main/AutoScroll", false).toBool()) { diff --git a/re/isotp_interpreterwindow.cpp b/re/isotp_interpreterwindow.cpp index 045d608..5c5f7c4 100644 --- a/re/isotp_interpreterwindow.cpp +++ b/re/isotp_interpreterwindow.cpp @@ -11,6 +11,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector *frames ui->setupUi(this); setWindowFlags(Qt::Window); modelFrames = frames; + m_isAutoScrolling = false; decoder = new ISOTP_HANDLER; udsDecoder = new UDS_HANDLER; @@ -33,6 +34,7 @@ ISOTP_InterpreterWindow::ISOTP_InterpreterWindow(const QVector *frames connect(ui->btnClearList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::clearList); connect(ui->btnSaveList, &QPushButton::clicked, this, &ISOTP_InterpreterWindow::saveList); connect(ui->cbUseExtendedAddressing, SIGNAL(toggled(bool)), this, SLOT(useExtendedAddressing(bool))); + connect(ui->tableIsoFrames->verticalScrollBar(), &QScrollBar::valueChanged, this, &ISOTP_InterpreterWindow::onManualScroll); QStringList headers; headers << "Timestamp" << "ID" << "Bus" << "Dir" << "Length" << "Data"; @@ -322,6 +324,25 @@ void ISOTP_InterpreterWindow::newUDSMessage(UDS_MESSAGE msg) ui->txtFrameDetails->setPlainText(buildText); } +void ISOTP_InterpreterWindow::onManualScroll() +{ + // If the user manually scrolls, check if they're at the bottom + if (!m_isAutoScrolling) + { + QScrollBar *scrollBar = ui->tableIsoFrames->verticalScrollBar(); + if (scrollBar->value() == scrollBar->maximum()) + { + // At bottom - enable autoscroll + ui->cbAutoscroll->setChecked(true); + } + else + { + // Not at bottom - disable autoscroll + ui->cbAutoscroll->setChecked(false); + } + } +} + void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg) { int rowNum; @@ -357,8 +378,21 @@ void ISOTP_InterpreterWindow::newISOMessage(ISOTP_MESSAGE msg) for (int i = 0; i < dataLen; i++) { - tempString.append(Utility::formatNumber(data[i])); - tempString.append(" "); + // if last character is the newline + if (i == dataLen -1 && data[i] == '\n') { + continue; + } + tempString.append(QString(QChar(data[i]))); } ui->tableIsoFrames->setItem(rowNum, 5, new QTableWidgetItem(tempString)); + + // autoscroll to the newly added row if autoscroll is enabled + if (ui->cbAutoscroll->isChecked()) + { + m_isAutoScrolling = true; + ui->tableIsoFrames->scrollToItem(ui->tableIsoFrames->item(rowNum, 0), QAbstractItemView::PositionAtBottom); + // scroll down one additional row height + ui->tableIsoFrames->verticalScrollBar()->setValue(ui->tableIsoFrames->verticalScrollBar()->value() + ui->tableIsoFrames->rowHeight(rowNum)); + m_isAutoScrolling = false; + } } diff --git a/re/isotp_interpreterwindow.h b/re/isotp_interpreterwindow.h index 3b3a6b2..af0202a 100644 --- a/re/isotp_interpreterwindow.h +++ b/re/isotp_interpreterwindow.h @@ -33,6 +33,7 @@ private slots: void interpretCapturedFrames(); void useExtendedAddressing(bool checked); void headerClicked(int logicalIndex); + void onManualScroll(); private: Ui::ISOTP_InterpreterWindow *ui; @@ -42,6 +43,7 @@ private: const QVector *modelFrames; QVector messages; QHash idFilters; + bool m_isAutoScrolling; void closeEvent(QCloseEvent *event); bool eventFilter(QObject *obj, QEvent *event); diff --git a/ui/isotp_interpreterwindow.ui b/ui/isotp_interpreterwindow.ui index 6f7f67d..dd28ccd 100644 --- a/ui/isotp_interpreterwindow.ui +++ b/ui/isotp_interpreterwindow.ui @@ -63,6 +63,16 @@ + + + + Autoscroll to new messages + + + true + + +