diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-17 20:10:00 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-06-17 20:10:00 (GMT) |
commit | 25917c68a06432cccb1d40d2fb4207ce2d1407f6 (patch) | |
tree | 7a6d04c277cf04e4d33a52d35134a841834c9f8e /src/declarative | |
parent | 6aa50af000f85cc4497749fcf0860c8ed244a60e (diff) | |
parent | 8fe1b2baf562df50e7b5cd7b4ea23bc5545ee80f (diff) | |
download | Qt-25917c68a06432cccb1d40d2fb4207ce2d1407f6.zip Qt-25917c68a06432cccb1d40d2fb4207ce2d1407f6.tar.gz Qt-25917c68a06432cccb1d40d2fb4207ce2d1407f6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml:
Fix event forwarding in QDeclarativeFlickable.
doc: improve Repeater model docs.
doc: couple more performance tips.
BorderImage is not updated when border values change
XmlListModel: Don't lock while doing the slow bit.
Auto test for QTBUG-11507
Properly update childrenRect for position changes and shrinking.
Diffstat (limited to 'src/declarative')
7 files changed, 83 insertions, 48 deletions
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; } 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<QDeclarativeItem*>(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; 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/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: 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>("QDeclarativeXmlQueryResult"); + m_currentJob.queryId = -1; } ~QDeclarativeXmlQuery() { @@ -161,6 +162,13 @@ public: void abort(int id) { QMutexLocker locker(&m_mutex); + QQueue<XmlQueryJob>::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<XmlQueryJob> 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<QDeclarativeXmlListRange> * 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<job.keyRoleResultsCache.count(); i++) { - if (!keyRoleResults.contains(job.keyRoleResultsCache[i])) + for (int i=0; i<m_currentJob.keyRoleResultsCache.count(); i++) { + if (!keyRoleResults.contains(m_currentJob.keyRoleResultsCache[i])) addIndexToRangeList(&m_removedItemRanges, i); else - temp << job.keyRoleResultsCache[i]; + temp << m_currentJob.keyRoleResultsCache[i]; } for (int i=0; i<keyRoleResults.count(); i++) { @@ -360,11 +371,11 @@ void QDeclarativeXmlQuery::doSubQueryJob() } } } - job.keyRoleResultsCache = keyRoleResults; + m_currentJob.keyRoleResultsCache = keyRoleResults; // Get the new values for each role. //### we might be able to condense even further (query for everything in one go) - const QStringList &queries = job.roleQueries; + const QStringList &queries = m_currentJob.roleQueries; for (int i = 0; i < queries.size(); ++i) { QList<QVariant> 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. |