@@ -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;
}
}
@@ -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;
@@ -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. */
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(-)