From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
Yordan Karadzhov <ykaradzhov@vmware.com>
Subject: [PATCH 3/5] kernel-shark: Define KS_NO_ROW_SELECTED as a negative row index (-1)
Date: Tue, 12 Feb 2019 19:04:00 +0200 [thread overview]
Message-ID: <20190212170402.10104-4-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20190212170402.10104-1-ykaradzhov@vmware.com>
Currently the model of the table treats any negative value of the Passive
Marker index as "No Row is Selected". In multiple places in the code the
value of "-1" is used in order to deselecting the marker. Defining a
dedicated constant (KS_NO_ROW_SELECTED), to be used for deselecting the
Passive Marker will make the code more readable and robust.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202327
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
kernel-shark/src/KsModels.cpp | 8 ++++----
kernel-shark/src/KsModels.hpp | 3 +++
kernel-shark/src/KsTraceViewer.cpp | 6 +++---
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/kernel-shark/src/KsModels.cpp b/kernel-shark/src/KsModels.cpp
index 1b68143..b89fee8 100644
--- a/kernel-shark/src/KsModels.cpp
+++ b/kernel-shark/src/KsModels.cpp
@@ -199,8 +199,8 @@ KsViewModel::KsViewModel(QObject *parent)
_nRows(0),
_header({"#", "CPU", "Time Stamp", "Task", "PID",
"Latency", "Event", "Info"}),
- _markA(-1),
- _markB(-1)
+ _markA(KS_NO_ROW_SELECTED),
+ _markB(KS_NO_ROW_SELECTED)
{}
/**
@@ -311,10 +311,10 @@ void KsViewModel::selectRow(DualMarkerState state, int row)
{
if (state == DualMarkerState::A) {
_markA = row;
- _markB = -1;
+ _markB = KS_NO_ROW_SELECTED;
} else {
_markB = row;
- _markA = -1;
+ _markA = KS_NO_ROW_SELECTED;
}
}
diff --git a/kernel-shark/src/KsModels.hpp b/kernel-shark/src/KsModels.hpp
index 808c574..3faaf4a 100644
--- a/kernel-shark/src/KsModels.hpp
+++ b/kernel-shark/src/KsModels.hpp
@@ -28,6 +28,9 @@
#include "libkshark-model.h"
#include "KsSearchFSM.hpp"
+/** A negative row index, to be used for deselecting the Passive Marker. */
+#define KS_NO_ROW_SELECTED -1
+
enum class DualMarkerState;
class KsDataStore;
diff --git a/kernel-shark/src/KsTraceViewer.cpp b/kernel-shark/src/KsTraceViewer.cpp
index 61d7386..2881bd0 100644
--- a/kernel-shark/src/KsTraceViewer.cpp
+++ b/kernel-shark/src/KsTraceViewer.cpp
@@ -474,7 +474,7 @@ void KsTraceViewer::markSwitch()
* The passive marker is not set.
* Make sure that the model colors nothing.
*/
- _model.selectRow(!state, -1);
+ _model.selectRow(!state, KS_NO_ROW_SELECTED);
}
/*
@@ -722,12 +722,12 @@ void KsTraceViewer::passiveMarkerSelectRow(int row)
/**
* Get the currently selected row. If no row is selected the function
- * returns -1.
+ * returns KS_NO_ROW_SELECTED (-1).
*/
int KsTraceViewer::selectedRow()
{
QItemSelectionModel *sm = _view.selectionModel();
- int dataRow = -1;
+ int dataRow = KS_NO_ROW_SELECTED;
if (sm->hasSelection()) {
/* Only one row at the time can be selected. */
--
2.17.1
next prev parent reply other threads:[~2019-02-12 17:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-12 17:03 [PATCH 0/5] The right click of the button deselects the marker Yordan Karadzhov
2019-02-12 17:03 ` [PATCH 1/5] kernel-shark: Customize the marker switching button Yordan Karadzhov
2019-02-12 17:03 ` [PATCH 2/5] kernel-shark: Define a method in View for selecting the Passive marker Yordan Karadzhov
2019-02-12 17:04 ` Yordan Karadzhov [this message]
2019-02-12 17:04 ` [PATCH 4/5] kernel-shark-qt: Do marker-deselect by right mouse click of the button Yordan Karadzhov
2019-02-12 17:04 ` [PATCH 5/5] kernel-shark: Rename the method for deselecting the Active marker Yordan Karadzhov
2019-02-13 14:41 ` [PATCH 0/5] The right click of the button deselects the marker 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=20190212170402.10104-4-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 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).