aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-02-11 12:31:56 +0200
committerYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-02-16 10:25:14 +0200
commit16d2a2d480a5cfbcbbf2c16425beec87be90fe9b (patch)
tree7d93496f10e545d75aa9862f3aadd9a1589aec81
parentb3ec9bc20cf66d6329fdd1c48c37ca25fc1bfd1b (diff)
downloadkernel-shark-16d2a2d480a5cfbcbbf2c16425beec87be90fe9b.tar.gz
kernel-shark: Update KsTraceViewer
The compilation of KsTraceViewer.cpp is re-enabled and all functionalities are made compatible with the new version of the C API of libkshark (KernelShark 2.0). Link: https://lore.kernel.org/linux-trace-devel/20210211103205.418588-19-y.karadz@gmail.com Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/KsTraceGraph.hpp5
-rw-r--r--src/KsTraceViewer.cpp57
-rw-r--r--src/KsTraceViewer.hpp13
4 files changed, 54 insertions, 25 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ab74d5ac..e09deb7f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -73,7 +73,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
KsDualMarker.hpp
KsWidgetsLib.hpp
KsTraceGraph.hpp
-# KsTraceViewer.hpp
+ KsTraceViewer.hpp
# KsMainWindow.hpp
# KsCaptureDialog.hpp
KsQuickContextMenu.hpp)
@@ -89,7 +89,7 @@ if (Qt5Widgets_FOUND AND Qt5Network_FOUND AND TT_FONT_FILE)
KsDualMarker.cpp
KsWidgetsLib.cpp
KsTraceGraph.cpp
-# KsTraceViewer.cpp
+ KsTraceViewer.cpp
# KsMainWindow.cpp
# KsCaptureDialog.cpp
KsQuickContextMenu.cpp)
diff --git a/src/KsTraceGraph.hpp b/src/KsTraceGraph.hpp
index 0e31b888..6e83f21e 100644
--- a/src/KsTraceGraph.hpp
+++ b/src/KsTraceGraph.hpp
@@ -29,7 +29,10 @@ public:
* Reimplemented handler for mouse wheel events. All mouse wheel
* events will be ignored.
*/
- void wheelEvent(QWheelEvent *evt) {evt->ignore();}
+ void wheelEvent(QWheelEvent *evt) {
+ if (QApplication::keyboardModifiers() != Qt::ControlModifier)
+ QScrollArea::wheelEvent(evt);
+ }
};
/**
diff --git a/src/KsTraceViewer.cpp b/src/KsTraceViewer.cpp
index 0e0e3d4e..afd5a859 100644
--- a/src/KsTraceViewer.cpp
+++ b/src/KsTraceViewer.cpp
@@ -9,7 +9,7 @@
* @brief KernelShark Trace Viewer widget.
*/
-// C++11
+// C++
#include <thread>
#include <future>
#include <queue>
@@ -50,11 +50,10 @@ void KsTableView::scrollTo(const QModelIndex &index, ScrollHint hint)
/** Create a default (empty) Trace viewer widget. */
KsTraceViewer::KsTraceViewer(QWidget *parent)
-: QWidget(parent),
+: KsWidgetsLib::KsDataWidget(parent),
_view(this),
_model(this),
_proxyModel(this),
- _tableHeader(_model.header()),
_toolbar(this),
_labelSearch("Search: Column", this),
_labelGrFollows("Graph follows ", this),
@@ -72,7 +71,7 @@ KsTraceViewer::KsTraceViewer(QWidget *parent)
/* On the toolbar make two Combo boxes for the search settings. */
_toolbar.addWidget(&_labelSearch);
- _searchFSM._columnComboBox.addItems(_tableHeader);
+ _searchFSM._columnComboBox.addItems(_model.header());
/*
* Using the old Signal-Slot syntax because
@@ -163,6 +162,9 @@ void KsTraceViewer::loadData(KsDataStore *data)
_model.fill(data);
this->_resizeToContents();
+ _searchFSM._columnComboBox.clear();
+ _searchFSM._columnComboBox.addItems(_model.header());
+
this->setMinimumHeight(SCREEN_HEIGHT / 5);
}
@@ -172,8 +174,8 @@ void KsTraceViewer::setMarkerSM(KsDualMarkerSM *m)
QString styleSheetA, styleSheetB;
_mState = m;
- _model.setColors(_mState->markerA()._color,
- _mState->markerB()._color);
+ _model.setMarkerColors(_mState->markerA()._color,
+ _mState->markerB()._color);
/*
* Assign a property to State A of the Dual marker state machine. When
@@ -234,6 +236,7 @@ void KsTraceViewer::update(KsDataStore *data)
_data = data;
if (_mState->activeMarker()._isSet)
showRow(_mState->activeMarker()._pos, true);
+ _resizeToContents();
}
void KsTraceViewer::_onCustomContextMenu(const QPoint &point)
@@ -246,7 +249,7 @@ void KsTraceViewer::_onCustomContextMenu(const QPoint &point)
* of the row number in the source model.
*/
size_t row = _proxyModel.mapRowFromSource(i.row());
- KsQuickContextMenu menu(_data, row, _mState, this);
+ KsQuickContextMenu menu(_mState, _data, row, this);
/*
* Note that this slot was connected to the
@@ -290,7 +293,7 @@ void KsTraceViewer::_graphFollowsChanged(int state)
_graphFollows = (bool) state;
if (_graphFollows && row != KS_NO_ROW_SELECTED)
- emit select(row); // Send a signal to the Graph widget.
+ emit select(*_it); // Send a signal to the Graph widget.
}
void KsTraceViewer::_search()
@@ -459,7 +462,7 @@ void KsTraceViewer::clearSelection()
/** Switch the Dual marker. */
void KsTraceViewer::markSwitch()
{
- int row;
+ ssize_t row;
/* The state of the Dual marker has changed. Get the new active marker. */
DualMarkerState state = _mState->getState();
@@ -490,7 +493,7 @@ void KsTraceViewer::markSwitch()
* The index in the source model is used to retrieve the value
* of the row number in the proxy model.
*/
- size_t row =_mState->getMarker(state)._pos;
+ row =_mState->getMarker(state)._pos;
QModelIndex index =
_proxyModel.mapFromSource(_model.index(row, 0));
@@ -525,7 +528,7 @@ void KsTraceViewer::markSwitch()
*/
void KsTraceViewer::resizeEvent(QResizeEvent* event)
{
- int nColumns = _tableHeader.count();
+ int nColumns = _model.header().count();
int tableSize(0), viewSize, freeSpace;
_resizeToContents();
@@ -564,7 +567,7 @@ void KsTraceViewer::keyReleaseEvent(QKeyEvent *event)
void KsTraceViewer::_resizeToContents()
{
- int rows, columnSize, markRow = selectedRow();
+ int col, rows, columnSize, markRow = selectedRow();
_view.setVisible(false);
_view.resizeColumnsToContents();
@@ -579,13 +582,22 @@ void KsTraceViewer::_resizeToContents()
_view.clearSelection();
/*
- * Because of some unknown reason the first column doesn't get
+ * Because of some unknown reason some of the columns doesn't get
* resized properly by the code above. We will resize this
* column by hand.
*/
+ col = KsViewModel::TRACE_VIEW_COL_STREAM;
+ columnSize = STRING_WIDTH(_model.header()[col]) + FONT_WIDTH;
+ _view.setColumnWidth(col, columnSize);
+
+ col = KsViewModel::TRACE_VIEW_COL_CPU;
+ columnSize = STRING_WIDTH(_model.header()[col]) + FONT_WIDTH * 2;
+ _view.setColumnWidth(col, columnSize);
+
+ col = KsViewModel::TRACE_VIEW_COL_INDEX;
rows = _model.rowCount({});
columnSize = STRING_WIDTH(QString("%1").arg(rows)) + FONT_WIDTH;
- _view.setColumnWidth(0, columnSize);
+ _view.setColumnWidth(col, columnSize);
}
//! @cond Doxygen_Suppress
@@ -598,7 +610,16 @@ size_t KsTraceViewer::_searchItems()
{
int column = _searchFSM._columnComboBox.currentIndex();
QString searchText = _searchFSM._searchLineEdit.text();
- int count, dataRow;
+ int count, dataRow, columnIndex = column;
+
+ if (_model.singleStream()) {
+ /*
+ * If only one Data stream (file) is loaded, the first column
+ * (TRACE_VIEW_COL_STREAM) is not shown. The column index has
+ * to be corrected.
+ */
+ ++columnIndex;
+ }
if (searchText.isEmpty()) {
/*
@@ -620,8 +641,8 @@ size_t KsTraceViewer::_searchItems()
} else {
_searchFSM.handleInput(sm_input_t::Start);
- if (column == KsViewModel::TRACE_VIEW_COL_INFO ||
- column == KsViewModel::TRACE_VIEW_COL_LAT)
+ if (columnIndex == KsViewModel::TRACE_VIEW_COL_INFO ||
+ columnIndex == KsViewModel::TRACE_VIEW_COL_AUX)
_searchItemsST();
else
_searchItemsMT();
@@ -761,7 +782,7 @@ void KsTraceViewer::_searchItemsMT()
};
for (int i = 0; i < mapList.size(); ++i)
- if ( mapList[i].count()) {
+ if (mapList[i].count()) {
queue.push(std::make_pair(i, mapList[i].front()));
mapList[i].pop_front();
}
diff --git a/src/KsTraceViewer.hpp b/src/KsTraceViewer.hpp
index 6080d0dc..f3979a64 100644
--- a/src/KsTraceViewer.hpp
+++ b/src/KsTraceViewer.hpp
@@ -20,6 +20,7 @@
#include "KsModels.hpp"
#include "KsSearchFSM.hpp"
#include "KsDualMarker.hpp"
+#include "KsWidgetsLib.hpp"
/**
* Table View class, needed in order to reimplemented the handler for mouse
@@ -42,7 +43,7 @@ public:
* The KsTraceViewer class provides a widget for browsing in the trace data
* shown in a text form.
*/
-class KsTraceViewer : public QWidget
+class KsTraceViewer : public KsWidgetsLib::KsDataWidget
{
Q_OBJECT
public:
@@ -74,6 +75,12 @@ public:
void update(KsDataStore *data);
+ /** Update the color scheme used by the model. */
+ void loadColors()
+ {
+ _model.loadColors();
+ }
+
signals:
/** Signal emitted when new row is selected. */
void select(size_t);
@@ -82,7 +89,7 @@ signals:
* This signal is used to re-emitted the addTaskPlot signal of the
* KsQuickContextMenu.
*/
- void addTaskPlot(int pid);
+ void addTaskPlot(int sd, int pid);
/**
* This signal is used to re-emitted the deselect signal of the
@@ -99,8 +106,6 @@ private:
KsFilterProxyModel _proxyModel;
- QStringList _tableHeader;
-
QToolBar _toolbar;
QLabel _labelSearch, _labelGrFollows;