From: Joel Holdsworth Date: Sat, 20 Dec 2014 11:58:16 +0000 (+0000) Subject: Replaced use of QFontMetrics::boundingRect with height() and ascent() X-Git-Tag: pulseview-0.3.0~337 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c009650038207adcb66938170cbeb36bdf9ed63f;p=pulseview.git Replaced use of QFontMetrics::boundingRect with height() and ascent() --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 5bb73f63..9b2be1d5 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -261,9 +261,7 @@ void Ruler::draw_hover_mark(QPainter &p) int Ruler::calculate_text_height() const { - QFontMetrics fm(font()); - return fm.boundingRect(0, 0, INT_MAX, INT_MAX, - Qt::AlignLeft | Qt::AlignTop, "8").height(); + return QFontMetrics(font()).ascent(); } void Ruler::hover_point_changed() diff --git a/pv/view/timemarker.cpp b/pv/view/timemarker.cpp index 39966467..4b8d2b52 100644 --- a/pv/view/timemarker.cpp +++ b/pv/view/timemarker.cpp @@ -87,7 +87,7 @@ QRectF TimeMarker::label_rect(const QRectF &rect) const QFontMetrics m(QApplication::font()); const float text_width = max(m.boundingRect(get_text()).size().width(), ArrowSize); - const float text_height = m.boundingRect("Tg").size().height(); + const float text_height = m.height(); const QSizeF label_size( text_width + View::LabelPadding.width() * 2, diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 8411612b..24f97fb7 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -149,8 +149,7 @@ QRectF Trace::label_rect(const QRectF &rect) const QFontMetrics m(QApplication::font()); const QSize text_size( - m.boundingRect(QRect(), 0, name_).width(), - m.boundingRect(QRect(), 0, "Tg").height()); + m.boundingRect(QRect(), 0, name_).width(), m.height()); const QSizeF label_size( text_size.width() + View::LabelPadding.width() * 2, ceilf((text_size.height() + View::LabelPadding.height() * 2) / 2) * 2); diff --git a/pv/view/viewitempaintparams.cpp b/pv/view/viewitempaintparams.cpp index b6a17925..83dda4e5 100644 --- a/pv/view/viewitempaintparams.cpp +++ b/pv/view/viewitempaintparams.cpp @@ -42,8 +42,7 @@ QFont ViewItemPaintParams::font() } int ViewItemPaintParams::text_height() { - QFontMetrics m(font()); - return m.boundingRect(QRect(), 0, "Tg").height(); + return QFontMetrics(font()).height(); } } // namespace view