[PATCH 2/2] kernel-shark: CPU plots dialog ease spotting empty CPUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The CPU plots dialog will show only the ones with content. A "hide empty"
checkbox is added, that by default is checked. If it is unchecked, then
all the CPUs would show up.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215677
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
---
 src/KsWidgetsLib.cpp | 26 +++++++++++++++++++++++++-
 src/KsWidgetsLib.hpp |  7 +++++--
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/KsWidgetsLib.cpp b/src/KsWidgetsLib.cpp
index e30bf27..7b3192d 100644
--- a/src/KsWidgetsLib.cpp
+++ b/src/KsWidgetsLib.cpp
@@ -906,12 +906,35 @@ void KsCheckBoxTreeWidget::_verify()
  * @param parent: The parent of this widget.
  */
 KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *parent)
-: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent)
+: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent),
+  _hideEmpty("hide empty")
 {
 	int height(FONT_HEIGHT * 1.5);
 	KsPlot::ColorTable colors;
 	QString style;
 
+	_hideEmpty.setCheckState(Qt::Checked);
+	_tb.addSeparator();
+	_tb.addWidget(&_hideEmpty);
+
+	auto lamHideEmpty = [this, stream] (bool hide) {
+		QTreeWidgetItem *item;
+		bool isIdle;
+
+		for(int cpu = 0; cpu < stream->n_cpus; ++cpu) {
+			item = _tree.topLevelItem(cpu);
+			if (hide) {
+				isIdle = kshark_hash_id_find(stream->idle_cpus, cpu);
+				item->setHidden(isIdle);
+			} else {
+				item->setHidden(false);
+			}
+		}
+	};
+
+	connect(&_hideEmpty,	&QCheckBox::clicked,
+				lamHideEmpty);
+
 	style = QString("QTreeView::item { height: %1 ;}").arg(height);
 	_tree.setStyleSheet(style);
 
@@ -934,6 +957,7 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *pa
 		_cb[i] = cpuItem;
 	}
 
+	lamHideEmpty(true);
 	_adjustSize();
 }
 
diff --git a/src/KsWidgetsLib.hpp b/src/KsWidgetsLib.hpp
index 6ec2bd1..2cc3535 100644
--- a/src/KsWidgetsLib.hpp
+++ b/src/KsWidgetsLib.hpp
@@ -275,10 +275,9 @@ public:
 	/** The user provided an input. The widget has been modified. */
 	bool _userInput;
 
-private:
+protected:
 	QToolBar _tb;
 
-protected:
 	/** Identifier of the Data stream for which the selection applies. */
 	int		_sd;
 
@@ -544,6 +543,10 @@ struct KsCPUCheckBoxWidget : public KsCheckBoxTreeWidget
 
 	KsCPUCheckBoxWidget(kshark_data_stream *stream,
 			    QWidget *parent = nullptr);
+
+private:
+	/** The "hide empty" checkbox. */
+	QCheckBox	_hideEmpty;
 };
 
 /**
-- 
2.32.0




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux