From: Soeren Apel Date: Fri, 14 Nov 2014 15:51:22 +0000 (+0100) Subject: Fix bug #477 by keeping track of visible rows, not just titles X-Git-Tag: pulseview-0.3.0~498 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c294543f8df3b3c90fa613c8198506aea68e91e7;p=pulseview.git Fix bug #477 by keeping track of visible rows, not just titles --- diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 5b1999cc..e290e55f 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -184,7 +184,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) assert(_decoder_stack); const vector rows(_decoder_stack->get_visible_rows()); - _cur_row_headings.clear(); + _visible_rows.clear(); for (size_t i = 0; i < rows.size(); i++) { const Row &row = rows[i]; @@ -205,7 +205,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right) base_colour); y += _row_height; - _cur_row_headings.push_back(row.title()); + _visible_rows.push_back(rows[i]); } } @@ -221,7 +221,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) assert(_row_height); - for (size_t i = 0; i < _cur_row_headings.size(); i++) + for (size_t i = 0; i < _visible_rows.size(); i++) { const int y = i * _row_height + get_y(); @@ -240,7 +240,7 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right) const QRect r(left + ArrowSize * 2, y - _row_height / 2, right - left, _row_height); - const QString h(_cur_row_headings[i]); + const QString h(_visible_rows[i].title()); const int f = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextDontClip; @@ -559,7 +559,7 @@ bool DecodeTrace::hover_point_is_over_trace() // so we set trace.left to 1 to exclude this. QRect trace(1, get_y() - (_row_height/2), - _view->width(), _row_height * _cur_row_headings.size()); + _view->width(), _row_height * _visible_rows.size()); // Note: We don't need to check for _row_height being 0 here but // we do it anyway to be more robust. @@ -576,9 +576,7 @@ int DecodeTrace::get_row_at_hover_point() QPoint hp = _view->hover_point(); int hover_row = (hp.y() - get_y() + (_row_height/2)) / _row_height; - const vector rows(_decoder_stack->get_visible_rows()); - - return min(hover_row, (int)rows.size() - 1); + return min(hover_row, (int)_visible_rows.size() - 1); } const QString DecodeTrace::get_annotation_at_hover_point() @@ -590,14 +588,12 @@ const QString DecodeTrace::get_annotation_at_hover_point() pair sample_range = get_sample_range(hp.x(), hp.x() + 1); - assert(_decoder_stack); - const vector rows(_decoder_stack->get_visible_rows()); - const int hover_row = get_row_at_hover_point(); vector annotations; - _decoder_stack->get_annotation_subset(annotations, rows[hover_row], + assert(_decoder_stack); + _decoder_stack->get_annotation_subset(annotations, _visible_rows[hover_row], sample_range.first, sample_range.second); return (annotations.empty()) ? diff --git a/pv/view/decodetrace.h b/pv/view/decodetrace.h index e5a9c0b6..9e0faace 100644 --- a/pv/view/decodetrace.h +++ b/pv/view/decodetrace.h @@ -30,6 +30,7 @@ #include #include +#include struct srd_channel; struct srd_decoder; @@ -203,7 +204,7 @@ private: std::list _channel_selectors; std::vector _decoder_forms; - std::vector _cur_row_headings; + std::vector _visible_rows; int _text_height, _row_height; QSignalMapper _delete_mapper, _show_hide_mapper;