aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2022-03-16 15:26:00 +0200
committerYordan Karadzhov (VMware) <y.karadz@gmail.com>2022-03-17 18:31:44 +0200
commit027ccb9b4e2fd5fde2a41a4e5ff1931ddf0df9d5 (patch)
tree16de49cad811bc504c3042f8b520d954041e3ba9
parentb5ad5393ebf014db40a565e2e64b9dcd88246d8b (diff)
downloadkernel-shark-027ccb9b4e2fd5fde2a41a4e5ff1931ddf0df9d5.tar.gz
kernel-shark: CPU plots dialog ease spotting empty CPUs
The CPU plots dialog will show only the ones with content. A "hide empty" checkbox is added, that by default is checked. If it is unchecked, then all the CPUs would show up. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=215677 Tested-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
-rw-r--r--src/KsWidgetsLib.cpp26
-rw-r--r--src/KsWidgetsLib.hpp7
2 files changed, 30 insertions, 3 deletions
diff --git a/src/KsWidgetsLib.cpp b/src/KsWidgetsLib.cpp
index e30bf270..7b3192dd 100644
--- a/src/KsWidgetsLib.cpp
+++ b/src/KsWidgetsLib.cpp
@@ -906,12 +906,35 @@ void KsCheckBoxTreeWidget::_verify()
* @param parent: The parent of this widget.
*/
KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *parent)
-: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent)
+: KsCheckBoxTreeWidget(stream->stream_id, "CPUs", parent),
+ _hideEmpty("hide empty")
{
int height(FONT_HEIGHT * 1.5);
KsPlot::ColorTable colors;
QString style;
+ _hideEmpty.setCheckState(Qt::Checked);
+ _tb.addSeparator();
+ _tb.addWidget(&_hideEmpty);
+
+ auto lamHideEmpty = [this, stream] (bool hide) {
+ QTreeWidgetItem *item;
+ bool isIdle;
+
+ for(int cpu = 0; cpu < stream->n_cpus; ++cpu) {
+ item = _tree.topLevelItem(cpu);
+ if (hide) {
+ isIdle = kshark_hash_id_find(stream->idle_cpus, cpu);
+ item->setHidden(isIdle);
+ } else {
+ item->setHidden(false);
+ }
+ }
+ };
+
+ connect(&_hideEmpty, &QCheckBox::clicked,
+ lamHideEmpty);
+
style = QString("QTreeView::item { height: %1 ;}").arg(height);
_tree.setStyleSheet(style);
@@ -934,6 +957,7 @@ KsCPUCheckBoxWidget::KsCPUCheckBoxWidget(kshark_data_stream *stream, QWidget *pa
_cb[i] = cpuItem;
}
+ lamHideEmpty(true);
_adjustSize();
}
diff --git a/src/KsWidgetsLib.hpp b/src/KsWidgetsLib.hpp
index 6ec2bd17..2cc35353 100644
--- a/src/KsWidgetsLib.hpp
+++ b/src/KsWidgetsLib.hpp
@@ -275,10 +275,9 @@ public:
/** The user provided an input. The widget has been modified. */
bool _userInput;
-private:
+protected:
QToolBar _tb;
-protected:
/** Identifier of the Data stream for which the selection applies. */
int _sd;
@@ -544,6 +543,10 @@ struct KsCPUCheckBoxWidget : public KsCheckBoxTreeWidget
KsCPUCheckBoxWidget(kshark_data_stream *stream,
QWidget *parent = nullptr);
+
+private:
+ /** The "hide empty" checkbox. */
+ QCheckBox _hideEmpty;
};
/**