From 9ed5c78a805263908df030d7037efdfecb9323d2 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Wed, 20 Mar 2024 10:03:23 +0800 Subject: [PATCH] cabana: horizontal scrolling with Shift+wheel (#31929) --- tools/cabana/messageswidget.cc | 12 +++++++++++- tools/cabana/messageswidget.h | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tools/cabana/messageswidget.cc b/tools/cabana/messageswidget.cc index 0cec551017..720553dcb3 100644 --- a/tools/cabana/messageswidget.cc +++ b/tools/cabana/messageswidget.cc @@ -85,7 +85,9 @@ MessagesWidget::MessagesWidget(QWidget *parent) : menu(new QMenu(this)), QWidget Byte color
constant changing
increasing
- decreasing + decreasing
+ Shortcuts
+ Horizontal Scrolling:  shift+wheel  )")); } @@ -391,6 +393,14 @@ void MessageView::updateBytesSectionSize() { header()->resizeSection(MessageListModel::Column::DATA, delegate->sizeForBytes(max_bytes).width()); } +void MessageView::wheelEvent(QWheelEvent *event) { + if (event->modifiers() == Qt::ShiftModifier) { + QApplication::sendEvent(horizontalScrollBar(), event); + } else { + QTreeView::wheelEvent(event); + } +} + // MessageViewHeader MessageViewHeader::MessageViewHeader(QWidget *parent) : QHeaderView(Qt::Horizontal, parent) { diff --git a/tools/cabana/messageswidget.h b/tools/cabana/messageswidget.h index 4f54941c64..e7f1f8c033 100644 --- a/tools/cabana/messageswidget.h +++ b/tools/cabana/messageswidget.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "tools/cabana/dbc/dbcmanager.h" #include "tools/cabana/streams/abstractstream.h" @@ -65,10 +66,13 @@ class MessageView : public QTreeView { Q_OBJECT public: MessageView(QWidget *parent) : QTreeView(parent) {} + void updateBytesSectionSize(); + +protected: void drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override {} void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles = QVector()) override; - void updateBytesSectionSize(); + void wheelEvent(QWheelEvent *event) override; }; class MessageViewHeader : public QHeaderView {