summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-10-08 06:14:43 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-10-08 06:14:43 (GMT)
commit3f0eb0416205600b97a0504006d7fbb09a10e035 (patch)
tree21fec3832a755c44d40c9ad1261b749747be7fe0 /src/declarative
parent11536f150887266b6a6f5cf00b22f9d1fcc1aaeb (diff)
parent1ebf63580152cba99c54e0241633145b6d7927e3 (diff)
downloadQt-3f0eb0416205600b97a0504006d7fbb09a10e035.zip
Qt-3f0eb0416205600b97a0504006d7fbb09a10e035.tar.gz
Qt-3f0eb0416205600b97a0504006d7fbb09a10e035.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/graphicsitems/qdeclarativeimagebase.cpp13
-rw-r--r--src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp27
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject.cpp25
-rw-r--r--src/declarative/qml/qdeclarativevmemetaobject_p.h19
5 files changed, 71 insertions, 15 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
index b06e2f7..c3bac2d 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp
@@ -113,6 +113,7 @@ void QDeclarativeImageBase::setSourceSize(const QSize& size)
return;
d->sourcesize = size;
+ d->explicitSourceSize = true;
emit sourceSizeChanged();
if (isComponentComplete())
load();
@@ -121,7 +122,10 @@ void QDeclarativeImageBase::setSourceSize(const QSize& size)
QSize QDeclarativeImageBase::sourceSize() const
{
Q_D(const QDeclarativeImageBase);
- return d->sourcesize.isValid() ? d->sourcesize : QSize(implicitWidth(),implicitHeight());
+
+ int width = d->sourcesize.width();
+ int height = d->sourcesize.height();
+ return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight());
}
void QDeclarativeImageBase::load()
@@ -139,7 +143,7 @@ void QDeclarativeImageBase::load()
pixmapChange();
update();
} else {
- d->pix.load(qmlEngine(this), d->url, d->sourcesize, d->async);
+ d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), d->async);
if (d->pix.isLoading()) {
d->progress = 0.0;
@@ -184,11 +188,8 @@ void QDeclarativeImageBase::requestFinished()
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
- if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) {
- d->sourcesize.setWidth(d->pix.width());
- d->sourcesize.setHeight(d->pix.height());
+ if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height())
emit sourceSizeChanged();
- }
if (d->status != oldStatus)
emit statusChanged(d->status);
diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
index aee8b28..3d23ba9 100644
--- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
+++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h
@@ -69,6 +69,7 @@ public:
QDeclarativeImageBasePrivate()
: status(QDeclarativeImageBase::Null),
progress(0.0),
+ explicitSourceSize(false),
async(false)
{
QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents;
@@ -79,6 +80,7 @@ public:
QUrl url;
qreal progress;
QSize sourcesize;
+ bool explicitSourceSize : 1;
bool async : 1;
};
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index 7a29f24..74bc5bd 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -2565,8 +2565,8 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
QStringList alias = astNodeToStringList(node);
- if (alias.count() != 1 && alias.count() != 2)
- COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id> or <id>.<property>"));
+ if (alias.count() < 1 || alias.count() > 3)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
if (!compileState.ids.contains(alias.at(0)))
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0)));
@@ -2578,11 +2578,14 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
int propIdx = -1;
int flags = 0;
bool writable = false;
- if (alias.count() == 2) {
+ if (alias.count() == 2 || alias.count() == 3) {
propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData());
- if (-1 == propIdx)
+ if (-1 == propIdx) {
COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+ } else if (propIdx > 0xFFFF) {
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds"));
+ }
QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx);
if (!aliasProperty.isScriptable())
@@ -2590,6 +2593,22 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder,
writable = aliasProperty.isWritable();
+ if (alias.count() == 3) {
+ QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()];
+ if (!valueType)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+
+ propIdx |= ((unsigned int)aliasProperty.type()) << 24;
+
+ int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData());
+ if (valueTypeIndex == -1)
+ COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location"));
+ Q_ASSERT(valueTypeIndex <= 0xFF);
+
+ aliasProperty = valueType->metaObject()->property(valueTypeIndex);
+ propIdx |= (valueTypeIndex << 16);
+ }
+
if (aliasProperty.isEnumType())
typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
else
diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp
index 37f08fc..e28062b 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject.cpp
+++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp
@@ -459,7 +459,7 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
id -= propOffset;
if (id < metaData->propertyCount) {
- int t = (metaData->propertyData() + id)->propertyType;
+ int t = (metaData->propertyData() + id)->propertyType;
bool needActivate = false;
if (t == -1) {
@@ -586,11 +586,26 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a)
connectAlias(id);
- if (d->propertyIdx == -1) {
+ if (d->isObjectAlias()) {
*reinterpret_cast<QObject **>(a[0]) = target;
return -1;
+ } else if (d->isValueTypeAlias()) {
+ // Value type property
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine);
+
+ QDeclarativeValueType *valueType = ep->valueTypes[d->valueType()];
+ Q_ASSERT(valueType);
+
+ valueType->read(target, d->propertyIndex());
+ int rv = QMetaObject::metacall(valueType, c, d->valueTypeIndex(), a);
+
+ if (c == QMetaObject::WriteProperty)
+ valueType->write(target, d->propertyIndex(), 0x00);
+
+ return rv;
+
} else {
- return QMetaObject::metacall(target, c, d->propertyIdx, a);
+ return QMetaObject::metacall(target, c, d->propertyIndex(), a);
}
}
@@ -823,8 +838,8 @@ void QDeclarativeVMEMetaObject::connectAlias(int aliasId)
int sigIdx = methodOffset + aliasId + metaData->propertyCount;
QMetaObject::connect(context, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx);
- if (d->propertyIdx != -1) {
- QMetaProperty prop = target->metaObject()->property(d->propertyIdx);
+ if (!d->isObjectAlias()) {
+ QMetaProperty prop = target->metaObject()->property(d->propertyIndex());
if (prop.hasNotifySignal())
QDeclarativePropertyPrivate::connect(target, prop.notifySignalIndex(), object, sigIdx);
}
diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h
index 4ccaa73..5134763 100644
--- a/src/declarative/qml/qdeclarativevmemetaobject_p.h
+++ b/src/declarative/qml/qdeclarativevmemetaobject_p.h
@@ -84,6 +84,25 @@ struct QDeclarativeVMEMetaData
int contextIdx;
int propertyIdx;
int flags;
+
+ bool isObjectAlias() const {
+ return propertyIdx == -1;
+ }
+ bool isPropertyAlias() const {
+ return !isObjectAlias() && !(propertyIdx & 0xFF000000);
+ }
+ bool isValueTypeAlias() const {
+ return !isObjectAlias() && (propertyIdx & 0xFF000000);
+ }
+ int propertyIndex() const {
+ return propertyIdx & 0x0000FFFF;
+ }
+ int valueTypeIndex() const {
+ return (propertyIdx & 0x00FF0000) >> 16;
+ }
+ int valueType() const {
+ return ((unsigned int)propertyIdx) >> 24;
+ }
};
struct PropertyData {