@@ -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();
}
@@ -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;
};
/**
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 Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com> --- src/KsWidgetsLib.cpp | 26 +++++++++++++++++++++++++- src/KsWidgetsLib.hpp | 7 +++++-- 2 files changed, 30 insertions(+), 3 deletions(-)