From 950f1dde9e68c0e566357d270d8d2a91ea61def4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Wed, 19 Aug 2015 15:38:10 +0200 Subject: [PATCH] IO Graphs: Don't show unchecked graphs in legend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I0a9c4d967ee03a0a8dfc93f87dbe38e4e3a0404c Reviewed-on: https://code.wireshark.org/review/10128 Reviewed-by: Stig Bjørlykke --- ui/qt/io_graph_dialog.cpp | 19 +++++++++++++++++-- ui/qt/io_graph_dialog.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp index 3861168f09..ad1251b28d 100644 --- a/ui/qt/io_graph_dialog.cpp +++ b/ui/qt/io_graph_dialog.cpp @@ -684,7 +684,7 @@ void IOGraphDialog::updateLegend() for (int i = 0; i < ui->graphTreeWidget->topLevelItemCount(); i++) { QTreeWidgetItem *ti = ui->graphTreeWidget->topLevelItem(i); IOGraph *iog = NULL; - if (ti) { + if (ti && ti->checkState(name_col_) == Qt::Checked) { iog = ti->data(name_col_, Qt::UserRole).value(); vu_label_set.insert(iog->valueUnitLabel()); } @@ -707,7 +707,11 @@ void IOGraphDialog::updateLegend() IOGraph *iog = NULL; if (ti) { iog = ti->data(name_col_, Qt::UserRole).value(); - iog->addToLegend(); + if (ti->checkState(name_col_) == Qt::Checked) { + iog->addToLegend(); + } else { + iog->removeFromLegend(); + } } } iop->legend->setVisible(true); @@ -1745,6 +1749,17 @@ bool IOGraph::addToLegend() return false; } +bool IOGraph::removeFromLegend() +{ + if (graph_) { + return graph_->removeFromLegend(); + } + if (bars_) { + return bars_->removeFromLegend(); + } + return false; +} + double IOGraph::startOffset() { if (graph_ && graph_->keyAxis()->tickLabelType() == QCPAxis::ltDateTime && graph_->data()->size() > 0) { diff --git a/ui/qt/io_graph_dialog.h b/ui/qt/io_graph_dialog.h index a6ef6a6078..20c591fc43 100644 --- a/ui/qt/io_graph_dialog.h +++ b/ui/qt/io_graph_dialog.h @@ -78,6 +78,7 @@ public: unsigned int movingAveragePeriod() { return moving_avg_period_; } void setInterval(int interval); bool addToLegend(); + bool removeFromLegend(); QCPGraph *graph() { return graph_; } QCPBars *bars() { return bars_; } double startOffset();