From bba51197a1f99a5c77c2747de2ecd399fdb638a0 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 17 Jun 2010 11:36:30 +1000 Subject: Properly update childrenRect for position changes and shrinking. Task-number: QTBUG-11465 --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 9 ++-- .../qdeclarativeitem/data/childrenRectBug2.qml | 53 ++++++++++++++++++++++ .../qdeclarativeitem/tst_qdeclarativeitem.cpp | 27 ++++++++++- 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 42b370b..336010f 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -345,10 +345,11 @@ void QDeclarativeContents::complete() void QDeclarativeContents::itemGeometryChanged(QDeclarativeItem *changed, const QRectF &newGeometry, const QRectF &oldGeometry) { - if (newGeometry.width() != oldGeometry.width()) - calcWidth(changed); - if (newGeometry.height() != oldGeometry.height()) - calcHeight(changed); + //### we can only pass changed if the left edge has moved left, or the right edge has moved right + if (newGeometry.width() != oldGeometry.width() || newGeometry.x() != oldGeometry.x()) + calcWidth(/*changed*/); + if (newGeometry.height() != oldGeometry.height() || newGeometry.y() != oldGeometry.y()) + calcHeight(/*changed*/); } void QDeclarativeContents::itemDestroyed(QDeclarativeItem *item) diff --git a/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml new file mode 100644 index 0000000..225d8d4 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeitem/data/childrenRectBug2.qml @@ -0,0 +1,53 @@ +import Qt 4.7 + +Rectangle { + width:360; + height: 200 + + Item { + objectName: "theItem" + anchors.centerIn: parent + width: childrenRect.width + height: childrenRect.height + Rectangle { + id: header1 + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + width: 100; height: 50 + color: "green" + } + Rectangle { + id: text1 + anchors.top: header1.bottom + anchors.topMargin: 10 + anchors.horizontalCenter: parent.horizontalCenter + width: 100; height: 50 + color: "blue" + } + } + + states: [ + State { + name: "row" + AnchorChanges { + target: header1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.top: undefined + } + AnchorChanges { + target: text1 + anchors.horizontalCenter: undefined + anchors.verticalCenter: parent.verticalCenter + anchors.top: undefined + anchors.left: header1.right + } + PropertyChanges { + target: text1 + anchors.leftMargin: 10 + anchors.topMargin: 0 + } + } + ] +} diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index 0a66245..4a57def 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -44,7 +44,8 @@ #include #include #include -#include +#include +#include #include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN @@ -73,6 +74,7 @@ private slots: void transforms_data(); void childrenRect(); void childrenRectBug(); + void childrenRectBug2(); void childrenProperty(); void resourcesProperty(); @@ -753,6 +755,29 @@ void tst_QDeclarativeItem::childrenRectBug() delete canvas; } +// QTBUG-11465 +void tst_QDeclarativeItem::childrenRectBug2() +{ + QDeclarativeView *canvas = new QDeclarativeView(0); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/childrenRectBug2.qml")); + canvas->show(); + + QDeclarativeRectangle *rect = qobject_cast(canvas->rootObject()); + QVERIFY(rect); + QDeclarativeItem *item = rect->findChild("theItem"); + QCOMPARE(item->width(), qreal(100)); + QCOMPARE(item->height(), qreal(110)); + QCOMPARE(item->x(), qreal(130)); + + QDeclarativeItemPrivate *rectPrivate = QDeclarativeItemPrivate::get(rect); + rectPrivate->setState("row"); + QCOMPARE(item->width(), qreal(210)); + QCOMPARE(item->height(), qreal(50)); + QCOMPARE(item->x(), qreal(75)); + + delete canvas; +} + template T *tst_QDeclarativeItem::findItem(QGraphicsObject *parent, const QString &objectName) { -- cgit v0.12 From cc621ba462331ad936f47c44c22030392caa574f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 17 Jun 2010 15:29:06 +1000 Subject: Auto test for QTBUG-11507 --- .../declarative/qdeclarativeqt/data/createComponent_lib.js | 7 +++++++ .../declarative/qdeclarativeqt/data/createComponent_lib.qml | 10 ++++++++++ tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 11 +++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js create mode 100644 tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js new file mode 100644 index 0000000..c165e29 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.js @@ -0,0 +1,7 @@ +.pragma library + +function loadComponent() { + var component = Qt.createComponent("createComponentData.qml"); + return component.status; +} + diff --git a/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml new file mode 100644 index 0000000..aae7a91 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeqt/data/createComponent_lib.qml @@ -0,0 +1,10 @@ +import Qt 4.7 +import "createComponent_lib.js" as Test + +Item { + property int status: Component.Null + + Component.onCompleted: { + status = Test.loadComponent() + } +} diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index 06561fa..e3e0ba0 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -76,6 +76,7 @@ private slots: void openUrlExternally(); void md5(); void createComponent(); + void createComponent_pragmaLibrary(); void createQmlObject(); void consoleLog(); void formatting(); @@ -361,6 +362,16 @@ void tst_qdeclarativeqt::createComponent() delete object; } +void tst_qdeclarativeqt::createComponent_pragmaLibrary() +{ + QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QEXPECT_FAIL("", "QTBUG-11507", Continue); + QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); +} + void tst_qdeclarativeqt::createQmlObject() { QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml")); -- cgit v0.12 From f8080432e1307c099aee65153870af7c1677ccba Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 16:36:00 +1000 Subject: XmlListModel: Don't lock while doing the slow bit. --- src/declarative/util/qdeclarativexmllistmodel.cpp | 71 +++++++++++++---------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4adef25..bfd25be 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -148,6 +148,7 @@ public: QDeclarativeXmlQuery(QObject *parent=0) : QThread(parent), m_quit(false), m_abortQueryId(-1), m_queryIds(XMLLISTMODEL_CLEAR_ID + 1) { qRegisterMetaType("QDeclarativeXmlQueryResult"); + m_currentJob.queryId = -1; } ~QDeclarativeXmlQuery() { @@ -161,6 +162,13 @@ public: void abort(int id) { QMutexLocker locker(&m_mutex); + QQueue::iterator it; + for (it = m_jobs.begin(); it != m_jobs.end(); ++it) { + if ((*it).queryId == id) { + m_jobs.erase(it); + return; + } + } m_abortQueryId = id; } @@ -188,7 +196,7 @@ public: m_queryIds++; if (!isRunning()) - start(); + start(QThread::IdlePriority); else m_condition.wakeOne(); return job.queryId; @@ -202,24 +210,28 @@ protected: void run() { while (!m_quit) { m_mutex.lock(); - doQueryJob(); - doSubQueryJob(); + if (!m_jobs.isEmpty()) + m_currentJob = m_jobs.dequeue(); m_mutex.unlock(); - m_mutex.lock(); - const XmlQueryJob &job = m_jobs.dequeue(); - if (m_abortQueryId != job.queryId) { - QDeclarativeXmlQueryResult r; - r.queryId = job.queryId; + QDeclarativeXmlQueryResult r; + if (m_currentJob.queryId != -1) { + doQueryJob(); + doSubQueryJob(); + r.queryId = m_currentJob.queryId; r.size = m_size; r.data = m_modelData; r.inserted = m_insertedItemRanges; r.removed = m_removedItemRanges; - r.keyRoleResultsCache = job.keyRoleResultsCache; - emit queryCompleted(r); + r.keyRoleResultsCache = m_currentJob.keyRoleResultsCache; } + + m_mutex.lock(); + if (m_currentJob.queryId != -1 && m_abortQueryId != m_currentJob.queryId) + emit queryCompleted(r); if (m_jobs.isEmpty()) m_condition.wait(&m_mutex); + m_currentJob.queryId = -1; m_abortQueryId = -1; m_mutex.unlock(); } @@ -235,6 +247,7 @@ private: QMutex m_mutex; QWaitCondition m_condition; QQueue m_jobs; + XmlQueryJob m_currentJob; bool m_quit; int m_abortQueryId; QString m_prefix; @@ -249,15 +262,14 @@ Q_GLOBAL_STATIC(QDeclarativeXmlQuery, globalXmlQuery) void QDeclarativeXmlQuery::doQueryJob() { - Q_ASSERT(!m_jobs.isEmpty()); - XmlQueryJob &job = m_jobs.head(); + Q_ASSERT(m_currentJob.queryId != -1); QString r; QXmlQuery query; - QBuffer buffer(&job.data); + QBuffer buffer(&m_currentJob.data); buffer.open(QIODevice::ReadOnly); query.bindVariable(QLatin1String("src"), &buffer); - query.setQuery(job.namespaces + job.query); + query.setQuery(m_currentJob.namespaces + m_currentJob.query); query.evaluateTo(&r); //always need a single root element @@ -265,9 +277,9 @@ void QDeclarativeXmlQuery::doQueryJob() QBuffer b(&xml); b.open(QIODevice::ReadOnly); - QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + job.namespaces; + QString namespaces = QLatin1String("declare namespace dummy=\"http://qtsotware.com/dummy\";\n") + m_currentJob.namespaces; QString prefix = QLatin1String("doc($inputDocument)/dummy:items") + - job.query.mid(job.query.lastIndexOf(QLatin1Char('/'))); + m_currentJob.query.mid(m_currentJob.query.lastIndexOf(QLatin1Char('/'))); //figure out how many items we are dealing with int count = -1; @@ -282,7 +294,7 @@ void QDeclarativeXmlQuery::doQueryJob() count = item.toAtomicValue().toInt(); } - job.data = xml; + m_currentJob.data = xml; m_prefix = namespaces + prefix + QLatin1Char('/'); m_size = 0; if (count > 0) @@ -291,9 +303,9 @@ void QDeclarativeXmlQuery::doQueryJob() void QDeclarativeXmlQuery::getValuesOfKeyRoles(QStringList *values, QXmlQuery *query) const { - Q_ASSERT(!m_jobs.isEmpty()); + Q_ASSERT(m_currentJob.queryId != -1); - const QStringList &keysQueries = m_jobs.head().keyRoleQueries; + const QStringList &keysQueries = m_currentJob.keyRoleQueries; QString keysQuery; if (keysQueries.count() == 1) keysQuery = m_prefix + keysQueries[0]; @@ -323,11 +335,10 @@ void QDeclarativeXmlQuery::addIndexToRangeList(QList * void QDeclarativeXmlQuery::doSubQueryJob() { - Q_ASSERT(!m_jobs.isEmpty()); - XmlQueryJob &job = m_jobs.head(); + Q_ASSERT(m_currentJob.queryId != -1); m_modelData.clear(); - QBuffer b(&job.data); + QBuffer b(&m_currentJob.data); b.open(QIODevice::ReadOnly); QXmlQuery subquery; @@ -340,16 +351,16 @@ void QDeclarativeXmlQuery::doSubQueryJob() m_insertedItemRanges.clear(); m_removedItemRanges.clear(); - if (job.keyRoleResultsCache.isEmpty()) { + if (m_currentJob.keyRoleResultsCache.isEmpty()) { m_insertedItemRanges << qMakePair(0, m_size); } else { - if (keyRoleResults != job.keyRoleResultsCache) { + if (keyRoleResults != m_currentJob.keyRoleResultsCache) { QStringList temp; - for (int i=0; i resultList; if (!queries[i].isEmpty()) { @@ -378,7 +389,7 @@ void QDeclarativeXmlQuery::doSubQueryJob() item = resultItems.next(); } } else { - emit error(job.roleQueryErrorId.at(i), queries[i]); + emit error(m_currentJob.roleQueryErrorId.at(i), queries[i]); } } //### should warn here if things have gone wrong. -- cgit v0.12 From f0c02624791441d45cc8b2f084505cfc5add7237 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 17 Jun 2010 16:50:10 +1000 Subject: BorderImage is not updated when border values change Task-number: QTBUG-11509 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeborderimage.cpp | 5 +++++ src/declarative/graphicsitems/qdeclarativeborderimage_p.h | 1 + src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index cf458da..d4ca9eb 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -449,6 +449,11 @@ void QDeclarativeBorderImage::sciRequestFinished() } } +void QDeclarativeBorderImage::doUpdate() +{ + update(); +} + void QDeclarativeBorderImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeBorderImage); diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h index 5e725ca..07f049e 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage_p.h +++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p.h @@ -91,6 +91,7 @@ private: void setGridScaledImage(const QDeclarativeGridScaledImage& sci); private Q_SLOTS: + void doUpdate(); void requestFinished(); void sciRequestFinished(); diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h index 3535109..01e4a00 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeborderimage_p_p.h @@ -77,11 +77,20 @@ public: { } + QDeclarativeScaleGrid *getScaleGrid() { Q_Q(QDeclarativeBorderImage); - if (!border) + if (!border) { border = new QDeclarativeScaleGrid(q); + static int borderChangedSignalIdx = -1; + static int doUpdateSlotIdx = -1; + if (borderChangedSignalIdx < 0) + borderChangedSignalIdx = QDeclarativeScaleGrid::staticMetaObject.indexOfSignal("borderChanged()"); + if (doUpdateSlotIdx < 0) + doUpdateSlotIdx = QDeclarativeBorderImage::staticMetaObject.indexOfSlot("doUpdate()"); + QMetaObject::connect(border, borderChangedSignalIdx, q, doUpdateSlotIdx); + } return border; } -- cgit v0.12 From 5cc37fcec3d75f6a8d0ce58ab724916795aff0aa Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 18:14:32 +1000 Subject: doc: couple more performance tips. --- doc/src/declarative/qdeclarativeperformance.qdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc index b535e4b..c866724 100644 --- a/doc/src/declarative/qdeclarativeperformance.qdoc +++ b/doc/src/declarative/qdeclarativeperformance.qdoc @@ -117,4 +117,16 @@ a Loader as needed. \o Fast data access - ensure the data model is as fast as possible. \endlist +\section1 Image resources over composition + +If possible, provide a single image resource, rather than using composition +of a number of elements. For example, a frame with a shadow could be created using +a Rectangle placed over an Image providing the shadow. It is more efficient to +provide an image that includes the frame and the shadow. + +\section1 Limit JavaScript + +Avoid running JavaScript during animation. For example, running a complex +JavaScript expression for each frame of an x property animation. + */ -- cgit v0.12 From 3b6d5bcc0ef8186608be8f27bfd4c816b0cc86bb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 17 Jun 2010 18:15:44 +1000 Subject: doc: improve Repeater model docs. --- src/declarative/graphicsitems/qdeclarativerepeater.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp index 995e22a..87da904 100644 --- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp +++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp @@ -83,17 +83,10 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate() \image repeater-simple.png - The \l model of a Repeater can be specified as a model object, a number, a string list - or an object list. If a model object is used, the - \l delegate can access the model roles as named properties, just as for view elements like - ListView and GridView. + The \l model of a Repeater can be any of the supported \l {qmlmodels}{Data Models}. - The \l delegate can also access two additional properties: - - \list - \o \c index - the index of the delegate's item - \o \c modelData - the data element for the delegate, which is useful where the \l model is a string or object list - \endlist + The index of a delegate is exposed as an accessible \c index property in the delegate. + Properties of the model are also available depending upon the type of \l {qmlmodels}{Data Model}. Here is a Repeater that uses the \c index property inside the instantiated items: -- cgit v0.12 From 8fe1b2baf562df50e7b5cd7b4ea23bc5545ee80f Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 17 Jun 2010 12:13:14 +0200 Subject: Fix event forwarding in QDeclarativeFlickable. The flickable element filters all events of its children and store the press event to replay it if there is a release or if the scrolling didn't happen. The issue was that the event and the item stored to "replay" the press event might not be the item that is interessted by the event. Let say you have a translucent overlay on top of an other item. Previously all events will be send to the overlay and not to the item underneath. This happen beause QGraphicsView propagate events from top to bottom (stacking order) so the overlay will be the first child filtered by the flickable. So we need to repropagate the event through the normal process to the event delivery mechanism of QGraphicsView will work properly. Also we need to unset the mouse grabber since after the first press it might be set to a wrong item. We also need to replay the release by ourself on the new mouse grabber but only if we need to send again the press. Reviewed-by:Yann Bodson --- .../graphicsitems/qdeclarativeflickable.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 6dfd4d9..3f681b7 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -914,8 +914,14 @@ void QDeclarativeFlickable::timerEvent(QTimerEvent *event) d->delayedPressTimer.stop(); if (d->delayedPressEvent) { QDeclarativeItem *grabber = scene() ? qobject_cast(scene()->mouseGrabberItem()) : 0; - if (!grabber || grabber != this) - scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent); + if (!grabber || grabber != this) { + // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) + // so we reset the grabber + if (scene()->mouseGrabberItem() == d->delayedPressTarget) + d->delayedPressTarget->ungrabMouse(); + //Use the event handler that will take care of finding the proper item to propagate the event + QApplication::sendEvent(scene(), d->delayedPressEvent); + } delete d->delayedPressEvent; d->delayedPressEvent = 0; } @@ -1206,8 +1212,17 @@ bool QDeclarativeFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) break; case QEvent::GraphicsSceneMouseRelease: if (d->delayedPressEvent) { - scene()->sendEvent(d->delayedPressTarget, d->delayedPressEvent); + // We replay the mouse press but the grabber we had might not be interessted by the event (e.g. overlay) + // so we reset the grabber + if (s->mouseGrabberItem() == d->delayedPressTarget) + d->delayedPressTarget->ungrabMouse(); + //Use the event handler that will take care of finding the proper item to propagate the event + QApplication::sendEvent(scene(), d->delayedPressEvent); d->clearDelayedPress(); + // We send the release + scene()->sendEvent(s->mouseGrabberItem(), event); + // And the event has been consumed + return true; } d->handleMouseReleaseEvent(&mouseEvent); break; -- cgit v0.12 From 335616740f946db08ecd6806067daaeff1bee840 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 17 Jun 2010 18:06:17 +1000 Subject: Doc fixes --- .../graphicsitems/qdeclarativemousearea.cpp | 12 +++++------ src/declarative/util/qdeclarativeanimation.cpp | 24 +++++++--------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index c4956df..0bed41b 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -294,12 +294,12 @@ QDeclarativeMouseAreaPrivate::~QDeclarativeMouseAreaPrivate() /*! \qmlsignal MouseArea::onCanceled() - This handler is called when the mouse events are canceled, either because the event was not accepted or - another element stole the mouse event handling. This signal is for advanced users, it's useful in case there - is more than one mouse areas handling input, or when there is a mouse area inside a flickable. In the latter - case, if you do some logic on pressed and then start dragging, the flickable will steal the mouse handling - from the mouse area. In these cases, to reset the logic when there is no mouse handling anymore, you should - use onCanceled, in addition to onReleased. + This handler is called when mouse events have been canceled, either because an event was not accepted, or + because another element stole the mouse event handling. This signal is for advanced use: it is useful when + there is more than one MouseArea that is handling input, or when there is a MouseArea inside a \l Flickable. In the latter + case, if you execute some logic on the pressed signal and then start dragging, the \l Flickable will steal the mouse handling + from the MouseArea. In these cases, to reset the logic when the MouseArea has lost the mouse handling to the + \l Flickable, \c onCanceled should be used in addition to onReleased. */ /*! diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 25cf133..f807866 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1344,24 +1344,14 @@ void QDeclarativeRotationAnimation::setTo(qreal t) Possible values are: - \table - \row - \o RotationAnimation.Numerical - \o Rotate by linearly interpolating between the two numbers. + \list + \o RotationAnimation.Numerical (default) - Rotate by linearly interpolating between the two numbers. A rotation from 10 to 350 will rotate 340 degrees clockwise. - \row - \o RotationAnimation.Clockwise - \o Rotate clockwise between the two values - \row - \o RotationAnimation.Counterclockwise - \o Rotate counterclockwise between the two values - \row - \o RotationAnimation.Shortest - \o Rotate in the direction that produces the shortest animation path. + \o RotationAnimation.Clockwise - Rotate clockwise between the two values + \o RotationAnimation.Counterclockwise - Rotate counterclockwise between the two values + \o RotationAnimation.Shortest - Rotate in the direction that produces the shortest animation path. A rotation from 10 to 350 will rotate 20 degrees counterclockwise. - \endtable - - The default direction is RotationAnimation.Numerical. + \endlist */ QDeclarativeRotationAnimation::RotationDirection QDeclarativeRotationAnimation::direction() const { @@ -1747,7 +1737,7 @@ void QDeclarativePropertyAnimation::setFrom(const QVariant &f) /*! \qmlproperty real PropertyAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition or Behavior. + If not set, then the value defined in the end state of the transition or \l Behavior. */ QVariant QDeclarativePropertyAnimation::to() const { -- cgit v0.12 From 72e61434b3596988e4748029d8b384350e2ef270 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 17 Jun 2010 18:06:27 +1000 Subject: ListView doc improvements and examples clean up --- doc/src/declarative/pics/ListViewSections.png | Bin 7596 -> 5491 bytes doc/src/examples/qml-examples.qdoc | 2 +- .../declarative/modelviews/listview/PetsModel.qml | 3 -- .../modelviews/listview/RecipesModel.qml | 1 - .../listview/content/PressAndHoldButton.qml | 11 +++--- .../modelviews/listview/dynamiclist.qml | 2 +- .../modelviews/listview/expandingdelegates.qml | 4 +-- .../declarative/modelviews/listview/highlight.qml | 4 +++ .../modelviews/listview/highlightranges.qml | 20 +++++------ .../declarative/modelviews/listview/sections.qml | 3 ++ .../graphicsitems/qdeclarativelistview.cpp | 37 ++++++++++++++------- 11 files changed, 53 insertions(+), 34 deletions(-) diff --git a/doc/src/declarative/pics/ListViewSections.png b/doc/src/declarative/pics/ListViewSections.png index 9270126..4e8f076 100644 Binary files a/doc/src/declarative/pics/ListViewSections.png and b/doc/src/declarative/pics/ListViewSections.png differ diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index b6069f2..ee708a8 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -213,7 +213,7 @@ \title Models and Views: ListView \example declarative/modelviews/listview - This example shows how to use the ListView element. + These examples show how to use the ListView element. */ /*! diff --git a/examples/declarative/modelviews/listview/PetsModel.qml b/examples/declarative/modelviews/listview/PetsModel.qml index 70cdcdd..b77557d 100644 --- a/examples/declarative/modelviews/listview/PetsModel.qml +++ b/examples/declarative/modelviews/listview/PetsModel.qml @@ -40,10 +40,7 @@ import Qt 4.7 -// ListModel allows free form list models to be defined and populated. - ListModel { - id: petsModel ListElement { name: "Polly" type: "Parrot" diff --git a/examples/declarative/modelviews/listview/RecipesModel.qml b/examples/declarative/modelviews/listview/RecipesModel.qml index 03ab961..e6d829f 100644 --- a/examples/declarative/modelviews/listview/RecipesModel.qml +++ b/examples/declarative/modelviews/listview/RecipesModel.qml @@ -41,7 +41,6 @@ import Qt 4.7 ListModel { - id: recipesModel ListElement { title: "Pancakes" picture: "content/pics/pancakes.jpg" diff --git a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml index 7c174e3..0d5a255 100644 --- a/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml +++ b/examples/declarative/modelviews/listview/content/PressAndHoldButton.qml @@ -51,6 +51,11 @@ Image { scale: pressed ? 0.9 : 1 + function release() { + autoRepeatClicks.stop() + container.pressed = false + } + SequentialAnimation on pressed { id: autoRepeatClicks running: false @@ -70,10 +75,8 @@ Image { anchors.fill: parent onPressed: autoRepeatClicks.start() - onReleased: { - autoRepeatClicks.stop() - container.pressed = false - } + onReleased: container.release() + onCanceled: container.release() } } diff --git a/examples/declarative/modelviews/listview/dynamiclist.qml b/examples/declarative/modelviews/listview/dynamiclist.qml index 0e290f5..12c331b 100644 --- a/examples/declarative/modelviews/listview/dynamiclist.qml +++ b/examples/declarative/modelviews/listview/dynamiclist.qml @@ -45,7 +45,7 @@ import "content" Rectangle { id: container - width: 640; height: 480 + width: 500; height: 400 color: "#343434" // The model: diff --git a/examples/declarative/modelviews/listview/expandingdelegates.qml b/examples/declarative/modelviews/listview/expandingdelegates.qml index 94ea48f..24d6386 100644 --- a/examples/declarative/modelviews/listview/expandingdelegates.qml +++ b/examples/declarative/modelviews/listview/expandingdelegates.qml @@ -138,7 +138,8 @@ Rectangle { id: flick width: parent.width anchors { top: methodTitle.bottom; bottom: parent.bottom } - contentHeight: methodText.height; clip: true + contentHeight: methodText.height + clip: true Text { id: methodText; text: method; wrapMode: Text.WordWrap; width: details.width } } @@ -197,6 +198,5 @@ Rectangle { anchors.fill: parent model: RecipesModel {} delegate: recipeDelegate - clip: true } } diff --git a/examples/declarative/modelviews/listview/highlight.qml b/examples/declarative/modelviews/listview/highlight.qml index 5748974..9f43409 100644 --- a/examples/declarative/modelviews/listview/highlight.qml +++ b/examples/declarative/modelviews/listview/highlight.qml @@ -38,6 +38,10 @@ ** ****************************************************************************/ +// This example shows how to create your own highlight delegate for a ListView +// that uses a SpringFollow animation to provide custom movement when the +// highlight bar is moved between items. + import Qt 4.7 Rectangle { diff --git a/examples/declarative/modelviews/listview/highlightranges.qml b/examples/declarative/modelviews/listview/highlightranges.qml index 162d8b7..f0d7f75 100644 --- a/examples/declarative/modelviews/listview/highlightranges.qml +++ b/examples/declarative/modelviews/listview/highlightranges.qml @@ -43,31 +43,31 @@ import Qt 4.7 Rectangle { width: 600; height: 300 - // Show the model in three lists, with different highlight ranges. - // preferredHighlightBegin and preferredHighlightEnd set the - // range in which to attempt to maintain the highlight. + // This example shows the same model in three different ListView items, + // with different highlight ranges. The highlight ranges are set by the + // preferredHighlightBegin and preferredHighlightEnd properties in ListView. // - // The second and third ListView set their currentIndex to be the - // same as the first, and the first ListView is given keyboard focus. + // The second and third ListViews set their currentIndex to be the + // same as the first. The first ListView is given keyboard focus. // - // The first list does not set a highlight range, so its currentItem + // The first ListView does not set a highlight range, so its currentItem // can move freely within the visible area. If it moves outside the // visible area, the view is automatically scrolled to keep the current // item visible. // - // The second list sets a highlight range which attempts to keep the + // The second ListView sets a highlight range which attempts to keep the // current item within the the bounds of the range. However, // items will not scroll beyond the beginning or end of the view, // forcing the highlight to move outside the range at the ends. // - // The third list sets the highlightRangeMode to StrictlyEnforceRange + // The third ListView sets the highlightRangeMode to StrictlyEnforceRange // and sets a range smaller than the height of an item. This // forces the current item to change when the view is flicked, // since the highlight is unable to move. // // Note that the first ListView sets its currentIndex to be equal to - // the third ListView's currentIndex. By flicking List3 with - // the mouse, the current index of List1 will be changed. + // the third ListView's currentIndex. By flicking the third ListView with + // the mouse, the current index of the first ListView will be changed. ListView { id: list1 diff --git a/examples/declarative/modelviews/listview/sections.qml b/examples/declarative/modelviews/listview/sections.qml index 8c038a0..8e0a49f 100644 --- a/examples/declarative/modelviews/listview/sections.qml +++ b/examples/declarative/modelviews/listview/sections.qml @@ -38,6 +38,9 @@ ** ****************************************************************************/ +// This example shows how a ListView can be separated into sections using +// the ListView.section attached property. + import Qt 4.7 //! [0] diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 48ac4a4..b0728c1 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1379,7 +1379,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m to set \e {clip: true} in order to have the out of view items clipped nicely. - \sa ListModel, GridView + \sa ListModel, GridView, {declarative/modelviews/listview}{ListView examples} */ QDeclarativeListView::QDeclarativeListView(QDeclarativeItem *parent) @@ -1663,7 +1663,7 @@ int QDeclarativeListView::count() const so as to stay with the current item, unless the highlightFollowsCurrentItem property is false. - \sa highlightItem, highlightFollowsCurrentItem + \sa highlightItem, highlightFollowsCurrentItem, {declarative/modelviews/listview}{ListView examples} */ QDeclarativeComponent *QDeclarativeListView::highlight() const { @@ -1940,28 +1940,41 @@ void QDeclarativeListView::setCacheBuffer(int b) These properties hold the expression to be evaluated for the \l section attached property. - \c section.property hold the name of the property to use to determine - the section that holds the item. + The \l section attached property enables a ListView to be visually + separated into different parts. These properties determine how sections + are created. + + \c section.property holds the name of the property that is the basis + of each section. - \c section.criteria holds the criteria to use to access the section. It - can be either: + \c section.criteria holds the criteria for forming each section based on + \c section.property. This value can be one of: \list - \o ViewSection.FullString (default) - section is the value of the property. - \o ViewSection.FirstCharacter - section is the first character of the property value. + \o ViewSection.FullString (default) - sections are created based on the + \c section.property value. + \o ViewSection.FirstCharacter - sections are created based on the first + character of the \c section.property value (for example, 'A', 'B', 'C' + sections, etc. for an address book) \endlist \c section.delegate holds the delegate component for each section. Each item in the list has attached properties named \c ListView.section and \c ListView.prevSection. These may be used to place a section header for - related items. The example below assumes that the model is sorted by size of - pet. The section expression is the size property. If \c ListView.section and - \c ListView.prevSection differ, the item will display a section header. - + related items. + + For example, here is a ListView that displays a list of animals, separated + into sections. Each item in the ListView is placed in a different section + depending on the "size" property of the model item. The \c sectionHeading + delegate component provides the light blue bar that marks the beginning of + each section. + \snippet examples/declarative/modelviews/listview/sections.qml 0 \image ListViewSections.png + + \sa {declarative/modelviews/listview}{ListView examples} */ QDeclarativeViewSection *QDeclarativeListView::sectionCriteria() { -- cgit v0.12 From 9a1a98ea193d822f0a356f6afc2cb50b87d22968 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Fri, 18 Jun 2010 11:26:59 +1000 Subject: Fix test --- tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp index e3e0ba0..fb100a5 100644 --- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp +++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp @@ -364,12 +364,15 @@ void tst_qdeclarativeqt::createComponent() void tst_qdeclarativeqt::createComponent_pragmaLibrary() { + // Currently, just loading createComponent_lib.qml causes crash on some platforms + /* QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml")); QObject *object = component.create(); QVERIFY(object != 0); QEXPECT_FAIL("", "QTBUG-11507", Continue); QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready)); + */ } void tst_qdeclarativeqt::createQmlObject() -- cgit v0.12 From 3ea12bbbf794ceb431b182d79267ac2826f25c64 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 21 Jun 2010 12:49:11 +0200 Subject: Seems to fix the keyboard focus confusion Task-number: QTBUG-11411 --- demos/qtdemo/qmlShell.qml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index b1ee79a..141531f 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -73,12 +73,15 @@ Item { clip: true source: qmlFile anchors.centerIn: parent - onStatusChanged: if(status == Loader.Ready) { + onStatusChanged:{ + if(status == Loader.Null) { + loader.focus = false;//fixes QTBUG11411, probably because the focusScope needs to gain focus to focus the right child + }else if(status == Loader.Ready) { if(loader.item.width > 640) loader.item.width = 640; if(loader.item.height > 480) loader.item.height = 480; - } + }} } Rectangle{ id: frame -- cgit v0.12 From 1531db939b31df30d92c95072afdafbed999ffe0 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 21 Jun 2010 12:50:24 +0200 Subject: Allow things that load SameGame to disable the Quit button If I missed any, just set inAnotherDemo to true on the SameGame root item. Task-number: QTBUG-11562 --- demos/declarative/samegame/samegame.qml | 2 ++ demos/qtdemo/qmlShell.qml | 1 + examples/declarative/modelviews/parallax/parallax.qml | 1 + 3 files changed, 4 insertions(+) diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 9c4bfa8..10bf79f 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -46,6 +46,7 @@ import "SamegameCore/samegame.js" as Logic Rectangle { id: screen width: 490; height: 720 + property bool inAnotherDemo: false //Samegame often is just plonked straight into other demos SystemPalette { id: activePalette } @@ -143,6 +144,7 @@ Rectangle { } Button { + visible: !inAnotherDemo text: "Quit" anchors { left: newGameButton.right; leftMargin: 3; verticalCenter: parent.verticalCenter } onClicked: Qt.quit(); diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index 141531f..bc46786 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -81,6 +81,7 @@ Item { loader.item.width = 640; if(loader.item.height > 480) loader.item.height = 480; + loader.item.inAnotherDemo = true; }} } diff --git a/examples/declarative/modelviews/parallax/parallax.qml b/examples/declarative/modelviews/parallax/parallax.qml index ec52a24..3b5c70a 100644 --- a/examples/declarative/modelviews/parallax/parallax.qml +++ b/examples/declarative/modelviews/parallax/parallax.qml @@ -73,6 +73,7 @@ Rectangle { width: 300; height: 400 clip: true; source: "../../../../demos/declarative/samegame/samegame.qml" + Component.onCompleted: item.inAnotherDemo = true; } } -- cgit v0.12 From f0b74a1e78ccf52b0f6d7c13738918baff0eeef4 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 21 Jun 2010 13:05:00 +0200 Subject: Only steal hover events when enabled, in QtDemo's qml integration Not sure whether it was the correct behaviour for a MouseArea to have when enabled is false but hoverEnabled is true, that it would still get hover events. But the current behaviour is unambigious and correct. Task-number: QTBUG-11564 --- demos/qtdemo/qmlShell.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index bc46786..4ac6c97 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -143,7 +143,7 @@ Item { MouseArea{ z: 8 enabled: main.show - hoverEnabled: true //To steal focus from the buttons + hoverEnabled: main.show //To steal focus from the buttons anchors.fill: parent onClicked: main.show=false; } -- cgit v0.12 From b5af8fbbdc26fa50f40dad2c159b6b64827fa431 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 21 Jun 2010 15:25:49 +0200 Subject: Avoid printing a warning --- demos/qtdemo/qmlShell.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/demos/qtdemo/qmlShell.qml b/demos/qtdemo/qmlShell.qml index 4ac6c97..5c5f96c 100644 --- a/demos/qtdemo/qmlShell.qml +++ b/demos/qtdemo/qmlShell.qml @@ -81,7 +81,8 @@ Item { loader.item.width = 640; if(loader.item.height > 480) loader.item.height = 480; - loader.item.inAnotherDemo = true; + if(loader.item.inAnotherDemo != undefined) + loader.item.inAnotherDemo = true; }} } -- cgit v0.12