summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeflipable.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimage.cpp4
-rw-r--r--src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp46
-rw-r--r--src/declarative/graphicsitems/qdeclarativemousearea.cpp1
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp59
7 files changed, 80 insertions, 38 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflipable.cpp b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
index e670d3e..ccefc70 100644
--- a/src/declarative/graphicsitems/qdeclarativeflipable.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeflipable.cpp
@@ -75,7 +75,7 @@ public:
Here is a Flipable that flips whenever it is clicked:
- \snippet examples/declarative/flipable/flipable-example.qml 0
+ \snippet doc/src/snippets/declarative/flipable.qml 0
\image flipable.gif
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 12ede34..30f04f6 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -815,7 +815,7 @@ void QDeclarativeGridViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
if (snapMode != QDeclarativeGridView::SnapToRow && highlightRange != QDeclarativeGridView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- if ((maxDistance > 0 || overShoot) && (snapMode != QDeclarativeGridView::NoSnap || highlightRange == QDeclarativeGridView::StrictlyEnforceRange)) {
+ if (maxDistance > 0 || overShoot) {
// This mode requires the grid to stop exactly on a row boundary.
qreal v = velocity;
if (maxVelocity != -1 && maxVelocity < qAbs(v)) {
@@ -1856,6 +1856,8 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
if (d->currentItem)
d->currentItem->index = d->currentIndex;
emit currentIndexChanged();
+ } else if (d->currentIndex < 0) {
+ d->updateCurrent(0);
}
emit countChanged();
return;
diff --git a/src/declarative/graphicsitems/qdeclarativeimage.cpp b/src/declarative/graphicsitems/qdeclarativeimage.cpp
index 23a2350..3145c43 100644
--- a/src/declarative/graphicsitems/qdeclarativeimage.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimage.cpp
@@ -275,6 +275,10 @@ qreal QDeclarativeImage::paintedHeight() const
used by a loaded image. The image will be scaled down if its intrinsic size
is greater than this value.
+ If only one dimension of the size is set (and the other left at 0), the
+ unset dimension will be set in proportion to the set dimension to preserve
+ the source image aspect ratio. The fillMode is independent of this.
+
Unlike setting the width and height properties, which merely scale the painting
of the image, this property affects the number of pixels stored.
diff --git a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
index 7bc74ce..97a22cf 100644
--- a/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeitemsmodule.cpp
@@ -130,7 +130,6 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QDeclarativeTextEdit>("Qt",4,6,"TextEdit");
qmlRegisterType<QDeclarativeTextInput>("Qt",4,6,"TextInput");
qmlRegisterType<QDeclarativeViewSection>("Qt",4,6,"ViewSection");
- qmlRegisterType<QDeclarativeFlickableVisibleArea>("Qt",4,6,"VisibleArea");
qmlRegisterType<QDeclarativeVisualDataModel>("Qt",4,6,"VisualDataModel");
qmlRegisterType<QDeclarativeVisualItemModel>("Qt",4,6,"VisualItemModel");
@@ -148,6 +147,7 @@ void QDeclarativeItemModule::defineModule()
qmlRegisterType<QDeclarativeVisualModel>();
qmlRegisterType<QAction>();
qmlRegisterType<QDeclarativePen>();
+ qmlRegisterType<QDeclarativeFlickableVisibleArea>();
#ifdef QT_WEBKIT_LIB
qmlRegisterType<QDeclarativeWebSettings>();
#endif
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index cbf8eac..308612f 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -305,7 +305,7 @@ public:
if (item->index == -1)
continue;
qreal itemTop = item->position();
- if (item->index == model->count()-1 || (itemTop+item->size()/2 >= pos))
+ if (itemTop+item->size()/2 >= pos && itemTop <= pos)
return item->position();
}
if (visibleItems.count()) {
@@ -1153,7 +1153,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
maxDistance = qAbs(minExtent - data.move.value());
}
}
- if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ if (snapMode == QDeclarativeListView::NoSnap && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = minExtent;
} else {
if (data.move.value() > maxExtent) {
@@ -1164,10 +1164,10 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
maxDistance = qAbs(maxExtent - data.move.value());
}
}
- if (snapMode != QDeclarativeListView::SnapToItem && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
+ if (snapMode == QDeclarativeListView::NoSnap && highlightRange != QDeclarativeListView::StrictlyEnforceRange)
data.flickTarget = maxExtent;
}
- if ((maxDistance > 0 || overShoot) && (snapMode != QDeclarativeListView::NoSnap || highlightRange == QDeclarativeListView::StrictlyEnforceRange)) {
+ if (maxDistance > 0 || overShoot) {
// These modes require the list to stop exactly on an item boundary.
// The initial flick will estimate the boundary to stop on.
// Since list items can have variable sizes, the boundary will be
@@ -1183,18 +1183,35 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m
// the initial flick - estimate boundary
qreal accel = deceleration;
qreal v2 = v * v;
- if (maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) {
- // + averageSize/4 to encourage moving at least one item in the flick direction
- qreal dist = v2 / (accel * 2.0) + averageSize/4;
- if (v > 0)
- dist = -dist;
+ overshootDist = 0.0;
+ // + averageSize/4 to encourage moving at least one item in the flick direction
+ qreal dist = v2 / (accel * 2.0) + averageSize/4;
+ if (maxDistance > 0)
+ dist = qMin(dist, maxDistance);
+ if (v > 0)
+ dist = -dist;
+ if ((maxDistance > 0.0 && v2 / (2.0f * maxDistance) < accel) || snapMode == QDeclarativeListView::SnapOneItem) {
data.flickTarget = -snapPosAt(-(data.move.value() - highlightRangeStart) + dist) + highlightRangeStart;
+ if (overShoot) {
+ if (data.flickTarget >= minExtent) {
+ overshootDist = overShootDistance(v, vSize);
+ data.flickTarget += overshootDist;
+ } else if (data.flickTarget <= maxExtent) {
+ overshootDist = overShootDistance(v, vSize);
+ data.flickTarget -= overshootDist;
+ }
+ }
dist = -data.flickTarget + data.move.value();
accel = v2 / (2.0f * qAbs(dist));
- overshootDist = 0.0;
- } else {
- data.flickTarget = velocity > 0 ? minExtent : maxExtent;
- overshootDist = overShoot ? overShootDistance(v, vSize) : 0;
+ } else if (overShoot) {
+ data.flickTarget = data.move.value() - dist;
+ if (data.flickTarget >= minExtent) {
+ overshootDist = overShootDistance(v, vSize);
+ data.flickTarget += overshootDist;
+ } else if (data.flickTarget <= maxExtent) {
+ overshootDist = overShootDistance(v, vSize);
+ data.flickTarget -= overshootDist;
+ }
}
timeline.reset(data.move);
timeline.accel(data.move, v, accel, maxDistance + overshootDist);
@@ -2381,6 +2398,8 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
if (d->currentItem)
d->currentItem->index = d->currentIndex;
emit currentIndexChanged();
+ } else if (d->currentIndex < 0) {
+ d->updateCurrent(0);
}
emit countChanged();
return;
@@ -2743,7 +2762,6 @@ void QDeclarativeListView::destroyingItem(QDeclarativeItem *item)
void QDeclarativeListView::animStopped()
{
Q_D(QDeclarativeListView);
- d->moveReason = QDeclarativeListViewPrivate::Other;
d->bufferMode = QDeclarativeListViewPrivate::NoBuffer;
}
diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
index dde3366..6126a6f 100644
--- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp
+++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp
@@ -640,6 +640,7 @@ bool QDeclarativeMouseArea::setPressed(bool p)
QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress);
if (d->pressed) {
emit pressed(&me);
+ emit positionChanged(&me);
} else {
emit released(&me);
if (isclick)
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index bb742ee..3e570e5 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -81,6 +81,7 @@
#include <QDebug>
#include <QMetaObject>
#include <QStack>
+#include <QMap>
#include <QPluginLoader>
#include <QtCore/qlibraryinfo.h>
#include <QtCore/qthreadstorage.h>
@@ -342,7 +343,8 @@ void QDeclarativeEnginePrivate::clear(SimpleList<QDeclarativeParserStatus> &pss)
}
Q_GLOBAL_STATIC(QDeclarativeEngineDebugServer, qmlEngineDebugServer);
-Q_GLOBAL_STATIC(QSet<QString>, qmlEnginePluginsWithRegisteredTypes);
+typedef QMap<QString, QString> StringStringMap;
+Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri
void QDeclarativeEnginePrivate::init()
{
@@ -1788,7 +1790,13 @@ void QDeclarativeEngine::addImportPath(const QString& path)
if (qmlImportTrace())
qDebug() << "QDeclarativeEngine::addImportPath" << path;
Q_D(QDeclarativeEngine);
- d->fileImportPath.prepend(path);
+ QUrl url = QUrl(path);
+ if (url.isRelative() || url.scheme() == QString::fromLocal8Bit("file")) {
+ QDir dir = QDir(path);
+ d->fileImportPath.prepend(dir.canonicalPath());
+ } else {
+ d->fileImportPath.prepend(path);
+ }
}
@@ -1838,34 +1846,43 @@ bool QDeclarativeEngine::importExtension(const QString &fileName, const QString
qDebug() << "QDeclarativeEngine::importExtension" << uri << "from" << fileName;
QFileInfo fileInfo(fileName);
const QString absoluteFilePath = fileInfo.absoluteFilePath();
- QPluginLoader loader(absoluteFilePath);
- if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
- const QByteArray bytes = uri.toUtf8();
- const char *moduleId = bytes.constData();
+ QDeclarativeEnginePrivate *d = QDeclarativeEnginePrivate::get(this);
+ bool engineInitialized = d->initializedPlugins.contains(absoluteFilePath);
+ bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
- // ### this code should probably be protected with a mutex.
- if (! qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath)) {
- // types should only be registered once (they're global).
+ if (typesRegistered) {
+ Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri,
+ "QDeclarativeEngine::importExtension",
+ "Internal error: Plugin imported previously with different uri");
+ }
- qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath);
- iface->registerTypes(moduleId);
- }
+ if (!engineInitialized || !typesRegistered) {
+ QPluginLoader loader(absoluteFilePath);
- QDeclarativeEnginePrivate *d = QDeclarativeEnginePrivate::get(this);
+ if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
- if (! d->initializedPlugins.contains(absoluteFilePath)) {
- // things on the engine (eg. adding new global objects) have to be done for every engine.
+ const QByteArray bytes = uri.toUtf8();
+ const char *moduleId = bytes.constData();
+ if (!typesRegistered) {
- // protect against double initialization
- d->initializedPlugins.insert(absoluteFilePath);
- iface->initializeEngine(this, moduleId);
- }
+ // ### this code should probably be protected with a mutex.
+ qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
+ iface->registerTypes(moduleId);
+ }
+ if (!engineInitialized) {
+ // things on the engine (eg. adding new global objects) have to be done for every engine.
- return true;
+ // protect against double initialization
+ d->initializedPlugins.insert(absoluteFilePath);
+ iface->initializeEngine(this, moduleId);
+ }
+ } else {
+ return false;
+ }
}
- return false;
+ return true;
}
/*!