All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH 8/8] kernel-shark-qt: Remove duplicate code in KsWidgetsLib.cpp
Date: Thu, 1 Nov 2018 21:45:46 +0000	[thread overview]
Message-ID: <20181101214512.18684-9-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20181101214512.18684-1-ykaradzhov@vmware.com>

Currently the "Task" and "CPU" checkbox widgets have their own
implementation of the code that generates the Rainbow color palettes
of the CPUs and Tasks. This patch make the two widgets to use the same
hash tables of colors used when plotting the graphs.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsWidgetsLib.cpp | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/kernel-shark-qt/src/KsWidgetsLib.cpp b/kernel-shark-qt/src/KsWidgetsLib.cpp
index b4b62a4..dd6ab0f 100644
--- a/kernel-shark-qt/src/KsWidgetsLib.cpp
+++ b/kernel-shark-qt/src/KsWidgetsLib.cpp
@@ -622,7 +622,7 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(struct tep_handle *tep,
 : KsCheckBoxTreeWidget("CPUs", parent)
 {
 	int nCPUs(0), height(FONT_HEIGHT * 1.5);
-	KsPlot::Color cpuCol;
+	KsPlot::ColorTable colors;
 	QString style;
 
 	style = QString("QTreeView::item { height: %1 ;}").arg(height);
@@ -635,16 +635,16 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(struct tep_handle *tep,
 
 	_id.resize(nCPUs);
 	_cb.resize(nCPUs);
+	colors = KsPlot::getCPUColorTable();
 
 	for (int i = 0; i < nCPUs; ++i) {
-		cpuCol.setRainbowColor(i);
 		QTreeWidgetItem *cpuItem = new QTreeWidgetItem;
 		cpuItem->setText(0, "  ");
 		cpuItem->setText(1, QString("CPU %1").arg(i));
 		cpuItem->setCheckState(0, Qt::Checked);
-		cpuItem->setBackgroundColor(0, QColor(cpuCol.r(),
-						      cpuCol.g(),
-						      cpuCol.b()));
+		cpuItem->setBackgroundColor(0, QColor(colors[i].r(),
+						      colors[i].g(),
+						      colors[i].b()));
 		_tree.addTopLevelItem(cpuItem);
 		_id[i] = i;
 		_cb[i] = cpuItem;
@@ -719,10 +719,10 @@ KsTasksCheckBoxWidget::KsTasksCheckBoxWidget(struct tep_handle *pevent,
 {
 	kshark_context *kshark_ctx(nullptr);
 	QTableWidgetItem *pidItem, *comItem;
-	KsPlot::Color pidCol;
+	KsPlot::ColorTable colors;
 	QStringList headers;
 	const char *comm;
-	int nTasks;
+	int nTasks, pid;
 
 	if (!kshark_instance(&kshark_ctx))
 		return;
@@ -735,24 +735,24 @@ KsTasksCheckBoxWidget::KsTasksCheckBoxWidget(struct tep_handle *pevent,
 	_id = KsUtils::getPidList();
 	nTasks = _id.count();
 	_initTable(headers, nTasks);
+	colors = KsPlot::getTaskColorTable();
 
 	for (int i = 0; i < nTasks; ++i) {
-		pidItem	= new QTableWidgetItem(tr("%1").arg(_id[i]));
+		pid = _id[i];
+		pidItem	= new QTableWidgetItem(tr("%1").arg(pid));
 		_table.setItem(i, 1, pidItem);
 
-		comm = tep_data_comm_from_pid(kshark_ctx->pevent, _id[i]);
+		comm = tep_data_comm_from_pid(kshark_ctx->pevent, pid);
 		comItem = new QTableWidgetItem(tr(comm));
 
-		pidItem->setBackgroundColor(QColor(pidCol.r(),
-						   pidCol.g(),
-						   pidCol.b()));
+		pidItem->setBackgroundColor(QColor(colors[pid].r(),
+						   colors[pid].g(),
+						   colors[pid].b()));
 
 		if (_id[i] == 0)
 			pidItem->setTextColor(Qt::white);
 
 		_table.setItem(i, 2, comItem);
-
-		pidCol.setRainbowColor(i);
 	}
 
 	_adjustSize();
-- 
2.17.1

  parent reply	other threads:[~2018-11-02  6:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01 21:45 [PATCH 0/8] This series of patches contains various independent Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 1/8] kernel-shark-qt: Free all collections when closing the trace file Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 2/8] kernel-shark-qt: Fix potential memory leak when searching in collections Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 3/8] kernel-shark-qt: Put error messages always on top Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 4/8] kernel-shark-qt: Fix bug when loading the Dual Marker Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 5/8] kernel-shark-qt: Fix bug when loading plugins from session Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 6/8] kernel-shark-qt: Fix bug when resizing the KS window for session Yordan Karadzhov
2018-11-01 21:45 ` [PATCH 7/8] kernel-shark-qt: Change the color convention of the task graphs Yordan Karadzhov
2018-11-01 21:45 ` Yordan Karadzhov [this message]
2018-11-02 19:16 ` [PATCH 0/8] This series of patches contains various independent Steven Rostedt

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=20181101214512.18684-9-ykaradzhov@vmware.com \
    --to=ykaradzhov@vmware.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.