aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-01-14 22:50:08 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-15 14:47:44 +1300
commit054521d3a10f4ef14ecb5e50a395f7496d6dedae (patch)
treeab7e551dcdbd5d927e26ae8813b1ad943953a54b
parent6a1a6c82bfbbc455f2c0c9ec85216f248b3152b6 (diff)
downloadsubsurface-054521d3a10f4ef14ecb5e50a395f7496d6dedae.tar.gz
Reduce the amount of calls to create the background on the ToolTip
We were deleting / recreating the graphics background item for *every* mouse movement. Now we are just creating the painter path; no more allocations / desalocations, adding, removing from the scene. This should make things a tiny bit faster. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/divetooltipitem.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp
index fc76e50dc..790c222fd 100644
--- a/qt-ui/profile/divetooltipitem.cpp
+++ b/qt-ui/profile/divetooltipitem.cpp
@@ -60,11 +60,8 @@ void ToolTipItem::setRect(const QRectF &r)
if( r == rectangle ) {
return;
}
- delete background;
rectangle = r;
- setBrush(QBrush(Qt::white));
- setPen(QPen(Qt::black, 0.5));
// Creates a 2pixels border
QPainterPath border;
@@ -75,17 +72,7 @@ void ToolTipItem::setRect(const QRectF &r)
QPainterPath bg;
bg.addRoundedRect(-1, -1, rectangle.width() + 3, rectangle.height() + 4, 3, 3);
- QColor c = QColor(Qt::black);
- c.setAlpha(155);
-
- QGraphicsPathItem *b = new QGraphicsPathItem(bg, this);
- b->setFlag(ItemStacksBehindParent);
- b->setFlag(ItemIgnoresTransformations);
- b->setBrush(c);
- b->setPen(QPen(QBrush(Qt::transparent), 0));
- b->setZValue(-10);
- background = b;
-
+ background->setPath(bg);
updateTitlePosition();
}
@@ -158,6 +145,16 @@ ToolTipItem::ToolTipItem(QGraphicsItem *parent) : QGraphicsPathItem(parent),
entryToolTip.first = NULL;
entryToolTip.second = NULL;
setFlags(ItemIgnoresTransformations | ItemIsMovable | ItemClipsChildrenToShape);
+
+ QColor c = QColor(Qt::black);
+ c.setAlpha(155);
+ background = new QGraphicsPathItem(this);
+ background->setFlag(ItemStacksBehindParent);
+ background->setFlag(ItemIgnoresTransformations);
+ background->setBrush(c);
+ background->setPen(QPen(QBrush(Qt::transparent), 0));
+ background->setZValue(-10);
+
updateTitlePosition();
setZValue(99);
@@ -171,6 +168,9 @@ ToolTipItem::ToolTipItem(QGraphicsItem *parent) : QGraphicsPathItem(parent),
title->setFlag(ItemIgnoresTransformations);
title->setPen(QPen(Qt::white, 1));
title->setBrush(Qt::white);
+
+ setBrush(QBrush(Qt::white));
+ setPen(QPen(Qt::black, 0.5));
}
ToolTipItem::~ToolTipItem()