diff mbox series

kernel-shark: Show multi-line events using the dual marker

Message ID 20230115184312.46666-1-y.karadz@gmail.com (mailing list archive)
State Accepted
Commit 8723a2dce4a459e01b65ed520497cb1ac751a982
Headers show
Series kernel-shark: Show multi-line events using the dual marker | expand

Commit Message

Yordan Karadzhov Jan. 15, 2023, 6:43 p.m. UTC
Some events (stack traces) have multiple lines, but currently the list
view of each event is just a single line. Make sure that the cells of
the records, selected with the markers, are resized such that all lines
are shown into the table.

Signed-off-by: Yordan Karadzhov <y.karadz@gmail.com>
---
 src/KsTraceViewer.cpp | 23 ++++++++++++++++++++++-
 src/KsTraceViewer.hpp |  2 ++
 2 files changed, 24 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/KsTraceViewer.cpp b/src/KsTraceViewer.cpp
index be0a419..12a95a7 100644
--- a/src/KsTraceViewer.cpp
+++ b/src/KsTraceViewer.cpp
@@ -110,6 +110,25 @@  KsTraceViewer::KsTraceViewer(QWidget *parent)
 	connect(&_searchFSM._searchRestartButton,	&QPushButton::pressed,
 		this,				&KsTraceViewer::_searchContinue);
 
+	int defaultRowHeight = FONT_HEIGHT * 1.25;
+	auto lamSelectionChanged = [this, defaultRowHeight] (const QItemSelection &selected,
+							     const QItemSelection &deselected) {
+		if (deselected.count()) {
+			_view.verticalHeader()->resizeSection(deselected.indexes().first().row(),
+							      defaultRowHeight);
+		}
+		if (selected.count()) {
+			_view.resizeRowToContents(selected.indexes().first().row());
+		}
+
+		if (_mState->passiveMarker().isVisible()) {
+			QModelIndex index = _model.index(_mState->passiveMarker()._pos, 0);
+			_view.resizeRowToContents(_proxyModel.mapFromSource(index).row());
+		}
+	};
+	connect(&_selectionModel,	&QItemSelectionModel::selectionChanged,
+		lamSelectionChanged);
+
 	_searchFSM.placeInToolBar(&_toolbar);
 
 	/*
@@ -128,13 +147,15 @@  KsTraceViewer::KsTraceViewer(QWidget *parent)
 	_view.setEditTriggers(QAbstractItemView::NoEditTriggers);
 	_view.setSelectionBehavior(QAbstractItemView::SelectRows);
 	_view.setSelectionMode(QAbstractItemView::SingleSelection);
-	_view.verticalHeader()->setDefaultSectionSize(FONT_HEIGHT * 1.25);
+	_view.verticalHeader()->setDefaultSectionSize(defaultRowHeight);
 	_view.setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
 	_view.horizontalHeader()->setFont(
 		QFontDatabase::systemFont(QFontDatabase::GeneralFont));
 
 	 _proxyModel.setSource(&_model);
+	_selectionModel.setModel(&_proxyModel);
 	_view.setModel(&_proxyModel);
+	_view.setSelectionModel(&_selectionModel);
 	connect(&_proxyModel, &QAbstractItemModel::modelReset,
 		this, &KsTraceViewer::_searchReset);
 
diff --git a/src/KsTraceViewer.hpp b/src/KsTraceViewer.hpp
index f3979a6..ae1929d 100644
--- a/src/KsTraceViewer.hpp
+++ b/src/KsTraceViewer.hpp
@@ -106,6 +106,8 @@  private:
 
 	KsFilterProxyModel	_proxyModel;
 
+	QItemSelectionModel 	_selectionModel;
+
 	QToolBar	_toolbar;
 
 	QLabel		_labelSearch, _labelGrFollows;