summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-12-11 04:02:12 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-12-11 04:02:12 (GMT)
commit950a09098252c0607376170d7909ef33a4f264ab (patch)
tree512dac052f2b9e702af19705dd30df42fa6352f4 /src/declarative
parent3051067a661db92c77f9cf8c31d3231174a6a475 (diff)
parent2935ec84073898ed4fe700f41ca108d420fb5ba9 (diff)
downloadQt-950a09098252c0607376170d7909ef33a4f264ab.zip
Qt-950a09098252c0607376170d7909ef33a4f264ab.tar.gz
Qt-950a09098252c0607376170d7909ef33a4f264ab.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts: src/declarative/util/qmlopenmetaobject.cpp
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors.cpp55
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p.h5
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h5
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstextinput_p.h1
-rw-r--r--src/declarative/qml/qmlcompiler.cpp3
-rw-r--r--src/declarative/qml/qmlcontextscriptclass.cpp4
-rw-r--r--src/declarative/qml/qmlobjectscriptclass.cpp36
-rw-r--r--src/declarative/qml/qmlobjectscriptclass_p.h9
-rw-r--r--src/declarative/util/qmlanimation.cpp63
-rw-r--r--src/declarative/util/qmlanimation_p.h22
10 files changed, 184 insertions, 19 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
index b72f010..96d76cf 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp
@@ -833,7 +833,10 @@ void QmlGraphicsAnchors::setLeftMargin(qreal offset)
if (d->leftMargin == offset)
return;
d->leftMargin = offset;
- d->updateHorizontalAnchors();
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateHorizontalAnchors();
emit leftMarginChanged();
}
@@ -849,10 +852,38 @@ void QmlGraphicsAnchors::setRightMargin(qreal offset)
if (d->rightMargin == offset)
return;
d->rightMargin = offset;
- d->updateHorizontalAnchors();
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateHorizontalAnchors();
emit rightMarginChanged();
}
+qreal QmlGraphicsAnchors::margins() const
+{
+ Q_D(const QmlGraphicsAnchors);
+ return d->margins;
+}
+
+void QmlGraphicsAnchors::setMargins(qreal offset)
+{
+ Q_D(QmlGraphicsAnchors);
+ if (d->margins == offset)
+ return;
+ //###Is it significantly faster to set them directly so we can call fillChanged only once?
+ if(!d->rightMargin || d->rightMargin == d->margins)
+ setRightMargin(offset);
+ if(!d->leftMargin || d->leftMargin == d->margins)
+ setLeftMargin(offset);
+ if(!d->topMargin || d->topMargin == d->margins)
+ setTopMargin(offset);
+ if(!d->bottomMargin || d->bottomMargin == d->margins)
+ setBottomMargin(offset);
+ d->margins = offset;
+ emit marginsChanged();
+
+}
+
qreal QmlGraphicsAnchors::horizontalCenterOffset() const
{
Q_D(const QmlGraphicsAnchors);
@@ -865,7 +896,10 @@ void QmlGraphicsAnchors::setHorizontalCenterOffset(qreal offset)
if (d->hCenterOffset == offset)
return;
d->hCenterOffset = offset;
- d->updateHorizontalAnchors();
+ if(d->centerIn)
+ d->centerInChanged();
+ else
+ d->updateHorizontalAnchors();
emit horizontalCenterOffsetChanged();
}
@@ -881,7 +915,10 @@ void QmlGraphicsAnchors::setTopMargin(qreal offset)
if (d->topMargin == offset)
return;
d->topMargin = offset;
- d->updateVerticalAnchors();
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateVerticalAnchors();
emit topMarginChanged();
}
@@ -897,7 +934,10 @@ void QmlGraphicsAnchors::setBottomMargin(qreal offset)
if (d->bottomMargin == offset)
return;
d->bottomMargin = offset;
- d->updateVerticalAnchors();
+ if(d->fill)
+ d->fillChanged();
+ else
+ d->updateVerticalAnchors();
emit bottomMarginChanged();
}
@@ -913,7 +953,10 @@ void QmlGraphicsAnchors::setVerticalCenterOffset(qreal offset)
if (d->vCenterOffset == offset)
return;
d->vCenterOffset = offset;
- d->updateVerticalAnchors();
+ if(d->centerIn)
+ d->centerInChanged();
+ else
+ d->updateVerticalAnchors();
emit verticalCenterOffsetChanged();
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p.h
index 2f2ca74..a67a9f8 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p.h
@@ -67,6 +67,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsAnchors : public QObject
Q_PROPERTY(QmlGraphicsAnchorLine bottom READ bottom WRITE setBottom RESET resetBottom NOTIFY bottomChanged)
Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter WRITE setVerticalCenter RESET resetVerticalCenter NOTIFY verticalCenterChanged)
Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline WRITE setBaseline RESET resetBaseline NOTIFY baselineChanged)
+ Q_PROPERTY(qreal margins READ margins WRITE setMargins NOTIFY marginsChanged)
Q_PROPERTY(qreal leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged)
Q_PROPERTY(qreal rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged)
Q_PROPERTY(qreal horizontalCenterOffset READ horizontalCenterOffset WRITE setHorizontalCenterOffset NOTIFY horizontalCenterOffsetChanged())
@@ -137,6 +138,9 @@ public:
qreal bottomMargin() const;
void setBottomMargin(qreal);
+ qreal margins() const;
+ void setMargins(qreal);
+
qreal verticalCenterOffset() const;
void setVerticalCenterOffset(qreal);
@@ -172,6 +176,7 @@ Q_SIGNALS:
void rightMarginChanged();
void topMarginChanged();
void bottomMarginChanged();
+ void marginsChanged();
void verticalCenterOffsetChanged();
void horizontalCenterOffsetChanged();
void baselineOffsetChanged();
diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
index be3b6dc..4f7fde0 100644
--- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h
@@ -98,8 +98,8 @@ public:
QmlGraphicsAnchorsPrivate()
: updatingMe(false), updatingHorizontalAnchor(0),
updatingVerticalAnchor(0), updatingFill(0), updatingCenterIn(0), item(0), usedAnchors(0), fill(0),
- centerIn(0), leftMargin(0), rightMargin(0), topMargin(0),
- bottomMargin(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
+ centerIn(0), leftMargin(0), rightMargin(0), topMargin(0), bottomMargin(0),
+ margins(0), vCenterOffset(0), hCenterOffset(0), baselineOffset(0),
componentComplete(true)
{
}
@@ -159,6 +159,7 @@ public:
qreal rightMargin;
qreal topMargin;
qreal bottomMargin;
+ qreal margins;
qreal vCenterOffset;
qreal hCenterOffset;
qreal baselineOffset;
diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
index c22c637..85b8beb 100644
--- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h
@@ -72,6 +72,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsTextInput : public QmlGraphicsPaintedItem
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible)
Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
+ Q_PROPERTY(QRect cursorRect READ cursorRect NOTIFY cursorPositionChanged)
Q_PROPERTY(QmlComponent *cursorDelegate READ cursorDelegate WRITE setCursorDelegate)
Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 108e3cc..f9a9b1b 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1933,6 +1933,9 @@ bool QmlCompiler::buildPropertyObjectAssignment(QmlParser::Property *prop,
Q_ASSERT(prop->index != -1);
Q_ASSERT(v->object->type != -1);
+ if (!obj->metaObject()->property(prop->index).isWritable())
+ COMPILE_EXCEPTION(v, QCoreApplication::translate("QmlCompiler","Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop->name)));
+
if (QmlMetaType::isInterface(prop->type)) {
// Assigning an object to an interface ptr property
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp
index 5635ceb..54a5ca3 100644
--- a/src/declarative/qml/qmlcontextscriptclass.cpp
+++ b/src/declarative/qml/qmlcontextscriptclass.cpp
@@ -173,7 +173,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje
if (scopeObject) {
QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(scopeObject, name, flags, bindContext);
+ ep->objectClass->queryProperty(scopeObject, name, flags, bindContext, QmlObjectScriptClass::ImplicitObject);
if (rv) {
lastScopeObject = scopeObject;
lastContext = bindContext;
@@ -183,7 +183,7 @@ QmlContextScriptClass::queryProperty(QmlContext *bindContext, QObject *scopeObje
for (int ii = cp->defaultObjects.count() - 1; ii >= 0; --ii) {
QScriptClass::QueryFlags rv =
- ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext);
+ ep->objectClass->queryProperty(cp->defaultObjects.at(ii), name, flags, bindContext, QmlObjectScriptClass::ImplicitObject);
if (rv) {
lastDefaultObject = ii;
diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp
index 7a2b132..3d0581d 100644
--- a/src/declarative/qml/qmlobjectscriptclass.cpp
+++ b/src/declarative/qml/qmlobjectscriptclass.cpp
@@ -123,7 +123,8 @@ QmlObjectScriptClass::queryProperty(Object *object, const Identifier &name,
QScriptClass::QueryFlags
QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
- QScriptClass::QueryFlags flags, QmlContext *evalContext)
+ QScriptClass::QueryFlags flags, QmlContext *evalContext,
+ QueryHints hints)
{
Q_UNUSED(flags);
lastData = 0;
@@ -155,12 +156,8 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
lastData = &local;
}
- if (lastData) {
- QScriptClass::QueryFlags rv = QScriptClass::HandlesReadAccess;
- if (lastData->flags & QmlPropertyCache::Data::IsWritable)
- rv |= QScriptClass::HandlesWriteAccess;
- return rv;
- }
+ if (lastData)
+ return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
if (!evalContext && context()) {
// Global object, QScriptContext activation object, QmlContext object
@@ -183,6 +180,12 @@ QmlObjectScriptClass::queryProperty(QObject *obj, const Identifier &name,
}
}
+ if (!(hints & ImplicitObject)) {
+ local.coreIndex = -1;
+ lastData = &local;
+ return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess;
+ }
+
return 0;
}
@@ -198,6 +201,9 @@ QScriptValue QmlObjectScriptClass::property(QObject *obj, const Identifier &name
else if (name == m_toStringId.identifier)
return m_toString;
+ if (lastData && !lastData->isValid())
+ return QmlEnginePrivate::getScriptEngine(engine)->undefinedValue();
+
Q_ASSERT(obj);
QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine);
@@ -267,6 +273,22 @@ void QmlObjectScriptClass::setProperty(QObject *obj,
Q_ASSERT(obj);
Q_ASSERT(lastData);
+ if (!lastData->isValid()) {
+ QString error = QLatin1String("Cannot assign to non-existant property \"") +
+ toString(name) + QLatin1Char('\"');
+ if (context())
+ context()->throwError(error);
+ return;
+ }
+
+ if (!(lastData->flags & QmlPropertyCache::Data::IsWritable)) {
+ QString error = QLatin1String("Cannot assign to read-only property \"") +
+ toString(name) + QLatin1Char('\"');
+ if (context())
+ context()->throwError(error);
+ return;
+ }
+
QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine);
if (!evalContext && context()) {
diff --git a/src/declarative/qml/qmlobjectscriptclass_p.h b/src/declarative/qml/qmlobjectscriptclass_p.h
index d8ef1d2..20c68ce 100644
--- a/src/declarative/qml/qmlobjectscriptclass_p.h
+++ b/src/declarative/qml/qmlobjectscriptclass_p.h
@@ -76,11 +76,16 @@ public:
QObject *toQObject(const QScriptValue &) const;
int objectType(const QScriptValue &) const;
- enum QueryMode { IncludeAttachedProperties, SkipAttachedProperties };
+ enum QueryHint {
+ ImplicitObject = 0x01,
+ SkipAttachedProperties = 0x02
+ };
+ Q_DECLARE_FLAGS(QueryHints, QueryHint)
QScriptClass::QueryFlags queryProperty(QObject *, const Identifier &,
QScriptClass::QueryFlags flags,
- QmlContext *evalContext);
+ QmlContext *evalContext,
+ QueryHints hints = 0);
QScriptValue property(QObject *, const Identifier &);
void setProperty(QObject *, const Identifier &name, const QScriptValue &,
QmlContext *evalContext = 0);
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index a4f67ac..4c5015d 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -247,6 +247,11 @@ void QmlAbstractAnimation::setRunning(bool r)
d->running = r;
if (d->running) {
+ if (d->alwaysRunToEnd && d->repeat
+ && qtAnimation()->state() == QAbstractAnimation::Running) {
+ qtAnimation()->setLoopCount(-1);
+ }
+
if (!d->connectedTimeLine) {
QObject::connect(qtAnimation(), SIGNAL(finished()),
this, SLOT(timelineComplete()));
@@ -1367,6 +1372,64 @@ void QmlNumberAnimation::setTo(qreal t)
QML_DEFINE_TYPE(Qt,4,6,NumberAnimation,QmlNumberAnimation)
+/*!
+ \qmlclass Vector3dAnimation QmlVector3dAnimation
+ \inherits PropertyAnimation
+ \brief The Vector3dAnimation element allows you to animate changes in properties of type QVector3d.
+*/
+
+/*!
+ \internal
+ \class QmlVector3dAnimation
+*/
+
+QmlVector3dAnimation::QmlVector3dAnimation(QObject *parent)
+: QmlPropertyAnimation(parent)
+{
+ Q_D(QmlPropertyAnimation);
+ d->interpolatorType = QMetaType::QVector3D;
+ d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
+ d->defaultToInterpolatorType = true;
+}
+
+QmlVector3dAnimation::~QmlVector3dAnimation()
+{
+}
+
+/*!
+ \qmlproperty real Vector3dAnimation::from
+ This property holds the starting value.
+ If not set, then the value defined in the start state of the transition.
+*/
+QVector3D QmlVector3dAnimation::from() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->from.value<QVector3D>();
+}
+
+void QmlVector3dAnimation::setFrom(QVector3D f)
+{
+ QmlPropertyAnimation::setFrom(f);
+}
+
+/*!
+ \qmlproperty real Vector3dAnimation::to
+ This property holds the ending value.
+ If not set, then the value defined in the end state of the transition.
+*/
+QVector3D QmlVector3dAnimation::to() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->to.value<QVector3D>();
+}
+
+void QmlVector3dAnimation::setTo(QVector3D t)
+{
+ QmlPropertyAnimation::setTo(t);
+}
+
+QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation)
+
QmlAnimationGroup::QmlAnimationGroup(QObject *parent)
: QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent)
{
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 322f048..a52c36e 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -44,6 +44,7 @@
#include "qmltransition_p.h"
#include "qmlstate_p.h"
+#include <QtGui/qvector3d.h>
#include <qmlpropertyvaluesource.h>
#include <qml.h>
@@ -351,6 +352,26 @@ public:
void setTo(qreal);
};
+class Q_AUTOTEST_EXPORT QmlVector3dAnimation : public QmlPropertyAnimation
+{
+
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlPropertyAnimation)
+
+ Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
+
+public:
+ QmlVector3dAnimation(QObject *parent=0);
+ virtual ~QmlVector3dAnimation();
+
+ QVector3D from() const;
+ void setFrom(QVector3D);
+
+ QVector3D to() const;
+ void setTo(QVector3D);
+};
+
class QmlAnimationGroupPrivate;
class QmlAnimationGroup : public QmlAbstractAnimation
{
@@ -414,6 +435,7 @@ QML_DECLARE_TYPE(QmlColorAnimation)
QML_DECLARE_TYPE(QmlNumberAnimation)
QML_DECLARE_TYPE(QmlSequentialAnimation)
QML_DECLARE_TYPE(QmlParallelAnimation)
+QML_DECLARE_TYPE(QmlVector3dAnimation)
QT_END_HEADER