summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h22
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp18
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp18
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners.cpp22
-rw-r--r--src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h18
-rw-r--r--src/declarative/qml/qmlvme.cpp2
8 files changed, 79 insertions, 28 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index d02ab1c..555ecb0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -2994,6 +2994,9 @@ QDebug operator<<(QDebug debug, QmlGraphicsItem *item)
return debug;
}
+int QmlGraphicsItemPrivate::heightIdx = -1;
+int QmlGraphicsItemPrivate::widthIdx = -1;
+
int QmlGraphicsItemPrivate::consistentTime = -1;
void QmlGraphicsItemPrivate::setConsistentTime(int t)
{
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
index 0c722ac..a76a7f7 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
@@ -109,7 +109,12 @@ public:
_componentComplete(true), _keepMouse(false),
smooth(false), keyHandler(0),
width(0), height(0), implicitWidth(0), implicitHeight(0)
- {}
+ {
+ if (widthIdx == -1) {
+ widthIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("widthChanged()");
+ heightIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("heightChanged()");
+ }
+ }
~QmlGraphicsItemPrivate()
{ delete _anchors; }
@@ -249,6 +254,19 @@ public:
}
virtual void otherSiblingOrderChange(QmlGraphicsItemPrivate* other) {Q_UNUSED(other)}
+ bool connectToWidthChanged(QObject *object, int index) {
+ return QMetaObject::connect(q_func(), widthIdx, object, index);
+ }
+ bool disconnectFromWidthChanged(QObject *object, int index) {
+ return QMetaObject::disconnect(q_func(), widthIdx, object, index);
+ }
+
+ bool connectToHeightChanged(QObject *object, int index) {
+ return QMetaObject::connect(q_func(), heightIdx, object, index);
+ }
+ bool disconnectFromHeightChanged(QObject *object, int index) {
+ return QMetaObject::disconnect(q_func(), heightIdx, object, index);
+ }
static int consistentTime;
static QTime currentTime();
@@ -256,6 +274,8 @@ public:
static void start(QTime &);
static int elapsed(QTime &);
static int restart(QTime &);
+ static int widthIdx;
+ static int heightIdx;
};
QT_END_NAMESPACE
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index d04b4db..7a4e02c 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -481,8 +481,12 @@ public:
bool autoHighlight : 1;
bool haveHighlightRange : 1;
bool correctFlick : 1;
+
+ static int itemResizedIdx;
};
+int QmlGraphicsListViewPrivate::itemResizedIdx = -1;
+
void QmlGraphicsListViewPrivate::init()
{
Q_Q(QmlGraphicsListView);
@@ -491,6 +495,10 @@ void QmlGraphicsListViewPrivate::init()
QObject::connect(q, SIGNAL(widthChanged()), q, SLOT(refill()));
QObject::connect(q, SIGNAL(movementEnded()), q, SLOT(animStopped()));
q->setFlickDirection(QmlGraphicsFlickable::VerticalFlick);
+ if (itemResizedIdx == -1) {
+ itemResizedIdx = QmlGraphicsListView::staticMetaObject.indexOfSlot("itemResized()");
+ qDebug() << "ri" << itemResizedIdx;
+ }
}
void QmlGraphicsListViewPrivate::clear()
@@ -531,10 +539,11 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex)
model->completeItem();
listItem->item->setZValue(1);
listItem->item->setParent(q->viewport());
+ QmlGraphicsItemPrivate *itemPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(item));
if (orient == QmlGraphicsListView::Vertical)
- QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
+ itemPrivate->connectToHeightChanged(q, itemResizedIdx);
else
- QObject::connect(listItem->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
+ itemPrivate->connectToWidthChanged(q, itemResizedIdx);
}
requestedIndex = -1;
@@ -556,10 +565,11 @@ void QmlGraphicsListViewPrivate::releaseItem(FxListItem *item)
if (model->release(item->item) == 0) {
// item was not destroyed, and we no longer reference it.
unrequestedItems.insert(item->item, model->indexOf(item->item, q));
+ QmlGraphicsItemPrivate *itemPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(item->item));
if (orient == QmlGraphicsListView::Vertical)
- QObject::disconnect(item->item, SIGNAL(heightChanged()), q, SLOT(itemResized()));
+ itemPrivate->disconnectFromHeightChanged(q, itemResizedIdx);
else
- QObject::disconnect(item->item, SIGNAL(widthChanged()), q, SLOT(itemResized()));
+ itemPrivate->disconnectFromWidthChanged(q, itemResizedIdx);
}
delete item;
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
index 6c594cf..2aa9397 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp
@@ -119,6 +119,12 @@ void QmlGraphicsDrag::setYmax(qreal m)
_ymax = m;
}
+QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate()
+{
+ delete drag;
+}
+
+
/*!
\qmlclass MouseRegion QmlGraphicsMouseRegion
\brief The MouseRegion item enables simple mouse handling.
@@ -339,8 +345,10 @@ void QmlGraphicsMouseRegion::mousePressEvent(QGraphicsSceneMouseEvent *event)
else {
d->longPress = false;
d->saveEvent(event);
- d->dragX = drag()->axis() & QmlGraphicsDrag::XAxis;
- d->dragY = drag()->axis() & QmlGraphicsDrag::YAxis;
+ if (d->drag) {
+ d->dragX = drag()->axis() & QmlGraphicsDrag::XAxis;
+ d->dragY = drag()->axis() & QmlGraphicsDrag::YAxis;
+ }
d->dragged = false;
setHovered(true);
d->start = event->pos();
@@ -371,7 +379,7 @@ void QmlGraphicsMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
else if (!d->hovered && contains)
setHovered(true);
- if (drag()->target()) {
+ if (d->drag && d->drag->target()) {
if (!d->moved) {
if (d->dragX) d->startX = drag()->target()->x();
if (d->dragY) d->startY = drag()->target()->y();
@@ -616,7 +624,9 @@ bool QmlGraphicsMouseRegion::setPressed(bool p)
QmlGraphicsDrag *QmlGraphicsMouseRegion::drag()
{
Q_D(QmlGraphicsMouseRegion);
- return &(d->drag);
+ if (!d->drag)
+ d->drag = new QmlGraphicsDrag;
+ return d->drag;
}
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h
index f1fcd85..dc43ad5 100644
--- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p_p.h
@@ -70,6 +70,8 @@ public:
{
}
+ ~QmlGraphicsMouseRegionPrivate();
+
void init()
{
Q_Q(QmlGraphicsMouseRegion);
@@ -97,7 +99,7 @@ public:
bool dragX : 1;
bool dragY : 1;
bool dragged : 1;
- QmlGraphicsDrag drag;
+ QmlGraphicsDrag *drag;
QPointF start;
QPointF startScene;
qreal startX;
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
index 48bb492..70f0cb0 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp
@@ -51,30 +51,38 @@
QT_BEGIN_NAMESPACE
+int QmlGraphicsBasePositionerPrivate::prePosIdx = -1;
+int QmlGraphicsBasePositionerPrivate::visibleIdx = -1;
+int QmlGraphicsBasePositionerPrivate::opacityIdx = -1;
+
+
void QmlGraphicsBasePositionerPrivate::watchChanges(QmlGraphicsItem *other)
{
Q_Q(QmlGraphicsBasePositioner);
QMetaObject::connect(other, visibleIdx, q, prePosIdx);
QMetaObject::connect(other, opacityIdx, q, prePosIdx);
- QMetaObject::connect(other, heightIdx, q, prePosIdx);
- QMetaObject::connect(other, widthIdx, q, prePosIdx);
- static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other))->registerSiblingOrderNotification(this);
+ QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
+
+ otherPrivate->connectToHeightChanged(q, prePosIdx);
+ otherPrivate->connectToWidthChanged(q, prePosIdx);
+
+ otherPrivate->registerSiblingOrderNotification(this);
watched << other;
}
void QmlGraphicsBasePositionerPrivate::unwatchChanges(QmlGraphicsItem* other)
{
Q_Q(QmlGraphicsBasePositioner);
+ QmlGraphicsItemPrivate *otherPrivate = static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other));
bool stillAlive = false; //Use the return from disconnect to see if it was deleted or just reparented
stillAlive |= QMetaObject::disconnect(other, visibleIdx, q, prePosIdx);
stillAlive |= QMetaObject::disconnect(other, opacityIdx, q, prePosIdx);
- stillAlive |= QMetaObject::disconnect(other, heightIdx, q, prePosIdx);
- stillAlive |= QMetaObject::disconnect(other, widthIdx, q, prePosIdx);
+ stillAlive |= otherPrivate->disconnectFromHeightChanged(q, prePosIdx);
+ stillAlive |= otherPrivate->disconnectFromWidthChanged(q, prePosIdx);
if(stillAlive)
- static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other))
- ->unregisterSiblingOrderNotification(this);
+ otherPrivate->unregisterSiblingOrderNotification(this);
watched.removeAll(other);
}
diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
index e140bef..676f94c 100644
--- a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h
@@ -85,11 +85,11 @@ public:
void init(QmlGraphicsBasePositioner::AutoUpdateType at)
{
aut = at;
- prePosIdx = QmlGraphicsBasePositioner::staticMetaObject.indexOfSlot("prePositioning()");
- visibleIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("visibleChanged()");
- opacityIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("opacityChanged()");
- heightIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("heightChanged()");
- widthIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("widthChanged()");
+ if (prePosIdx == -1) {
+ prePosIdx = QmlGraphicsBasePositioner::staticMetaObject.indexOfSlot("prePositioning()");
+ visibleIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("visibleChanged()");
+ opacityIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("opacityChanged()");
+ }
}
bool _ep;
@@ -117,11 +117,9 @@ public:
QList<QGuard<QmlGraphicsItem> > watched;
bool queuedPositioning;
- int prePosIdx;
- int visibleIdx;
- int opacityIdx;
- int heightIdx;
- int widthIdx;
+ static int prePosIdx;
+ static int visibleIdx;
+ static int opacityIdx;
virtual void otherSiblingOrderChange(QmlGraphicsItemPrivate* other)
{
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 3968d8d..24ac565 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -158,7 +158,7 @@ QObject *QmlVME::run(QmlVMEStack<QObject *> &stack, QmlContext *ctxt,
QmlMetaProperty::WriteFlags flags = QmlMetaProperty::BypassInterceptor;
for (int ii = start; !isError() && ii < (start + count); ++ii) {
- QmlInstruction &instr = comp->bytecode[ii];
+ const QmlInstruction &instr = comp->bytecode.at(ii);
switch(instr.type) {
case QmlInstruction::Init: