All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yordan Karadzhov <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: rostedt@goodmis.org, Yordan Karadzhov <y.karadz@gmail.com>
Subject: [PATCH] kernel-shark: Show multi-line events using the dual marker
Date: Sun, 15 Jan 2023 20:43:12 +0200	[thread overview]
Message-ID: <20230115184312.46666-1-y.karadz@gmail.com> (raw)

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


                 reply	other threads:[~2023-01-15 18:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230115184312.46666-1-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.