diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-12-03 06:16:18 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-12-03 06:16:18 (GMT) |
commit | 9ddd812b37414fc12295c7fc07f06558d876a017 (patch) | |
tree | ef87dd62b727efccbbf9172a1dad9ef8eacf6542 /src/declarative/graphicsitems | |
parent | 8e45a7b2b66d998c941c1c66bdabc240decd5474 (diff) | |
parent | 2b07e188b91d2cb92a2c41f85678415c4dbb3721 (diff) | |
download | Qt-9ddd812b37414fc12295c7fc07f06558d876a017.zip Qt-9ddd812b37414fc12295c7fc07f06558d876a017.tar.gz Qt-9ddd812b37414fc12295c7fc07f06558d876a017.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/graphicsitems')
9 files changed, 119 insertions, 47 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index cb34c1f..6f6f76e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -3004,6 +3004,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 65e63eb..70f0cb0 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -49,39 +49,40 @@ #include <private/qmlgraphicspositioners_p.h> #include <private/qmlgraphicspositioners_p_p.h> - QT_BEGIN_NAMESPACE +int QmlGraphicsBasePositionerPrivate::prePosIdx = -1; +int QmlGraphicsBasePositionerPrivate::visibleIdx = -1; +int QmlGraphicsBasePositionerPrivate::opacityIdx = -1; + + void QmlGraphicsBasePositionerPrivate::watchChanges(QmlGraphicsItem *other) { Q_Q(QmlGraphicsBasePositioner); - QObject::connect(other, SIGNAL(visibleChanged()), - q, SLOT(prePositioning())); - QObject::connect(other, SIGNAL(opacityChanged()), - q, SLOT(prePositioning())); - QObject::connect(other, SIGNAL(heightChanged()), - q, SLOT(prePositioning())); - QObject::connect(other, SIGNAL(widthChanged()), - q, SLOT(prePositioning())); - static_cast<QmlGraphicsItemPrivate*>(QGraphicsItemPrivate::get(other))->registerSiblingOrderNotification(this); + QMetaObject::connect(other, visibleIdx, q, prePosIdx); + QMetaObject::connect(other, opacityIdx, q, prePosIdx); + + 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 |= QObject::disconnect(other, SIGNAL(visibleChanged()), - q, SLOT(prePositioning())); - stillAlive |= QObject::disconnect(other, SIGNAL(opacityChanged()), - q, SLOT(prePositioning())); - stillAlive |= QObject::disconnect(other, SIGNAL(heightChanged()), - q, SLOT(prePositioning())); - stillAlive |= QObject::disconnect(other, SIGNAL(widthChanged()), - q, SLOT(prePositioning())); + stillAlive |= QMetaObject::disconnect(other, visibleIdx, q, prePosIdx); + stillAlive |= QMetaObject::disconnect(other, opacityIdx, 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); } @@ -247,8 +248,9 @@ void QmlGraphicsBasePositioner::prePositioning() //###can we avoid using the QGraphicsItemPrivate? QList<QGraphicsItem *> children = childItems(); qSort(children.begin(), children.end(), d->insertionOrder); - positionedItems = QList<QmlGraphicsItem*>(); + positionedItems.clear(); + allItems.reserve(children.count()); for (int ii = 0; ii < children.count(); ++ii) { QmlGraphicsItem *child = qobject_cast<QmlGraphicsItem *>(children.at(ii)); if (!child) @@ -268,10 +270,12 @@ void QmlGraphicsBasePositioner::prePositioning() allItems += child; positionedItems << child; } - QSet<QmlGraphicsItem *> deletedItems = d->_items - allItems; - foreach(QmlGraphicsItem *child, deletedItems){ - d->unwatchChanges(child); - d->_items -= child; + if (d->_items.count() != allItems.count()) { + QSet<QmlGraphicsItem *> deletedItems = d->_items - allItems; + foreach(QmlGraphicsItem *child, deletedItems){ + d->unwatchChanges(child); + d->_items -= child; + } } d->_animated.clear(); doPositioning(); @@ -471,7 +475,7 @@ QmlGraphicsColumn::QmlGraphicsColumn(QmlGraphicsItem *parent) { } -inline bool isInvisible(QmlGraphicsItem *child) +static inline bool isInvisible(QmlGraphicsItem *child) { return child->opacity() == 0.0 || !child->isVisible() || !child->width() || !child->height(); } @@ -495,12 +499,15 @@ void QmlGraphicsColumn::doPositioning() bool needMove = (child->y() != voffset || child->x()); - QList<QPair<QString, QVariant> > changes; - changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset)); - changes << qMakePair(QString(QLatin1String("x")),QVariant(0)); - if (needMove && items()->contains(child) && move()) { + if (needMove && move() && items()->contains(child)) { + QList<QPair<QString, QVariant> > changes; + changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset)); + changes << qMakePair(QString(QLatin1String("x")),QVariant(0)); applyMove(changes,child); - } else if (!items()->contains(child) && add()) { + } else if (add() && !items()->contains(child)) { + QList<QPair<QString, QVariant> > changes; + changes << qMakePair(QString(QLatin1String("y")),QVariant(voffset)); + changes << qMakePair(QString(QLatin1String("x")),QVariant(0)); applyAdd(changes,child); } else if (needMove) { setMovingItem(child); @@ -630,12 +637,15 @@ void QmlGraphicsRow::doPositioning() bool needMove = (child->x() != hoffset || child->y()); - QList<QPair<QString, QVariant> > changes; - changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset)); - changes << qMakePair(QString(QLatin1String("y")),QVariant(0)); - if (needMove && items()->contains(child) && move()) { + if (needMove && move() && items()->contains(child)) { + QList<QPair<QString, QVariant> > changes; + changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset)); + changes << qMakePair(QString(QLatin1String("y")),QVariant(0)); applyMove(changes,child); - } else if (!items()->contains(child) && add()) { + } else if (add() && !items()->contains(child)) { + QList<QPair<QString, QVariant> > changes; + changes << qMakePair(QString(QLatin1String("x")),QVariant(hoffset)); + changes << qMakePair(QString(QLatin1String("y")),QVariant(0)); applyAdd(changes,child); } else if (needMove) { setMovingItem(child); diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h index d7a31a3..676f94c 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspositioners_p_p.h @@ -85,6 +85,11 @@ public: void init(QmlGraphicsBasePositioner::AutoUpdateType at) { aut = at; + if (prePosIdx == -1) { + prePosIdx = QmlGraphicsBasePositioner::staticMetaObject.indexOfSlot("prePositioning()"); + visibleIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("visibleChanged()"); + opacityIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("opacityChanged()"); + } } bool _ep; @@ -105,7 +110,6 @@ public: QmlTransitionManager addTransitionManager; QmlTransitionManager moveTransitionManager; QmlTransitionManager removeTransitionManager; -// QmlStateGroup *stateGroup; QmlGraphicsItem *_movingItem; void watchChanges(QmlGraphicsItem *other); @@ -113,6 +117,10 @@ public: QList<QGuard<QmlGraphicsItem> > watched; bool queuedPositioning; + static int prePosIdx; + static int visibleIdx; + static int opacityIdx; + virtual void otherSiblingOrderChange(QmlGraphicsItemPrivate* other) { Q_Q(QmlGraphicsBasePositioner); diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index c34fbd8..650d844 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -116,6 +116,13 @@ QmlGraphicsText::~QmlGraphicsText() { } + +QmlGraphicsTextPrivate::~QmlGraphicsTextPrivate() +{ + delete control; + delete doc; +} + /*! \qmlproperty string Text::font.family \qmlproperty bool Text::font.bold diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h index 7017a86..8a4c057 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h @@ -76,6 +76,8 @@ public: { } + ~QmlGraphicsTextPrivate(); + void updateSize(); void checkImgCache(); |