IO Graphs: Don't show unchecked graphs in legend

Change-Id: I0a9c4d967ee03a0a8dfc93f87dbe38e4e3a0404c
Reviewed-on: https://code.wireshark.org/review/10128
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2015-08-19 15:38:10 +02:00
parent 75f4ff727d
commit 950f1dde9e
2 changed files with 18 additions and 2 deletions

View File

@ -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<IOGraph *>();
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<IOGraph *>();
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) {

View File

@ -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();