From f7b44b64b0e3a97dd45d5aebd0ba9cd74a634f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 1 Jan 2021 12:51:39 +0100 Subject: [PATCH] Fixed broken graph info layout --- src/GUI/infoitem.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/GUI/infoitem.cpp b/src/GUI/infoitem.cpp index 54294170..2904ee74 100644 --- a/src/GUI/infoitem.cpp +++ b/src/GUI/infoitem.cpp @@ -18,9 +18,9 @@ void InfoItem::updateBoundingRect() for (QList >::const_iterator i = _list.constBegin(); i != _list.constEnd(); i++) { - width += fm.boundingRect(i->key() + ": ").width(); - width += fm.boundingRect(i->value()).width() - + ((i == _list.constEnd() - 1) ? 0 : PADDING); + width += fm.horizontalAdvance(i->key() + ": " + i->value()); + if (i != _list.constEnd() - 1) + width += PADDING; } _boundingRect = QRectF(0, 0, width, _list.isEmpty() ? 0 : fm.height()); @@ -39,12 +39,11 @@ void InfoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, for (QList >::const_iterator i = _list.constBegin(); i != _list.constEnd(); i++) { - painter->drawText(width, fm.height() - fm.descent(), i->key() + ": "); - width += fm.boundingRect(i->key() + ": ").width(); - painter->drawText(width, fm.height() - fm.descent(), i->value()); - width += fm.boundingRect(i->value()).width() - + ((i == _list.constEnd() - 1) ? 0 : PADDING); + QString text(i->key() + ": " + i->value()); + painter->drawText(width, fm.height() - fm.descent(), text); + width += fm.horizontalAdvance(text); if (i != _list.constEnd() - 1) { + width += PADDING; painter->save(); painter->setPen(Qt::gray); painter->drawLine(width - PADDING/2, fm.descent(),