diff options
Diffstat (limited to 'src/declarative/util')
-rw-r--r-- | src/declarative/util/qdeclarativeanimation.cpp | 14 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativelistmodel.cpp | 31 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativepropertychanges.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate.cpp | 3 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestate_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations.cpp | 16 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativestateoperations_p.h | 3 |
7 files changed, 44 insertions, 28 deletions
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 0f7c946..67440b6 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2536,13 +2536,13 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, viaData->pc << vpc; viaData->actions << myAction; QDeclarativeAction dummyAction; - QDeclarativeAction &xAction = pc->xIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &yAction = pc->yIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &sAction = pc->scaleIsSet() ? actions[++i] : dummyAction; - QDeclarativeAction &rAction = pc->rotationIsSet() ? actions[++i] : dummyAction; + QDeclarativeAction &xAction = pc->xIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; + QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); - QDeclarativeItem *targetParent = forward ? pc->parent() : pc->originalParent(); + QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); //### this mirrors the logic in QDeclarativeParentChange. bool ok; @@ -2583,9 +2583,9 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, if (ok && target->transformOrigin() != QDeclarativeItem::TopLeft) { qreal w = target->width(); qreal h = target->height(); - if (pc->widthIsSet()) + if (pc->widthIsSet() && i < actions.size() - 1) w = actions[++i].toValue.toReal(); - if (pc->heightIsSet()) + if (pc->heightIsSet() && i < actions.size() - 1) h = actions[++i].toValue.toReal(); const QPointF &transformOrigin = d->computeTransformOrigin(target->transformOrigin(), w,h); diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 0985a6b..a8e1be8 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -537,10 +537,9 @@ void QDeclarativeListModel::append(const QScriptValue& valuemap) */ QScriptValue QDeclarativeListModel::get(int index) const { - if (index >= count() || index < 0) { + // the internal flat/nested class takes care of return value for bad index + if (index >= count() || index < 0) qmlInfo(this) << tr("get: index %1 out of range").arg(index); - return 0; - } return m_flat ? m_flat->get(index) : m_nested->get(index); } @@ -930,13 +929,14 @@ bool FlatListModel::insert(int index, const QScriptValue &value) QScriptValue FlatListModel::get(int index) const { - Q_ASSERT(index >= 0 && index < m_values.count()); - QScriptEngine *scriptEngine = m_scriptEngine ? m_scriptEngine : QDeclarativeEnginePrivate::getScriptEngine(qmlEngine(m_listModel)); - if (!scriptEngine) + if (!scriptEngine) return 0; + if (index < 0 || index >= m_values.count()) + return scriptEngine->undefinedValue(); + QScriptValue rv = scriptEngine->newObject(); QHash<int, QVariant> row = m_values.at(index); @@ -999,7 +999,8 @@ bool FlatListModel::addValue(const QScriptValue &value, QHash<int, QVariant> *ro QScriptValueIterator it(value); while (it.hasNext()) { it.next(); - if (it.value().isObject()) { + QScriptValue value = it.value(); + if (!value.isVariant() && !value.isRegExp() && !value.isDate() && value.isObject()) { qmlInfo(m_listModel) << "Cannot add nested list values when modifying or after modification from a worker script"; return false; } @@ -1182,13 +1183,21 @@ bool NestedListModel::append(const QScriptValue& valuemap) } QScriptValue NestedListModel::get(int index) const -{ - ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); - if (!node) - return 0; +{ QDeclarativeEngine *eng = qmlEngine(m_listModel); if (!eng) return 0; + + if (index < 0 || index >= count()) { + QScriptEngine *seng = QDeclarativeEnginePrivate::getScriptEngine(eng); + if (seng) + return seng->undefinedValue(); + return 0; + } + + ModelNode *node = qvariant_cast<ModelNode *>(_root->values.at(index)); + if (!node) + return 0; return QDeclarativeEnginePrivate::qmlScriptObject(node->object(this), eng); } diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp index a22c756..12fef36 100644 --- a/src/declarative/util/qdeclarativepropertychanges.cpp +++ b/src/declarative/util/qdeclarativepropertychanges.cpp @@ -179,7 +179,7 @@ public: reverseExpression = rewindExpression; } - virtual void copyOriginals(QDeclarativeActionEvent *other) + /*virtual void copyOriginals(QDeclarativeActionEvent *other) { QDeclarativeReplaceSignalHandler *rsh = static_cast<QDeclarativeReplaceSignalHandler*>(other); saveCurrentValues(); @@ -190,7 +190,7 @@ public: ownedExpression = rsh->ownedExpression; rsh->ownedExpression = 0; } - } + }*/ virtual void rewind() { ownedExpression = QDeclarativePropertyPrivate::setSignalExpression(property, rewindExpression); diff --git a/src/declarative/util/qdeclarativestate.cpp b/src/declarative/util/qdeclarativestate.cpp index ea209aa..b5f7900 100644 --- a/src/declarative/util/qdeclarativestate.cpp +++ b/src/declarative/util/qdeclarativestate.cpp @@ -390,12 +390,13 @@ void QDeclarativeState::apply(QDeclarativeStateGroup *group, QDeclarativeTransit if (action.event->override(event)) { found = true; - if (action.event != d->revertList.at(jj).event) { + if (action.event != d->revertList.at(jj).event && action.event->needsCopy()) { action.event->copyOriginals(d->revertList.at(jj).event); QDeclarativeSimpleAction r(action); additionalReverts << r; d->revertList.removeAt(jj); + --jj; } else if (action.event->isRewindable()) //###why needed? action.event->saveCurrentValues(); diff --git a/src/declarative/util/qdeclarativestate_p.h b/src/declarative/util/qdeclarativestate_p.h index 0ba67b0..25715c6 100644 --- a/src/declarative/util/qdeclarativestate_p.h +++ b/src/declarative/util/qdeclarativestate_p.h @@ -96,6 +96,7 @@ public: virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); virtual void saveOriginals() {} + virtual bool needsCopy() { return false; } virtual void copyOriginals(QDeclarativeActionEvent *) {} virtual bool isRewindable() { return isReversable(); } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index a93a25d..0326f6d 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -408,7 +408,7 @@ void QDeclarativeParentChange::saveOriginals() d->origStackBefore = d->rewindStackBefore; } -void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) +/*void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) { Q_D(QDeclarativeParentChange); QDeclarativeParentChange *pc = static_cast<QDeclarativeParentChange*>(other); @@ -417,7 +417,7 @@ void QDeclarativeParentChange::copyOriginals(QDeclarativeActionEvent *other) d->origStackBefore = pc->d_func()->rewindStackBefore; saveCurrentValues(); -} +}*/ void QDeclarativeParentChange::execute(Reason) { @@ -1241,24 +1241,28 @@ QList<QDeclarativeAction> QDeclarativeAnchorChanges::additionalActions() Q_D(QDeclarativeAnchorChanges); QList<QDeclarativeAction> extra; + QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors; + bool hChange = combined & QDeclarativeAnchors::Horizontal_Mask; + bool vChange = combined & QDeclarativeAnchors::Vertical_Mask; + if (d->target) { QDeclarativeAction a; - if (d->fromX != d->toX) { + if (hChange && d->fromX != d->toX) { a.property = QDeclarativeProperty(d->target, QLatin1String("x")); a.toValue = d->toX; extra << a; } - if (d->fromY != d->toY) { + if (vChange && d->fromY != d->toY) { a.property = QDeclarativeProperty(d->target, QLatin1String("y")); a.toValue = d->toY; extra << a; } - if (d->fromWidth != d->toWidth) { + if (hChange && d->fromWidth != d->toWidth) { a.property = QDeclarativeProperty(d->target, QLatin1String("width")); a.toValue = d->toWidth; extra << a; } - if (d->fromHeight != d->toHeight) { + if (vChange && d->fromHeight != d->toHeight) { a.property = QDeclarativeProperty(d->target, QLatin1String("height")); a.toValue = d->toHeight; extra << a; diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h index e22c1e2..21a86f5 100644 --- a/src/declarative/util/qdeclarativestateoperations_p.h +++ b/src/declarative/util/qdeclarativestateoperations_p.h @@ -107,7 +107,7 @@ public: virtual ActionList actions(); virtual void saveOriginals(); - virtual void copyOriginals(QDeclarativeActionEvent*); + //virtual void copyOriginals(QDeclarativeActionEvent*); virtual void execute(Reason reason = ActualChange); virtual bool isReversable(); virtual void reverse(Reason reason = ActualChange); @@ -277,6 +277,7 @@ public: virtual bool override(QDeclarativeActionEvent*other); virtual bool changesBindings(); virtual void saveOriginals(); + virtual bool needsCopy() { return true; } virtual void copyOriginals(QDeclarativeActionEvent*); virtual void clearBindings(); virtual void rewind(); |