diff mbox series

[16/17] kernel-shark-qt: Add "Hide CPU" checkbox dialog to the Main window menu

Message ID 20181128151530.21965-17-ykaradzhov@vmware.com (mailing list archive)
State Accepted
Commit af6163ef16a4d1f36355906b25a2a609f842a277
Headers show
Series More modifications and bug fixes toward KS 1.0 | expand

Commit Message

Yordan Karadzhov Nov. 28, 2018, 3:16 p.m. UTC
"Hide CPU" checkbox dialog is added to Menu/Filtering. This dialog is
complementary to the "Hide CPU" action of the Quick Context Menu.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsMainWindow.cpp | 39 ++++++++++++++++++++++++++++
 kernel-shark-qt/src/KsMainWindow.hpp |  4 +++
 2 files changed, 43 insertions(+)

Comments

Steven Rostedt Nov. 28, 2018, 5:16 p.m. UTC | #1
On Wed, 28 Nov 2018 15:16:27 +0000
Yordan Karadzhov <ykaradzhov@vmware.com> wrote:


> +void KsMainWindow::_hideCPUs()
> +{
> +	kshark_context *kshark_ctx(nullptr);
> +	KsCheckBoxWidget *cpu_cbd;
> +	KsCheckBoxDialog *dialog;
> +
> +	if (!kshark_instance(&kshark_ctx))
> +		return;
> +
> +	cpu_cbd = new KsCPUCheckBoxWidget(_data.tep(), this);
> +	dialog = new KsCheckBoxDialog(cpu_cbd, this);
> +
> +	if (!kshark_ctx->hide_cpu_filter ||
> +	    !kshark_ctx->hide_cpu_filter->count) {
> +		cpu_cbd->setDefault(false);
> +	} else {
> +		int nCPUs = tep_get_cpus(_data.tep());
> +		QVector<bool> v(nCPUs, false);
> +
> +		for (int i = 0; i < nCPUs; ++i) {
> +			if (tracecmd_filter_id_find(kshark_ctx->hide_cpu_filter,
> +						    i))

Just a nit, but really that "i))" could have been on the previous line.

No need to send another patch, but let's not get too crazy at breaking
up lines like this ;-)

-- Steve

> +				v[i] = true;
> +		}
>
diff mbox series

Patch

diff --git a/kernel-shark-qt/src/KsMainWindow.cpp b/kernel-shark-qt/src/KsMainWindow.cpp
index f4804bd..16ba8bb 100644
--- a/kernel-shark-qt/src/KsMainWindow.cpp
+++ b/kernel-shark-qt/src/KsMainWindow.cpp
@@ -54,6 +54,7 @@  KsMainWindow::KsMainWindow(QWidget *parent)
   _showEventsAction("Show events", this),
   _showTasksAction("Show tasks", this),
   _hideTasksAction("Hide tasks", this),
+  _hideCPUsAction("Hide CPUs", this),
   _advanceFilterAction("Advance Filtering", this),
   _clearAllFilters("Clear all filters", this),
   _cpuSelectAction("CPUs", this),
@@ -207,6 +208,9 @@  void KsMainWindow::_createActions()
 	connect(&_hideTasksAction,	&QAction::triggered,
 		this,			&KsMainWindow::_hideTasks);
 
+	connect(&_hideCPUsAction,	&QAction::triggered,
+		this,			&KsMainWindow::_hideCPUs);
+
 	connect(&_advanceFilterAction,	&QAction::triggered,
 		this,			&KsMainWindow::_advancedFiltering);
 
@@ -329,6 +333,7 @@  void KsMainWindow::_createMenus()
 	filter->addAction(&_showEventsAction);
 	filter->addAction(&_showTasksAction);
 	filter->addAction(&_hideTasksAction);
+	filter->addAction(&_hideCPUsAction);
 	filter->addAction(&_advanceFilterAction);
 	filter->addAction(&_clearAllFilters);
 
@@ -603,6 +608,40 @@  void KsMainWindow::_hideTasks()
 	dialog->show();
 }
 
+void KsMainWindow::_hideCPUs()
+{
+	kshark_context *kshark_ctx(nullptr);
+	KsCheckBoxWidget *cpu_cbd;
+	KsCheckBoxDialog *dialog;
+
+	if (!kshark_instance(&kshark_ctx))
+		return;
+
+	cpu_cbd = new KsCPUCheckBoxWidget(_data.tep(), this);
+	dialog = new KsCheckBoxDialog(cpu_cbd, this);
+
+	if (!kshark_ctx->hide_cpu_filter ||
+	    !kshark_ctx->hide_cpu_filter->count) {
+		cpu_cbd->setDefault(false);
+	} else {
+		int nCPUs = tep_get_cpus(_data.tep());
+		QVector<bool> v(nCPUs, false);
+
+		for (int i = 0; i < nCPUs; ++i) {
+			if (tracecmd_filter_id_find(kshark_ctx->hide_cpu_filter,
+						    i))
+				v[i] = true;
+		}
+
+		cpu_cbd->set(v);
+	}
+
+	connect(dialog,		&KsCheckBoxDialog::apply,
+		&_data,		&KsDataStore::applyNegCPUFilter);
+
+	dialog->show();
+}
+
 void KsMainWindow::_advancedFiltering()
 {
 	KsAdvFilteringDialog *dialog;
diff --git a/kernel-shark-qt/src/KsMainWindow.hpp b/kernel-shark-qt/src/KsMainWindow.hpp
index 5938a25..b231b52 100644
--- a/kernel-shark-qt/src/KsMainWindow.hpp
+++ b/kernel-shark-qt/src/KsMainWindow.hpp
@@ -120,6 +120,8 @@  private:
 
 	QAction		_hideTasksAction;
 
+	QAction		_hideCPUsAction;
+
 	QAction		_advanceFilterAction;
 
 	QAction		_clearAllFilters;
@@ -171,6 +173,8 @@  private:
 
 	void _hideTasks();
 
+	void _hideCPUs();
+
 	void _advancedFiltering();
 
 	void _clearFilters();