]> sigrok.org Git - pulseview.git/commitdiff
DecodeTrace: Turn row_height and text_height into class members
authorSoeren Apel <redacted>
Tue, 11 Nov 2014 20:27:13 +0000 (21:27 +0100)
committerUwe Hermann <redacted>
Thu, 13 Nov 2014 19:16:53 +0000 (20:16 +0100)
pv/view/decodetrace.cpp
pv/view/decodetrace.h

index c8a20dc3c9c6cf7eb3888080351e624ba38349c7..61653658e47182eeb86fe236f50acb0e74ddbb3a 100644 (file)
@@ -116,6 +116,8 @@ DecodeTrace::DecodeTrace(pv::SigSession &session,
                decoder_stack->stack().front()->decoder()->name)),
        _session(session),
        _decoder_stack(decoder_stack),
+       _text_height(0),
+       _row_height(0),
        _delete_mapper(this),
        _show_hide_mapper(this)
 {
@@ -178,9 +180,9 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
                samples_per_pixel, 0.0);
 
        QFontMetrics m(QApplication::font());
-       const int text_height =  m.boundingRect(QRect(), 0, "Tg").height();
-       const int annotation_height = (text_height * 5) / 4;
-       const int row_height = (text_height * 6) / 4;
+       _text_height = m.boundingRect(QRect(), 0, "Tg").height();
+       _row_height = (_text_height * 6) / 4;
+       const int annotation_height = (_text_height * 5) / 4;
 
        assert(_decoder_stack);
        const QString err = _decoder_stack->error_message();
@@ -218,7 +220,7 @@ void DecodeTrace::paint_mid(QPainter &p, int left, int right)
                                        annotation_height, left, right,
                                        samples_per_pixel, pixels_offset, y,
                                        base_colour);
-                       y += row_height;
+                       y += _row_height;
 
                        _cur_row_headings.push_back(row.title());
                }
@@ -235,13 +237,11 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
 
        (void)right;
 
-       QFontMetrics m(QApplication::font());
-       const int text_height =  m.boundingRect(QRect(), 0, "Tg").height();
-       const int row_height = (text_height * 6) / 4;
+       assert(_row_height);
 
        for (size_t i = 0; i < _cur_row_headings.size(); i++)
        {
-               const int y = i * row_height + get_y();
+               const int y = i * _row_height + get_y();
 
                p.setPen(QPen(Qt::NoPen));
                p.setBrush(QApplication::palette().brush(QPalette::WindowText));
@@ -256,8 +256,8 @@ void DecodeTrace::paint_fore(QPainter &p, int left, int right)
                        p.drawPolygon(points, countof(points));
                }
 
-               const QRect r(left + ArrowSize * 2, y - row_height / 2,
-                       right - left, row_height);
+               const QRect r(left + ArrowSize * 2, y - _row_height / 2,
+                       right - left, _row_height);
                const QString h(_cur_row_headings[i]);
                const int f = Qt::AlignLeft | Qt::AlignVCenter |
                        Qt::TextDontClip;
index b93aa01f0a4cc8f69cfd44eb9ab37260b448db5d..420961ad1c9f4d83a1d873f3740aac9cb6ce1d63 100644 (file)
@@ -180,6 +180,7 @@ private:
        std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
 
        std::vector<QString> _cur_row_headings;
+       int _text_height, _row_height;
 
        QSignalMapper _delete_mapper, _show_hide_mapper;
 };