linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 2/8] kernel-shark: Add method for getting all selected events
Date: Tue,  9 Jul 2019 18:56:44 +0300	[thread overview]
Message-ID: <20190709155650.2345-3-y.karadz@gmail.com> (raw)
In-Reply-To: <20190709155650.2345-1-y.karadz@gmail.com>

A new method is added to the class KsEventsCheckBoxWidget. It returns
a list of strings containing all selected events. If the whole system
is selected (the top level checkbox is checked), only the name of the
system is added to the list.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsWidgetsLib.cpp | 41 +++++++++++++++++++++++++++++++
 kernel-shark/src/KsWidgetsLib.hpp |  2 ++
 2 files changed, 43 insertions(+)

diff --git a/kernel-shark/src/KsWidgetsLib.cpp b/kernel-shark/src/KsWidgetsLib.cpp
index ea02b5e..1c55c79 100644
--- a/kernel-shark/src/KsWidgetsLib.cpp
+++ b/kernel-shark/src/KsWidgetsLib.cpp
@@ -706,6 +706,47 @@ KsEventsCheckBoxWidget::KsEventsCheckBoxWidget(struct tep_handle *tep,
 	_adjustSize();
 }
 
+/**
+ * @brief Get a list of all checked events. If the whole system is selected
+ *	  (the top level checkbox is checked), only the name of the system is
+ *	  added to the list.
+ *
+ * @param option: If True, "-e" is added as prefix to each element of the list.
+ *
+ * @returns A list of checked events or systems.
+ */
+QStringList KsEventsCheckBoxWidget::getCheckedEvents(bool option)
+{
+	QTreeWidgetItem *sysItem, *evtItem;
+	QStringList list;
+	QString optStr;
+	int nSys, nEvts;
+
+	if (option)
+		optStr = "-e";
+
+	nSys = _tree.topLevelItemCount();
+	for(int t = 0; t < nSys; ++t) {
+		sysItem = _tree.topLevelItem(t);
+		if (sysItem->checkState(0) == Qt::Checked) {
+			list << optStr + sysItem->text(0);
+		} else {
+			nEvts = sysItem->childCount();
+			for (int c = 0; c < nEvts; ++c) {
+				evtItem = sysItem->child(c);
+				if (evtItem->checkState(0) == Qt::Checked) {
+					list << optStr +
+						sysItem->text(0) +
+						":" +
+						evtItem->text(0);
+				}
+			}
+		}
+	}
+
+	return list;
+}
+
 /** Remove a System from the Checkbox tree. */
 void KsEventsCheckBoxWidget::removeSystem(QString name) {
 	QTreeWidgetItem *item =
diff --git a/kernel-shark/src/KsWidgetsLib.hpp b/kernel-shark/src/KsWidgetsLib.hpp
index 6f22374..0d79250 100644
--- a/kernel-shark/src/KsWidgetsLib.hpp
+++ b/kernel-shark/src/KsWidgetsLib.hpp
@@ -333,6 +333,8 @@ struct KsEventsCheckBoxWidget : public KsCheckBoxTreeWidget
 	KsEventsCheckBoxWidget(struct tep_handle *pe,
 			       QWidget *parent = nullptr);
 
+	QStringList getCheckedEvents(bool option);
+
 	void removeSystem(QString name);
 };
 
-- 
2.20.1


  parent reply	other threads:[~2019-07-09 15:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09 15:56 [PATCH 0/8]Fixes needed befor KS 1.0 Yordan Karadzhov (VMware)
2019-07-09 15:56 ` [PATCH 1/8] kernel-shark: Don't free the string field of KS_CONFIG_STRING document Yordan Karadzhov (VMware)
2019-07-09 15:56 ` Yordan Karadzhov (VMware) [this message]
2019-07-09 15:56 ` [PATCH 3/8] kernel-shark: Optimize the command line options used by the capture dialog Yordan Karadzhov (VMware)
2019-07-09 15:56 ` [PATCH 4/8] kernel-shark: Don't try to open data file if recording failed Yordan Karadzhov (VMware)
2019-07-09 15:56 ` [PATCH 5/8] kernel-shark: Remove a duplicate error message Yordan Karadzhov (VMware)
2019-07-09 15:56 ` [PATCH 6/8] kernel-shark: remove the "make install" suggestion for capture errors Yordan Karadzhov (VMware)
2019-07-10  1:36   ` Steven Rostedt
2019-07-09 15:56 ` [PATCH 7/8] kernel-shark: Disconnect "capture errors" before closing KernelShark GUI Yordan Karadzhov (VMware)
2019-07-09 15:56 ` [PATCH 8/8] kernel-shark: Less scary error message from Capture dialog Yordan Karadzhov (VMware)

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=20190709155650.2345-3-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 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).