summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-12-07 03:50:34 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-12-07 03:50:34 (GMT)
commit25657bfa7588d6df713d4e15cebc23556b489693 (patch)
treebefa4a56e8d7c7bf0428a7a6bd637d14f1928721 /src/declarative
parent856b2cb8cdd0a5493f555b3d622fb819af9d826d (diff)
parent55a3fda3baf545cc7fbfa6b2c00705be40a7319b (diff)
downloadQt-25657bfa7588d6df713d4e15cebc23556b489693.zip
Qt-25657bfa7588d6df713d4e15cebc23556b489693.tar.gz
Qt-25657bfa7588d6df713d4e15cebc23556b489693.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem_p.h2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext.cpp28
-rw-r--r--src/declarative/graphicsitems/qmlgraphicstext_p_p.h10
-rw-r--r--src/declarative/util/qmlanimation.cpp152
-rw-r--r--src/declarative/util/qmlanimation_p.h21
-rw-r--r--src/declarative/util/qmlanimation_p_p.h21
-rw-r--r--src/declarative/util/qmltransition.cpp31
7 files changed, 160 insertions, 105 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
index 82950c2..a8d77ea 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h
@@ -119,8 +119,6 @@ public:
heightIdx = QmlGraphicsItem::staticMetaObject.indexOfSignal("heightChanged()");
}
}
- ~QmlGraphicsItemPrivate()
- { delete _anchors; }
void init(QmlGraphicsItem *parent)
{
diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp
index ad12189..03baaae 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp
@@ -483,19 +483,19 @@ void QmlGraphicsTextPrivate::updateSize()
//setup instance of QTextLayout for all cases other than richtext
if (!richText)
- {
- tmp = text;
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
- singleline = !tmp.contains(QChar::LineSeparator);
- if (singleline && elideMode != QmlGraphicsText::ElideNone && q->widthValid())
- tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
- layout.clearLayout();
- layout.setFont(font);
- layout.setText(tmp);
- size = setupTextLayout(&layout);
- cachedLayoutSize = size;
- }
- if (richText) {
+ {
+ tmp = text;
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ singleline = !tmp.contains(QChar::LineSeparator);
+ if (singleline && elideMode != QmlGraphicsText::ElideNone && q->widthValid())
+ tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...?
+ layout.clearLayout();
+ layout.setFont(font);
+ layout.setText(tmp);
+ size = setupTextLayout(&layout);
+ cachedLayoutSize = size;
+ dy -= size.height();
+ } else {
singleline = false; // richtext can't elide or be optimized for single-line case
doc->setDefaultFont(font);
QTextOption option((Qt::Alignment)int(hAlign | vAlign));
@@ -509,8 +509,6 @@ void QmlGraphicsTextPrivate::updateSize()
else
doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug)
dy -= (int)doc->size().height();
- } else {
- dy -= size.height();
}
int yoff = 0;
diff --git a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
index 0ddae57..6fbee50 100644
--- a/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
+++ b/src/declarative/graphicsitems/qmlgraphicstext_p_p.h
@@ -101,11 +101,11 @@ public:
QPixmap imgStyleCache;
QmlGraphicsText::HAlignment hAlign;
QmlGraphicsText::VAlignment vAlign;
- QmlGraphicsText::TextElideMode elideMode;
- bool dirty;
- bool wrap;
- bool richText;
- bool singleline;
+ QmlGraphicsText::TextElideMode elideMode;
+ bool dirty:1;
+ bool wrap:1;
+ bool richText:1;
+ bool singleline:1;
QTextControl *control;
QTextDocument *doc;
QTextLayout layout;
diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp
index 00e3056..8afe667 100644
--- a/src/declarative/util/qmlanimation.cpp
+++ b/src/declarative/util/qmlanimation.cpp
@@ -422,50 +422,6 @@ void QmlAbstractAnimation::setGroup(QmlAnimationGroup *g)
setParent(g);
}
-QObject *QmlAbstractAnimation::target() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->target;
-}
-
-void QmlAbstractAnimation::setTarget(QObject *o)
-{
- Q_D(QmlAbstractAnimation);
- if (d->target == o)
- return;
-
- d->target = o;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
- emit targetChanged(d->target, d->propertyName);
-}
-
-QString QmlAbstractAnimation::property() const
-{
- Q_D(const QmlAbstractAnimation);
- return d->propertyName;
-}
-
-void QmlAbstractAnimation::setProperty(const QString &n)
-{
- Q_D(QmlAbstractAnimation);
- if (d->propertyName == n)
- return;
-
- d->propertyName = n;
- if (d->target && !d->propertyName.isEmpty()) {
- d->userProperty = d->createProperty(d->target, d->propertyName, this);
- } else {
- d->userProperty.invalidate();
- }
-
- emit targetChanged(d->target, d->propertyName);
-}
-
/*!
\qmlmethod Animation::start()
\brief Starts the animation.
@@ -886,6 +842,28 @@ void QmlPropertyActionPrivate::init()
is being used. Refer to the \l animation documentation for details.
*/
+QObject *QmlPropertyAction::target() const
+{
+ Q_D(const QmlPropertyAction);
+ return d->target;
+}
+
+void QmlPropertyAction::setTarget(QObject *o)
+{
+ Q_D(QmlPropertyAction);
+ if (d->target == o)
+ return;
+
+ d->target = o;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAction::property
This property holds an explicit property to animated.
@@ -894,6 +872,28 @@ void QmlPropertyActionPrivate::init()
is being used. Refer to the \l animation documentation for details.
*/
+QString QmlPropertyAction::property() const
+{
+ Q_D(const QmlPropertyAction);
+ return d->propertyName;
+}
+
+void QmlPropertyAction::setProperty(const QString &n)
+{
+ Q_D(QmlPropertyAction);
+ if (d->propertyName == n)
+ return;
+
+ d->propertyName = n;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAction::matchProperties
This property holds a comma-separated list of property names this action
@@ -1445,10 +1445,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions,
}
//needed for Behavior
- if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
+ if (d->userProperty.isValid()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
- }
+ }
for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) {
d->animations.at(ii)->transition(actions, modified, direction);
@@ -1517,7 +1517,7 @@ void QmlParallelAnimation::transition(QmlStateActions &actions,
Q_D(QmlAnimationGroup);
//needed for Behavior
- if (d->userProperty.isValid() && d->propertyName.isEmpty() && !target()) {
+ if (d->userProperty.isValid()) {
for (int i = 0; i < d->animations.count(); ++i)
d->animations.at(i)->setTarget(d->userProperty);
}
@@ -1608,9 +1608,6 @@ void QmlPropertyAnimationPrivate::init()
Q_Q(QmlPropertyAnimation);
va = new QmlTimeLineValueAnimator;
QmlGraphics_setParent_noEvent(va, q);
-
- va->setStartValue(QVariant(0.0f));
- va->setEndValue(QVariant(1.0f));
}
/*!
@@ -1884,6 +1881,28 @@ void QmlPropertyAnimation::setEasing(const QString &e)
\sa property matchTargets
*/
+QObject *QmlPropertyAnimation::target() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->target;
+}
+
+void QmlPropertyAnimation::setTarget(QObject *o)
+{
+ Q_D(QmlPropertyAnimation);
+ if (d->target == o)
+ return;
+
+ d->target = o;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAnimation::property
This property holds an explicit property name to animate.
@@ -1894,6 +1913,28 @@ void QmlPropertyAnimation::setEasing(const QString &e)
\sa target matchProperties
*/
+QString QmlPropertyAnimation::property() const
+{
+ Q_D(const QmlPropertyAnimation);
+ return d->propertyName;
+}
+
+void QmlPropertyAnimation::setProperty(const QString &n)
+{
+ Q_D(QmlPropertyAnimation);
+ if (d->propertyName == n)
+ return;
+
+ d->propertyName = n;
+ if (d->target && !d->propertyName.isEmpty()) {
+ d->userProperty = d->createProperty(d->target, d->propertyName, this);
+ } else {
+ d->userProperty.invalidate();
+ }
+
+ emit targetChanged(d->target, d->propertyName);
+}
+
/*!
\qmlproperty string PropertyAnimation::matchProperties
This property holds a comma-separated list of property names this animation
@@ -2022,6 +2063,12 @@ void QmlPropertyAnimation::prepare(QmlMetaProperty &p)
else
d->property = d->userProperty;
+ if (!d->rangeIsSet) {
+ d->va->setStartValue(QVariant(0.0f));
+ d->va->setEndValue(QVariant(1.0f));
+ d->rangeIsSet = true;
+ }
+
int propType = d->property.propertyType();
d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType);
if (d->fromIsDefined)
@@ -2179,6 +2226,11 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions,
}
if (data->actions.count()) {
+ if (!d->rangeIsSet) {
+ d->va->setStartValue(QVariant(0.0f));
+ d->va->setEndValue(QVariant(1.0f));
+ d->rangeIsSet = true;
+ }
d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped);
} else {
delete data;
diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h
index 707ed33..322f048 100644
--- a/src/declarative/util/qmlanimation_p.h
+++ b/src/declarative/util/qmlanimation_p.h
@@ -94,12 +94,6 @@ public:
QmlAnimationGroup *group() const;
void setGroup(QmlAnimationGroup *);
- //### these belong at a lower level in the hierarchy
- QObject *target() const;
- void setTarget(QObject *);
- QString property() const;
- void setProperty(const QString &);
-
virtual void setTarget(const QmlMetaProperty &);
void classBegin();
@@ -111,7 +105,6 @@ Q_SIGNALS:
void runningChanged(bool);
void pausedChanged(bool);
void repeatChanged(bool);
- void targetChanged(QObject *, const QString &);
void alwaysRunToEndChanged(bool);
public Q_SLOTS:
@@ -202,6 +195,12 @@ public:
QmlPropertyAction(QObject *parent=0);
virtual ~QmlPropertyAction();
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
QString properties() const;
void setProperties(const QString &);
@@ -214,6 +213,7 @@ public:
Q_SIGNALS:
void valueChanged(const QVariant &);
void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
protected:
virtual void transition(QmlStateActions &actions,
@@ -286,6 +286,12 @@ public:
QString easing() const;
void setEasing(const QString &);
+ QObject *target() const;
+ void setTarget(QObject *);
+
+ QString property() const;
+ void setProperty(const QString &);
+
QString properties() const;
void setProperties(const QString &);
@@ -305,6 +311,7 @@ Q_SIGNALS:
void toChanged(QVariant);
void easingChanged(const QString &);
void propertiesChanged(const QString &);
+ void targetChanged(QObject *, const QString &);
};
class Q_AUTOTEST_EXPORT QmlColorAnimation : public QmlPropertyAnimation
diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h
index 71b6caa..fbd7114 100644
--- a/src/declarative/util/qmlanimation_p_p.h
+++ b/src/declarative/util/qmlanimation_p_p.h
@@ -203,7 +203,7 @@ public:
QmlAbstractAnimationPrivate()
: running(false), paused(false), alwaysRunToEnd(false), repeat(false),
connectedTimeLine(false), componentComplete(true), startOnCompletion(false),
- target(0), group(0) {}
+ group(0) {}
bool running:1;
bool paused:1;
@@ -217,8 +217,6 @@ public:
void commence();
QmlNullableValue<QmlMetaProperty> userProperty;
- QObject *target;
- QString propertyName;
QmlMetaProperty property;
QmlAnimationGroup *group;
@@ -264,10 +262,12 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAction)
public:
QmlPropertyActionPrivate()
- : QmlAbstractAnimationPrivate(), proxy(this), spa(0) {}
+ : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {}
void init();
+ QObject *target;
+ QString propertyName;
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;
@@ -342,8 +342,8 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QmlPropertyAnimation)
public:
QmlPropertyAnimationPrivate()
- : QmlAbstractAnimationPrivate(), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
+ : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
+ rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0),
value(this, &QmlPropertyAnimationPrivate::valueChanged) {}
void init();
@@ -353,14 +353,17 @@ public:
QString easing;
+ QObject *target;
+ QString propertyName;
QString properties;
QList<QObject *> targets;
QList<QObject *> exclude;
bool fromSourced;
- bool fromIsDefined;
- bool toIsDefined;
- bool defaultToInterpolatorType;
+ bool fromIsDefined:1;
+ bool toIsDefined:1;
+ bool rangeIsSet:1;
+ bool defaultToInterpolatorType:1;
int interpolatorType;
QVariantAnimation::Interpolator interpolator;
diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp
index ec92cf9..b96ff61 100644
--- a/src/declarative/util/qmltransition.cpp
+++ b/src/declarative/util/qmltransition.cpp
@@ -83,22 +83,21 @@ class QmlTransitionPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlTransition)
public:
QmlTransitionPrivate() : fromState(QLatin1String("*")), toState(QLatin1String("*"))
- , reversed(false), reversible(false), group(0), endState(0)
+ , reversed(false), reversible(false), endState(0)
{
- operations.parent = this;
+ animations.parent = this;
}
QString fromState;
QString toState;
bool reversed;
bool reversible;
- ParallelAnimationWrapper *group;
+ ParallelAnimationWrapper group;
QmlTransitionManager *endState;
void init()
{
- group = new ParallelAnimationWrapper;
- group->trans = this;
+ group.trans = this;
}
void complete()
@@ -115,13 +114,13 @@ public:
QmlTransitionPrivate *parent;
};
- AnimationList operations;
+ AnimationList animations;
};
void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a)
{
QmlConcreteList<QmlAbstractAnimation *>::append(a);
- parent->group->addAnimation(a->qtAnimation());
+ parent->group.addAnimation(a->qtAnimation());
}
void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
@@ -146,14 +145,12 @@ QmlTransition::QmlTransition(QObject *parent)
QmlTransition::~QmlTransition()
{
- Q_D(QmlTransition);
- delete d->group;
}
void QmlTransition::stop()
{
Q_D(QmlTransition);
- d->group->stop();
+ d->group.stop();
}
void QmlTransition::setReversed(bool r)
@@ -169,18 +166,18 @@ void QmlTransition::prepare(QmlStateOperation::ActionList &actions,
Q_D(QmlTransition);
if (d->reversed) {
- for (int ii = d->operations.count() - 1; ii >= 0; --ii) {
- d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Backward);
+ for (int ii = d->animations.count() - 1; ii >= 0; --ii) {
+ d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Backward);
}
} else {
- for (int ii = 0; ii < d->operations.count(); ++ii) {
- d->operations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward);
+ for (int ii = 0; ii < d->animations.count(); ++ii) {
+ d->animations.at(ii)->transition(actions, after, QmlAbstractAnimation::Forward);
}
}
d->endState = endState;
- d->group->setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
- d->group->start();
+ d->group.setDirection(d->reversed ? QAbstractAnimation::Backward : QAbstractAnimation::Forward);
+ d->group.start();
}
/*!
@@ -254,7 +251,7 @@ void QmlTransition::setToState(const QString &t)
QmlList<QmlAbstractAnimation *>* QmlTransition::animations()
{
Q_D(QmlTransition);
- return &d->operations;
+ return &d->animations;
}
QT_END_NAMESPACE