kernel-shark-qt: Rearrange the "Filter" top menu
PATCH 1/4 kernel-shark-qt: Rearrange the "Filter" top menu
The "Filter" top menu contains only "Show Task" and "Show CPU" menu actions ("Hide" versions are removed). The code that adds the "Hide" actions is only commented out, because we may change our opinion in the future.
--- kernel-shark-qt/src/KsMainWindow.cpp | 42 ++++++++++++++++++++++++++-- kernel-shark-qt/src/KsMainWindow.hpp | 4 +++ 2 files changed, 44 insertions(+), 2 deletions(-)
kernel-shark-qt/src/KsMainWindow.cpp +40 -2
@@ -54,6 +54,7 @@ KsMainWindow::KsMainWindow(QWidget *parent) _showEventsAction("Show events", this), _showTasksAction("Show tasks", this), _hideTasksAction("Hide tasks", this), + _showCPUsAction("Show CPUs", this), _hideCPUsAction("Hide CPUs", this), _advanceFilterAction("Advance Filtering", this), _clearAllFilters("Clear all filters", this),
@@ -208,6 +209,9 @@ void KsMainWindow::_createActions() connect(&_hideTasksAction, &QAction::triggered, this, &KsMainWindow::_hideTasks); + connect(&_showCPUsAction, &QAction::triggered, + this, &KsMainWindow::_showCPUs); + connect(&_hideCPUsAction, &QAction::triggered, this, &KsMainWindow::_hideCPUs);
@@ -322,8 +326,9 @@ void KsMainWindow::_createMenus() filter->addAction(&_showEventsAction); filter->addAction(&_showTasksAction); - filter->addAction(&_hideTasksAction); - filter->addAction(&_hideCPUsAction); +// filter->addAction(&_hideTasksAction); + filter->addAction(&_showCPUsAction); +// filter->addAction(&_hideCPUsAction); filter->addAction(&_advanceFilterAction); filter->addAction(&_clearAllFilters);
@@ -621,6 +626,39 @@ void KsMainWindow::_hideTasks() dialog->show(); } +void KsMainWindow::_showCPUs() +{ + 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->show_cpu_filter || + !kshark_ctx->show_cpu_filter->count) { + cpu_cbd->setDefault(true); + } 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->show_cpu_filter, i)) + v[i] = true; + } + + cpu_cbd->set(v); + } + + connect(dialog, &KsCheckBoxDialog::apply, + &_data, &KsDataStore::applyPosCPUFilter); + + dialog->show(); +} + void KsMainWindow::_hideCPUs() { kshark_context *kshark_ctx(nullptr);
kernel-shark-qt/src/KsMainWindow.hpp +4 -0
@@ -120,6 +120,8 @@ private: QAction _hideTasksAction; + QAction _showCPUsAction; + QAction _hideCPUsAction; QAction _advanceFilterAction;
@@ -173,6 +175,8 @@ private: void _hideTasks(); + void _showCPUs(); + void _hideCPUs(); void _advancedFiltering();
Signature · 1 line
2.17.1
PATCH 2/4 kernel-shark-qt: Cosmetic modifications in KsQuickContextMenu
This patch does the following minor modifications in KsQuickContextMenu:
1. Removes the "Apply to list/graph" check-boxes.
2. Swaps the position of the Show / Hide actions
3. Adds "clear all filters" action.
The code that adds the check-boxes is commented out, because we may change our opinion in the future.
--- kernel-shark-qt/src/KsQuickContextMenu.cpp | 94 ++++++++++++---------- kernel-shark-qt/src/KsQuickContextMenu.hpp | 4 +- 2 files changed, 54 insertions(+), 44 deletions(-)
kernel-shark-qt/src/KsQuickContextMenu.cpp +51 -43
@@ -62,7 +62,7 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, _addTaskPlotAction(this), _removeCPUPlotAction(this), _removeTaskPlotAction(this), - _deselectAction(this) + _clearAllFilters(this) { typedef void (KsQuickContextMenu::*mfp)(); QString taskName, parentName, descr;
@@ -87,37 +87,45 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, parentName = parent->metaObject()->className(); - addSection("Pointer menu"); + addSection("Pointer filter menu"); + +// if (parentName == "KsTraceViewer" && +// list = dynamic_cast<KsTraceViewer *>(parent))) { +// _graphSyncCBox = +// KsUtils::addCheckBoxToMenu(this, "Apply filters to Graph"); +// +// connect(_graphSyncCBox, &QCheckBox::stateChanged, +// &KsUtils::graphFilterSync); +// +// /* +// * By defauls the filters will be append to the List (Table) +// * only. +// */ +// KsUtils::listFilterSync(true); +// KsUtils::graphFilterSync(false); +// _graphSyncCBox->setChecked(false); +// } + +// if (parentName == "KsTraceGraph" && +// (graphs = dynamic_cast<KsTraceGraph *>(parent))) { +// _listSyncCBox = +// KsUtils::addCheckBoxToMenu(this, "Apply filters to List"); +// +// connect(_listSyncCBox, &QCheckBox::stateChanged, +// &KsUtils::listFilterSync); +// +// /* By defauls the filters will be append to the Graph only. */ +// KsUtils::graphFilterSync(true); +// KsUtils::listFilterSync(false); +// _listSyncCBox->setChecked(false); +// } - if (parentName == "KsTraceViewer") { - _graphSyncCBox = - KsUtils::addCheckBoxToMenu(this, "Apply filters to Graph"); - - connect(_graphSyncCBox, &QCheckBox::stateChanged, - &KsUtils::graphFilterSync); - - /* - * By defauls the filters will be append to the List (Table) - * only. - */ - KsUtils::listFilterSync(true); - KsUtils::graphFilterSync(false); - _graphSyncCBox->setChecked(false); - } - - if (parentName == "KsTraceGraph" && - (graphs = dynamic_cast<KsTraceGraph *>(parent))) { - _listSyncCBox = - KsUtils::addCheckBoxToMenu(this, "Apply filters to List"); - - connect(_listSyncCBox, &QCheckBox::stateChanged, - &KsUtils::listFilterSync); - - /* By defauls the filters will be append to the Graph only. */ - KsUtils::graphFilterSync(true); - KsUtils::listFilterSync(false); - _listSyncCBox->setChecked(false); - } + descr = "Show task ["; + descr += taskName; + descr += "-"; + descr += QString("%1").arg(pid); + descr += "] only"; + lamAddAction(&_showTaskAction, &KsQuickContextMenu::_showTask); descr = "Hide task ["; descr += taskName;
@@ -126,30 +134,30 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, descr += "]"; lamAddAction(&_hideTaskAction, &KsQuickContextMenu::_hideTask); - descr = "Show task ["; - descr += taskName; - descr += "-"; - descr += QString("%1").arg(pid); + descr = "Show event ["; + descr += kshark_get_event_name_easy(_data->rows()[_row]); descr += "] only"; - lamAddAction(&_showTaskAction, &KsQuickContextMenu::_showTask); + lamAddAction(&_showEventAction, &KsQuickContextMenu::_showEvent); descr = "Hide event ["; descr += kshark_get_event_name_easy(_data->rows()[_row]); descr += "]"; lamAddAction(&_hideEventAction, &KsQuickContextMenu::_hideEvent); - descr = "Show event ["; - descr += kshark_get_event_name_easy(_data->rows()[_row]); - descr += "] only"; - lamAddAction(&_showEventAction, &KsQuickContextMenu::_showEvent); + if (parentName == "KsTraceViewer") { + descr = QString("Show CPU [%1] only").arg(cpu); + lamAddAction(&_showCPUAction, &KsQuickContextMenu::_showCPU); + } descr = QString("Hide CPU [%1]").arg(_data->rows()[_row]->cpu); lamAddAction(&_hideCPUAction, &KsQuickContextMenu::_hideCPU); - if (parentName == "KsTraceViewer") { - descr = QString("Show CPU [%1] only").arg(cpu); - lamAddAction(&_showCPUAction, &KsQuickContextMenu::_showCPU); + descr = "Clear all filters"; + lamAddAction(&_clearAllFilters, &KsQuickContextMenu::_clearFilters); + addSection("Pointer plot menu"); + + if (parentName == "KsTraceViewer") { descr = "Add ["; descr += taskName; descr += "-";
kernel-shark-qt/src/KsQuickContextMenu.hpp +3 -1
@@ -85,6 +85,8 @@ private: QVector<int> _getFilterVector(tracecmd_filter_id *filter, int newId); + void _clearFilters() {_data->clearAllFilters();} + KsDataStore *_data; size_t _row;
@@ -105,7 +107,7 @@ private: QAction _removeTaskPlotAction; - QAction _deselectAction; + QAction _clearAllFilters; }; /**
Signature · 1 line
2.17.1
Re: [PATCH 2/4] kernel-shark-qt: Cosmetic modifications in KsQuickContextMenu
Quoted 1 line · On Fri, 4 Jan 2019 19:57:52 +0000 Yordan Karadzhov <[email protected]>…
This patch does the following minor modifications in
FYI, it is looked down to say "This patch" or "This commit" as people know what it is. I've seen maintainers get really annoyed by it. I don't care as much, but I'd like to keep the same requirements as upstream Linux kernel.
Quoted 4 lines
KsQuickContextMenu:
1. Removes the "Apply to list/graph" check-boxes.
2. Swaps the position of the Show / Hide actions
3. Adds "clear all filters" action.
These should each be a separate patch (one patch that does one thing).
Quoted 3 lines
The code that adds the check-boxes is commented out, because we may change our opinion in the future.
Again, lets refrain from commenting out code, and just delete it. git history will archive it for us ;-)
-- Steve
Quoted 24 lines
Signed-off-by Yordan Karadzhov <[email protected]>--- kernel-shark-qt/src/KsQuickContextMenu.cpp | 94 ++++++++++++---------- kernel-shark-qt/src/KsQuickContextMenu.hpp | 4 +- 2 files changed, 54 insertions(+), 44 deletions(-)kernel-shark-qt/src/KsQuickContextMenu.cpp +1
-1@@ -62,7 +62,7 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, _addTaskPlotAction(this), _removeCPUPlotAction(this), _removeTaskPlotAction(this), - _deselectAction(this) + _clearAllFilters(this) { typedef void (KsQuickContextMenu::*mfp)(); QString taskName, parentName, descr;@@ -87,37 +87,45 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row, parentName = parent->metaObject()->className();
PATCH 3/4 kernel-shark-qt: Make the selection in the Table less touchy
In reply to Yordan KaradzhovThis patch aims to make the selection in the table by using the mouse more intuitive (less touchy). First of all, it disables the auto-scrolling in horizontal direction. In addition to this, it makes sure that all columns of the table have proper sizes when the main window gets resized by the user.
--- kernel-shark-qt/src/KsTraceViewer.cpp | 18 ++++++++++++++++++ kernel-shark-qt/src/KsTraceViewer.hpp | 2 ++ 2 files changed, 20 insertions(+)
kernel-shark-qt/src/KsTraceViewer.cpp +18 -0
@@ -30,6 +30,23 @@ void KsTableView::mousePressEvent(QMouseEvent *e) { QTableView::mousePressEvent(e); } +/** + * Reimplemented the handler for Auto-scrolling. With this we disable + * the Horizontal Auto-scrolling. + */ +void KsTableView::scrollTo(const QModelIndex &index, ScrollHint hint) +{ + int bottomMargin(2); + + if (hint == QAbstractItemView::EnsureVisible && + index.row() > indexAt(rect().topLeft()).row() && + index.row() < indexAt(rect().bottomLeft()).row() - bottomMargin) + return; + + QTableView::scrollTo(index, hint); +} + + /** Create a default (empty) Trace viewer widget. */ KsTraceViewer::KsTraceViewer(QWidget *parent) : QWidget(parent),
@@ -588,6 +605,7 @@ void KsTraceViewer::resizeEvent(QResizeEvent* event) int nColumns = _tableHeader.count(); int tableSize(0), viewSize, freeSpace; + _resizeToContents(); for (int c = 0; c < nColumns; ++c) { tableSize += _view.columnWidth(c); }
kernel-shark-qt/src/KsTraceViewer.hpp +2 -0
@@ -33,6 +33,8 @@ public: : QTableView(parent) {}; void mousePressEvent(QMouseEvent *event) override; + + void scrollTo(const QModelIndex &index, ScrollHint hint) override; }; /**
Signature · 1 line
2.17.1
PATCH 4/4 kernel-shark-qt: Do not auto-scrolling when the marker switches
In reply to Yordan KaradzhovIn some cases, the auto-scrolling (inside the table) to the position of the marker, when the user switches between MarkerA and MarkerB can be very annoying. This patch disables this vertical auto-scrolling. Jumping to the position of the Active marker is still possible, but the user has to do a second click on the MarkerA/MarkerB button.
--- kernel-shark-qt/src/KsTraceViewer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel-shark-qt/src/KsTraceViewer.cpp +7 -2
@@ -578,13 +578,18 @@ void KsTraceViewer::markSwitch() */ size_t row =_mState->getMarker(state)._pos; - QModelIndex index = _proxyModel.mapFromSource(_model.index(row, 0)); + QModelIndex index = + _proxyModel.mapFromSource(_model.index(row, 0)); /* * The row of the active marker will be colored according to - * the assigned property of the current state of the Dual marker. + * the assigned property of the current state of the Dual + * marker. Auto-scrolling is temporarily disabled because we + * do not want to scroll to the position of the marker yet. */ + _view.setAutoScroll(false); _view.selectRow(index.row()); + _view.setAutoScroll(true); } else { _view.clearSelection(); }
Signature · 1 line
2.17.1
Quoted 4 lines · On Fri, 4 Jan 2019 19:57:51 +0000 Yordan Karadzhov <[email protected]>…
The "Filter" top menu contains only "Show Task" and "Show CPU" menu actions ("Hide" versions are removed). The code that adds the "Hide" actions is only commented out, because we may change our opinion in the future.
Let's avoid just commenting it out. I've done this before and just regretted it (it makes the code look messy).
If we decided to add it in the future, it's trivial to add those lines and not to mention, the code is archived in git.
-- Steve
Quoted 103 lines
Signed-off-by Yordan Karadzhov <[email protected]>--- kernel-shark-qt/src/KsMainWindow.cpp | 42 ++++++++++++++++++++++++++-- kernel-shark-qt/src/KsMainWindow.hpp | 4 +++ 2 files changed, 44 insertions(+), 2 deletions(-)kernel-shark-qt/src/KsMainWindow.cpp +40
-2@@ -54,6 +54,7 @@ KsMainWindow::KsMainWindow(QWidget *parent) _showEventsAction("Show events", this), _showTasksAction("Show tasks", this), _hideTasksAction("Hide tasks", this), + _showCPUsAction("Show CPUs", this), _hideCPUsAction("Hide CPUs", this), _advanceFilterAction("Advance Filtering", this), _clearAllFilters("Clear all filters", this),@@ -208,6 +209,9 @@ void KsMainWindow::_createActions() connect(&_hideTasksAction, &QAction::triggered, this, &KsMainWindow::_hideTasks); + connect(&_showCPUsAction, &QAction::triggered, + this, &KsMainWindow::_showCPUs); + connect(&_hideCPUsAction, &QAction::triggered, this, &KsMainWindow::_hideCPUs);@@ -322,8 +326,9 @@ void KsMainWindow::_createMenus() filter->addAction(&_showEventsAction); filter->addAction(&_showTasksAction); - filter->addAction(&_hideTasksAction); - filter->addAction(&_hideCPUsAction); +// filter->addAction(&_hideTasksAction); + filter->addAction(&_showCPUsAction); +// filter->addAction(&_hideCPUsAction); filter->addAction(&_advanceFilterAction); filter->addAction(&_clearAllFilters);@@ -621,6 +626,39 @@ void KsMainWindow::_hideTasks() dialog->show(); } +void KsMainWindow::_showCPUs() +{ + 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->show_cpu_filter || + !kshark_ctx->show_cpu_filter->count) { + cpu_cbd->setDefault(true); + } 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->show_cpu_filter, i)) + v[i] = true; + } + + cpu_cbd->set(v); + } + + connect(dialog, &KsCheckBoxDialog::apply, + &_data, &KsDataStore::applyPosCPUFilter); + + dialog->show(); +} + void KsMainWindow::_hideCPUs() { kshark_context *kshark_ctx(nullptr);kernel-shark-qt/src/KsMainWindow.hpp +4
-0@@ -120,6 +120,8 @@ private: QAction _hideTasksAction; + QAction _showCPUsAction; + QAction _hideCPUsAction; QAction _advanceFilterAction;@@ -173,6 +175,8 @@ private: void _hideTasks(); + void _showCPUs(); + void _hideCPUs(); void _advancedFiltering();
Quoted 20 lines · On Fri, 4 Jan 2019 16:25:08 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 20 lines
kernel-shark-qt/src/KsMainWindow.cpp | 42 ++++++++++++++++++++++++++-- kernel-shark-qt/src/KsMainWindow.hpp | 4 +++ 2 files changed, 44 insertions(+), 2 deletions(-)kernel-shark-qt/src/KsMainWindow.cpp +1
-0@@ -54,6 +54,7 @@ KsMainWindow::KsMainWindow(QWidget *parent) _showEventsAction("Show events", this), _showTasksAction("Show tasks", this), _hideTasksAction("Hide tasks", this), + _showCPUsAction("Show CPUs", this), _hideCPUsAction("Hide CPUs", this), _advanceFilterAction("Advance Filtering", this), _clearAllFilters("Clear all filters", this),@@ -208,6 +209,9 @@ void KsMainWindow::_createActions() connect(&_hideTasksAction, &QAction::triggered, this, &KsMainWindow::_hideTasks);
Quoted 3 lines
kernel-shark-qt/src/KsMainWindow.cpp void KsMainWindow::_createActions() · line 214
Quoted 3 lines
kernel-shark-qt/src/KsMainWindow.cpp +3
-0+ connect(&_showCPUsAction, &QAction::triggered, + this, &KsMainWindow::_showCPUs); +
We don't need to comment out the unused hideCPU/TasksAction, but we could add a comment that says that they are currently unused.
Quoted 5 lines
Quoted 5 lines
kernel-shark-qt/src/KsMainWindow.cpp +0
-0connect(&_hideCPUsAction, &QAction::triggered, this, &KsMainWindow::_hideCPUs);@@ -322,8 +326,9 @@ void KsMainWindow::_createMenus()
Quoted 7 lines
kernel-shark-qt/src/KsMainWindow.cpp void KsMainWindow::_createMenus() · line 331
Quoted 7 lines
kernel-shark-qt/src/KsMainWindow.cpp +3
-2filter->addAction(&_showEventsAction); filter->addAction(&_showTasksAction); - filter->addAction(&_hideTasksAction); - filter->addAction(&_hideCPUsAction); +// filter->addAction(&_hideTasksAction); + filter->addAction(&_showCPUsAction); +// filter->addAction(&_hideCPUsAction);
Commenting out code is messy. But adding comments about why functions are unused is fine.
-- Steve
Quoted 66 lines
Quoted 65 lines
kernel-shark-qt/src/KsMainWindow.cpp +33
-0filter->addAction(&_advanceFilterAction); filter->addAction(&_clearAllFilters);@@ -621,6 +626,39 @@ void KsMainWindow::_hideTasks() dialog->show(); } +void KsMainWindow::_showCPUs() +{ + 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->show_cpu_filter || + !kshark_ctx->show_cpu_filter->count) { + cpu_cbd->setDefault(true); + } 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->show_cpu_filter, i)) + v[i] = true; + } + + cpu_cbd->set(v); + } + + connect(dialog, &KsCheckBoxDialog::apply, + &_data, &KsDataStore::applyPosCPUFilter); + + dialog->show(); +} + void KsMainWindow::_hideCPUs() { kshark_context *kshark_ctx(nullptr);kernel-shark-qt/src/KsMainWindow.hpp +4
-0@@ -120,6 +120,8 @@ private: QAction _hideTasksAction; + QAction _showCPUsAction; + QAction _hideCPUsAction; QAction _advanceFilterAction;@@ -173,6 +175,8 @@ private: void _hideTasks(); + void _showCPUs(); + void _hideCPUs(); void _advancedFiltering();