diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-06-09 06:32:07 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-06-09 06:32:07 (GMT) |
commit | f2eab026602a0608e036018eeacf3fa6c8ca3fa7 (patch) | |
tree | 97be8a8e269ea49fb68d4908d8f7d0f47afbd1d6 /src/declarative | |
parent | 22d7c82b71f34df637efd0ed39b3d63719a2bf67 (diff) | |
parent | 17fcc84e5ebcf09f80a4bbebafde913d0422a91e (diff) | |
download | Qt-f2eab026602a0608e036018eeacf3fa6c8ca3fa7.zip Qt-f2eab026602a0608e036018eeacf3fa6c8ca3fa7.tar.gz Qt-f2eab026602a0608e036018eeacf3fa6c8ca3fa7.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/QmlChanges.txt | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.cpp | 24 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeitem.h | 1 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativemousearea.cpp | 2 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativemousearea_p_p.h | 4 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeview.cpp | 20 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeview.h | 1 |
7 files changed, 46 insertions, 8 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 5735b1e..8b6b83f 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,8 @@ ============================================================================= The changes below are pre Qt 4.7.0 RC +QDeclarativeView + - initialSize() function added TextInput and TextEdit: - openSoftwareInputPanel() and closeSoftwareInputPanel() functions added Flickable: diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 9949e65..bef09bb 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1633,7 +1633,7 @@ void QDeclarativeItemPrivate::data_append(QDeclarativeListProperty<QObject> *pro QObject *QDeclarativeItemPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index) { - QObjectList children = prop->object->children(); + const QObjectList children = prop->object->children(); if (index < children.count()) return children.at(index); else @@ -2391,6 +2391,28 @@ void QDeclarativeItem::forceFocus() } } + +/*! + \qmlmethod Item::childAt(real x, real y) + + Returns the visible child item at point (\a x, \a y), which is in this + item's coordinate system, or \c null if there is no such item. + */ +QDeclarativeItem *QDeclarativeItem::childAt(qreal x, qreal y) const +{ + const QList<QGraphicsItem *> children = childItems(); + for (int i = children.count()-1; i >= 0; --i) { + if (QDeclarativeItem *child = qobject_cast<QDeclarativeItem *>(children.at(i))) { + if (child->isVisible() && child->x() <= x + && child->x() + child->width() >= x + && child->y() <= y + && child->y() + child->height() >= y) + return child; + } + } + return 0; +} + void QDeclarativeItemPrivate::focusChanged(bool flag) { Q_Q(QDeclarativeItem); diff --git a/src/declarative/graphicsitems/qdeclarativeitem.h b/src/declarative/graphicsitems/qdeclarativeitem.h index 77e316b..4f420f8 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.h +++ b/src/declarative/graphicsitems/qdeclarativeitem.h @@ -148,6 +148,7 @@ public: Q_INVOKABLE QScriptValue mapFromItem(const QScriptValue &item, qreal x, qreal y) const; Q_INVOKABLE QScriptValue mapToItem(const QScriptValue &item, qreal x, qreal y) const; Q_INVOKABLE void forceFocus(); + Q_INVOKABLE QDeclarativeItem *childAt(qreal x, qreal y) const; Q_SIGNALS: void childrenChanged(); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index 6fca283..a68e664 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -410,7 +410,7 @@ void QDeclarativeMouseArea::mousePressEvent(QGraphicsSceneMouseEvent *event) setHovered(true); d->startScene = event->scenePos(); // we should only start timer if pressAndHold is connected to. - if (d->isConnected("pressAndHold(QDeclarativeMouseEvent*)")) + if (d->isPressAndHoldConnected()) d->pressAndHoldTimer.start(PressAndHoldDelay, this); setKeepMouseGrab(false); event->setAccepted(setPressed(true)); diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h index 4e909ff..3d7bd1e 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h @@ -88,9 +88,9 @@ public: lastModifiers = event->modifiers(); } - bool isConnected(const char *signal) { + bool isPressAndHoldConnected() { Q_Q(QDeclarativeMouseArea); - int idx = QObjectPrivate::get(q)->signalIndex(signal); + static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarativeMouseEvent*)"); return QObjectPrivate::get(q)->isSignalConnected(idx); } diff --git a/src/declarative/util/qdeclarativeview.cpp b/src/declarative/util/qdeclarativeview.cpp index 6059ad6..0414e65 100644 --- a/src/declarative/util/qdeclarativeview.cpp +++ b/src/declarative/util/qdeclarativeview.cpp @@ -131,7 +131,7 @@ class QDeclarativeViewPrivate : public QGraphicsViewPrivate, public QDeclarative Q_DECLARE_PUBLIC(QDeclarativeView) public: QDeclarativeViewPrivate() - : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject) {} + : root(0), declarativeItemRoot(0), graphicsWidgetRoot(0), component(0), resizeMode(QDeclarativeView::SizeViewToRootObject), initialSize(0,0) {} ~QDeclarativeViewPrivate() { delete root; } void execute(); void itemGeometryChanged(QDeclarativeItem *item, const QRectF &newGeometry, const QRectF &oldGeometry); @@ -150,6 +150,7 @@ public: QBasicTimer resizetimer; QDeclarativeView::ResizeMode resizeMode; + QSize initialSize; QElapsedTimer frameTimer; void init(); @@ -586,9 +587,11 @@ void QDeclarativeView::setRootObject(QObject *obj) } if (d->root) { - QSize initialSize = d->rootObjectSize(); - if (initialSize != size()) { - resize(initialSize); + d->initialSize = d->rootObjectSize(); + if (d->initialSize != size()) { + if (!(parentWidget() && parentWidget()->layout())) { + resize(d->initialSize); + } } d->initResize(); } @@ -638,6 +641,15 @@ QSize QDeclarativeView::sizeHint() const } /*! + Returns the initial size of the root object +*/ +QSize QDeclarativeView::initialSize() const +{ + Q_D(const QDeclarativeView); + return d->initialSize; +} + +/*! Returns the view's root \l {QGraphicsObject} {item}. */ QGraphicsObject *QDeclarativeView::rootObject() const diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index e9cff32..cdcf134 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -90,6 +90,7 @@ public: QList<QDeclarativeError> errors() const; QSize sizeHint() const; + QSize initialSize() const; Q_SIGNALS: void sceneResized(QSize size); // ??? |