From 1e4d40aaf71469255409227d3c7105b199effcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 11:28:54 +0100 Subject: Speed up QmlGraphicsItem construction. It's much faster to just initalize the flags in the constructor of QmlGraphicsItemPrivate than doing a full blown QGraphicsItem::setFlags. We can perfectly do this because QmlGraphicsItem does not listen to any itemChange events related to those flags. Reviewed-by: Aaron Kennedy --- src/declarative/graphicsitems/qmlgraphicsitem_p.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index ca850f3..91d2119 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -116,6 +116,12 @@ public: smooth(false), keyHandler(0), width(0), height(0), implicitWidth(0), implicitHeight(0) { + QGraphicsItemPrivate::acceptedMouseButtons = 0; + QGraphicsItemPrivate::flags = QGraphicsItem::GraphicsItemFlags( + QGraphicsItem::ItemHasNoContents + | QGraphicsItem::ItemIsFocusable + | QGraphicsItem::ItemNegativeZStacksBehindParent); + } void init(QmlGraphicsItem *parent) @@ -125,10 +131,6 @@ public: if (parent) q->setParentItem(parent); _baselineOffset.invalidate(); - q->setAcceptedMouseButtons(Qt::NoButton); - q->setFlags(QGraphicsItem::ItemHasNoContents | - QGraphicsItem::ItemIsFocusable | - QGraphicsItem::ItemNegativeZStacksBehindParent); mouseSetsFocus = false; } -- cgit v0.12