mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Reduce the number of calls to boundingRect
There are a few calculations that go on boundingRect that can be avoided if we simply store the result. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
85a3cbf8af
commit
85909ca28d
1 changed files with 9 additions and 7 deletions
|
@ -89,15 +89,17 @@ void ToolTipItem::expand()
|
||||||
|
|
||||||
double width = 0, height = title->boundingRect().height() + iconMetrics.spacing;
|
double width = 0, height = title->boundingRect().height() + iconMetrics.spacing;
|
||||||
Q_FOREACH (const ToolTip& t, toolTips) {
|
Q_FOREACH (const ToolTip& t, toolTips) {
|
||||||
if (t.second->boundingRect().width() > width)
|
QRectF sRect = t.second->boundingRect();
|
||||||
width = t.second->boundingRect().width();
|
if (sRect.width() > width)
|
||||||
height += t.second->boundingRect().height();
|
width = sRect.width();
|
||||||
|
height += sRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entryToolTip.first) {
|
if (entryToolTip.first) {
|
||||||
if (entryToolTip.second->boundingRect().width() > width)
|
QRectF sRect = entryToolTip.second->boundingRect();
|
||||||
width = entryToolTip.second->boundingRect().width();
|
if (sRect.width() > width)
|
||||||
height += entryToolTip.second->boundingRect().height();
|
width = sRect.width();
|
||||||
|
height += sRect.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Left padding, Icon Size, space, right padding */
|
/* Left padding, Icon Size, space, right padding */
|
||||||
|
@ -166,7 +168,7 @@ void ToolTipItem::updateTitlePosition()
|
||||||
setRect(newRect);
|
setRect(newRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
title->setPos(boundingRect().width() / 2 - title->boundingRect().width() / 2 - 1, 0);
|
title->setPos(rect().width() / 2 - title->boundingRect().width() / 2 - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolTipItem::isExpanded() const
|
bool ToolTipItem::isExpanded() const
|
||||||
|
|
Loading…
Reference in a new issue