linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel-shark: Show multi-line events using the dual marker
@ 2023-01-15 18:43 Yordan Karadzhov
  0 siblings, 0 replies; only message in thread
From: Yordan Karadzhov @ 2023-01-15 18:43 UTC (permalink / raw)
  To: linux-trace-devel; +Cc: rostedt, Yordan Karadzhov

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 --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;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-15 18:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-15 18:43 [PATCH] kernel-shark: Show multi-line events using the dual marker Yordan Karadzhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).