42 #include "private/qdeclarativestateoperations_p.h" 52 #include "private/qdeclarativecontext_p.h" 53 #include "private/qdeclarativeproperty_p.h" 54 #include "private/qdeclarativebinding_p.h" 55 #include "private/qdeclarativestate_p_p.h" 57 #include <QtCore/qdebug.h> 58 #include <QtGui/qgraphicsitem.h> 66 #include <QtCore/qmath.h> 68 #include <private/qobject_p.h> 117 if (ok && !isRotate) {
118 if (transform.
m11() == transform.
m22())
119 scale = transform.
m11();
124 }
else if (ok && isRotate) {
125 if (transform.
m11() == transform.
m22())
126 scale =
qSqrt(transform.
m11()*transform.
m11() + transform.
m12()*transform.
m12());
153 t.
scale(scale, scale);
233 return d->xString.value;
239 qreal realValue =
string.toFloat(&ok);
256 return d->xString.isValid();
262 return d->yString.value;
275 return d->yString.isValid();
281 return d->widthString.value;
294 return d->widthString.isValid();
300 return d->heightString.value;
313 return d->heightString.isValid();
319 return d->scaleString.value;
332 return d->scaleString.isValid();
338 return d->rotationString.value;
351 return d->rotationString.isValid();
357 return d->origParent;
400 if (!
d->target || !
d->parent)
411 if (
d->xString.isValid()) {
412 if (
d->x.isValid()) {
427 if (
d->yString.isValid()) {
428 if (
d->y.isValid()) {
443 if (
d->scaleString.isValid()) {
444 if (
d->scale.isValid()) {
459 if (
d->rotationString.isValid()) {
460 if (
d->rotation.isValid()) {
475 if (
d->widthString.isValid()) {
476 if (
d->width.isValid()) {
491 if (
d->heightString.isValid()) {
492 if (
d->height.isValid()) {
517 return d->siblingIndex;
525 d->origParent =
d->rewindParent;
526 d->origStackBefore =
d->rewindStackBefore;
543 d->doChange(
d->parent);
554 d->doChange(
d->origParent,
d->origStackBefore);
568 return (
d->target == otherPC->object());
577 d->rewindStackBefore = 0;
581 d->rewindParent =
d->target->parentItem();
582 d->rewindStackBefore = 0;
584 if (!
d->rewindParent)
590 for (
int i = 0; i < children.
count(); ++i) {
595 d->rewindStackBefore = child;
604 d->doChange(
d->rewindParent,
d->rewindStackBefore);
690 if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
691 expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
751 : usedAnchors(0), resetAnchors(0), fill(0),
816 return d->bottomScript;
823 d->bottomScript = edge;
839 return d->vCenterScript;
846 d->vCenterScript = edge;
862 return d->baselineScript;
869 d->baselineScript = edge;
885 return d->leftScript;
892 d->leftScript = edge;
908 return d->rightScript;
915 d->rightScript = edge;
931 return d->hCenterScript;
938 d->hCenterScript = edge;
991 leftBinding(0), rightBinding(0), hCenterBinding(0),
992 topBinding(0), bottomBinding(0), vCenterBinding(0), baselineBinding(0),
993 origLeftBinding(0), origRightBinding(0), origHCenterBinding(0),
994 origTopBinding(0), origBottomBinding(0), origVCenterBinding(0),
995 origBaselineBinding(0)
1087 d->leftBinding =
d->rightBinding =
d->hCenterBinding =
d->topBinding
1088 =
d->bottomBinding =
d->vCenterBinding =
d->baselineBinding = 0;
1102 d->leftBinding->setTarget(
d->leftProp);
1105 d->rightBinding =
new QDeclarativeBinding(
d->anchorSet->d_func()->rightScript.script(),
d->target, ctxt);
1106 d->rightBinding->setTarget(
d->rightProp);
1109 d->hCenterBinding =
new QDeclarativeBinding(
d->anchorSet->d_func()->hCenterScript.script(),
d->target, ctxt);
1110 d->hCenterBinding->setTarget(
d->hCenterProp);
1114 d->topBinding->setTarget(
d->topProp);
1117 d->bottomBinding =
new QDeclarativeBinding(
d->anchorSet->d_func()->bottomScript.script(),
d->target, ctxt);
1118 d->bottomBinding->setTarget(
d->bottomProp);
1121 d->vCenterBinding =
new QDeclarativeBinding(
d->anchorSet->d_func()->vCenterScript.script(),
d->target, ctxt);
1122 d->vCenterBinding->setTarget(
d->vCenterProp);
1125 d->baselineBinding =
new QDeclarativeBinding(
d->anchorSet->d_func()->baselineScript.script(),
d->target, ctxt);
1126 d->baselineBinding->setTarget(
d->baselineProp);
1137 return d->anchorSet;
1184 if (
d->applyOrigLeft) {
1185 if (!
d->origLeftBinding)
1189 if (
d->applyOrigRight) {
1190 if (!
d->origRightBinding)
1194 if (
d->applyOrigHCenter) {
1195 if (!
d->origHCenterBinding)
1199 if (
d->applyOrigTop) {
1200 if (!
d->origTopBinding)
1204 if (
d->applyOrigBottom) {
1205 if (!
d->origBottomBinding)
1209 if (
d->applyOrigVCenter) {
1210 if (!
d->origVCenterBinding)
1214 if (
d->applyOrigBaseline) {
1215 if (!
d->origBaselineBinding)
1222 for (
int i = 0; i <
d->oldBindings.size(); ++i) {
1227 d->oldBindings.clear();
1263 if (
d->rightBinding)
1265 if (
d->hCenterBinding)
1269 if (
d->bottomBinding)
1271 if (
d->vCenterBinding)
1273 if (
d->baselineBinding)
1290 if (
d->leftBinding) {
1294 d->leftBinding->destroy();
d->leftBinding = 0;
1297 if (
d->rightBinding) {
1301 d->rightBinding->destroy();
d->rightBinding = 0;
1304 if (
d->hCenterBinding) {
1308 d->hCenterBinding->destroy();
d->hCenterBinding = 0;
1311 if (
d->topBinding) {
1315 d->topBinding->destroy();
d->topBinding = 0;
1318 if (
d->bottomBinding) {
1322 d->bottomBinding->destroy();
d->bottomBinding = 0;
1325 if (
d->vCenterBinding) {
1329 d->vCenterBinding->destroy();
d->vCenterBinding = 0;
1332 if (
d->baselineBinding) {
1336 d->baselineBinding->destroy();
d->baselineBinding = 0;
1341 if (
d->origLeftBinding)
1343 if (
d->origRightBinding)
1345 if (
d->origHCenterBinding)
1347 if (
d->origTopBinding)
1349 if (
d->origBottomBinding)
1351 if (
d->origVCenterBinding)
1353 if (
d->origBaselineBinding)
1362 bool stateSetWidth = (stateHAnchors &&
1366 bool origSetWidth = (origHAnchors &&
1370 if (
d->origWidth.isValid() && stateSetWidth && !origSetWidth)
1371 d->target->setWidth(
d->origWidth.value);
1373 bool stateSetHeight = (stateVAnchors &&
1378 bool origSetHeight = (origVAnchors &&
1383 if (
d->origHeight.isValid() && stateSetHeight && !origSetHeight)
1384 d->target->setHeight(
d->origHeight.value);
1386 if (stateHAnchors && !origHAnchors)
1387 d->target->setX(
d->origX);
1389 if (stateVAnchors && !origVAnchors)
1390 d->target->setY(
d->origY);
1403 QDeclarativeAnchors::Anchors combined =
d->anchorSet->d_func()->usedAnchors |
d->anchorSet->d_func()->resetAnchors;
1410 if (hChange &&
d->fromX !=
d->toX) {
1415 if (vChange &&
d->fromY !=
d->toY) {
1420 if (hChange &&
d->fromWidth !=
d->toWidth) {
1425 if (vChange &&
d->fromHeight !=
d->toHeight) {
1456 d->origWidth =
d->target->width();
1458 d->origHeight =
d->target->height();
1459 d->origX =
d->target->x();
1460 d->origY =
d->target->y();
1462 d->applyOrigLeft =
d->applyOrigRight =
d->applyOrigHCenter =
d->applyOrigTop
1463 =
d->applyOrigBottom =
d->applyOrigVCenter =
d->applyOrigBaseline =
false;
1499 d->oldBindings.clear();
1513 d->fromX =
d->target->x();
1514 d->fromY =
d->target->y();
1515 d->fromWidth =
d->target->width();
1516 d->fromHeight =
d->target->height();
1522 QDeclarativeAnchors::Anchors combined =
d->anchorSet->d_func()->resetAnchors |
1523 d->anchorSet->d_func()->usedAnchors;
1558 if (static_cast<QDeclarativeActionEvent*>(
this) == other)
1560 if (static_cast<QDeclarativeAnchorChanges*>(other)->object() ==
object())
1574 d->target->setX(
d->rewindX);
1575 d->target->setY(
d->rewindY);
1577 d->target->setWidth(
d->rewindWidth);
1580 d->target->setHeight(
d->rewindHeight);
1599 d->rewindX =
d->target->x();
1600 d->rewindY =
d->target->y();
1601 d->rewindWidth =
d->target->width();
1602 d->rewindHeight =
d->target->height();
1611 d->toX =
d->target->x();
1612 d->toY =
d->target->y();
1613 d->toWidth =
d->target->width();
1614 d->toHeight =
d->target->height();
1617 #include <qdeclarativestateoperations.moc> 1618 #include <moc_qdeclarativestateoperations_p.cpp>
QDeclarativeNullableValue< QDeclarativeScriptString > rotationString
virtual ActionList actions()
QDeclarativeAnchorLine rewindBottom
QDeclarativeAnchorChanges(QObject *parent=0)
~QDeclarativeAnchorChangesPrivate()
void setLeft(const QDeclarativeScriptString &edge)
QDeclarativeGuard< QDeclarativeItem > parent
static QDeclarativeData * get(const QObject *object, bool create=false)
QDeclarativeProperty property
QDeclarativeStateChangeScriptPrivate()
#define QT_END_NAMESPACE
This macro expands to.
void tryReal(QDeclarativeNullableValue< qreal > &value, const QString &string)
virtual QString typeName() const
void resetHorizontalCenter()
QScopedPointer< QGraphicsItemPrivate > d_ptr
QDeclarativeAbstractBinding * origLeftBinding
QList< QDeclarativeAction > ActionList
QDeclarativeAnchorLine top
QDeclarativeNullableValue< qreal > rotation
QTransform itemTransform(const QGraphicsItem *other, bool *ok=0) const
Returns a QTransform that maps coordinates from this item to other.
void resetHorizontalCenter()
QDeclarativeNullableValue< qreal > scale
QDeclarativeScriptString y() const
void setParent(QDeclarativeItem *)
void scale(qreal sx, qreal sy)
Use.
void setCenterIn(QDeclarativeItem *)
virtual QString typeName() const
QDeclarativeAnchors * anchors()
QDeclarativeNullableValue< QDeclarativeScriptString > xString
The QPointF class defines a point in the plane using floating point precision.
void setTarget(const QDeclarativeProperty &)
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore=0)
QDeclarativeScriptString horizontalCenter() const
QDeclarativeAnchorChangesPrivate()
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
QDeclarativeAnchors::Anchors usedAnchors() const
void setBaseline(const QDeclarativeScriptString &edge)
QDeclarativeItem * target
QDeclarativeBinding * bottomBinding
QDeclarativeItem * target
QDeclarativeProperty rightProp
QDeclarativeScriptString script
QDeclarativeScriptString hCenterScript
TransformOrigin transformOrigin
Returns the current transform origin.
QPointF transformOriginPoint
QDeclarativeScriptString right() const
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
QDeclarativeScriptString verticalCenter() const
QDeclarativeScriptString top() const
QDeclarativeBinding * vCenterBinding
QDeclarativeBinding * rightBinding
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
QDeclarativeNullableValue< QDeclarativeScriptString > heightString
void resetVerticalCenter()
The QObject class is the base class of all Qt objects.
QDeclarativeItem * object() const
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
QDeclarativeNullableValue< qreal > width
QDeclarativeAnchorLine baseline
virtual QString typeName() const
QDeclarativeBinding * topBinding
QDeclarativeScriptString vCenterScript
QDeclarativeNullableValue< qreal > height
QList< QDeclarativeAbstractBinding * > oldBindings
QDeclarativeProperty hCenterProp
qreal x() const
Returns the x-coordinate of this point.
QDeclarativeAnchorLine horizontalCenter
QDeclarativeGuard< QDeclarativeItem > origParent
QDeclarativeAnchorLine verticalCenter
void setParentItem(QDeclarativeItem *parent)
virtual void execute(Reason reason=ActualChange)
QDeclarativeAbstractBinding * origRightBinding
QDeclarativeAbstractBinding * origTopBinding
QDeclarativeScriptString height() const
QDeclarativeScriptString width() const
QDeclarativeScriptString rotation() const
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QDeclarativeScriptString class encapsulates a script and its context.
QDeclarativeItem * object() const
QDeclarativeScriptString leftScript
virtual void saveOriginals()
QDeclarativeNullableValue< QDeclarativeScriptString > scaleString
QDeclarativeNullableValue< qreal > y
The QDeclarativeItem class provides the most basic of all visual items in QML.
QDeclarativeAnchors::Anchors usedAnchors
virtual void reverse(Reason reason=ActualChange)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QDeclarativeScriptString topScript
const T & at(int i) const
Returns the item at index position i in the list.
QDeclarativeScriptString baseline() const
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
void setHorizontalCenter(const QDeclarativeScriptString &edge)
virtual void saveTargetValues()
QDeclarativeStateChangeScript(QObject *parent=0)
QDeclarativeItem * rewindParent
virtual bool isReversable()
QDeclarativeScriptString left() const
QDeclarativeItem * rewindStackBefore
void setRight(const QDeclarativeScriptString &edge)
static const char * data(const QByteArray &arr)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
QWeakPointer< QDeclarativeAbstractBinding > toBinding
QDeclarativeItem * centerIn() const
QDeclarativeParentChange(QObject *parent=0)
QDeclarativeBinding * hCenterBinding
qreal rotation() const
Returns the clockwise rotation, in degrees, around the Z axis.
QDeclarativeAnchorLine rewindTop
QDeclarativeAnchorLine rewindRight
void setX(qreal x)
Set's the x coordinate of the item's position.
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
QDeclarativeScriptString x() const
void setFill(QDeclarativeItem *)
void setVerticalCenter(const QDeclarativeScriptString &edge)
QDeclarativeScriptString script() const
QDeclarativeAbstractBinding * origBaselineBinding
QDeclarativeProperty baselineProp
void setScript(const QDeclarativeScriptString &)
virtual void saveCurrentValues()
virtual void saveCurrentValues()
QDeclarativeScriptString baselineScript
virtual QString typeName() const
void setBottom(const QDeclarativeScriptString &edge)
QDeclarativeProperty vCenterProp
virtual void copyOriginals(QDeclarativeActionEvent *)
virtual ActionList actions()
QDeclarativeParentChangePrivate()
virtual ActionList actions()
virtual void reverse(Reason reason=ActualChange)
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
QDeclarativeItem * centerIn
QDeclarativeAbstractBinding * origBottomBinding
QDeclarativeAnchorSet * anchorSet
QDeclarativeAnchorSet * anchors()
#define Q_DECLARE_PUBLIC(Class)
void setRotation(QDeclarativeScriptString rotation)
virtual ~QDeclarativeAnchorSet()
void setY(QDeclarativeScriptString y)
~QDeclarativeParentChange()
qreal y() const
This convenience function is equivalent to calling pos().
QDeclarativeItem * target
void setName(const QString &)
Anchors usedAnchors() const
QDeclarativeItem * parentItem() const
Returns the QDeclarativeItem parent of this item.
QDeclarativeItem * fill() const
QDeclarativeAnchorLine left
virtual bool override(QDeclarativeActionEvent *other)
void stackBefore(const QGraphicsItem *sibling)
Stacks this item before sibling, which must be a sibling item (i.
QDeclarativeAnchors::Anchors resetAnchors
QDeclarativeScriptString rightScript
QObject * parent() const
Returns a pointer to the parent object.
qreal x() const
This convenience function is equivalent to calling pos().
QDeclarativeAnchorLine rewindVCenter
QDeclarativeAnchorLine rewindBaseline
void setY(qreal y)
Set's the y coordinate of the item's position.
void setObject(QDeclarativeItem *)
QDeclarativeProperty bottomProp
QDeclarativeAnchorSetPrivate()
virtual void saveOriginals()
~QDeclarativeAnchorChanges()
virtual bool override(QDeclarativeActionEvent *other)
QDeclarativeNullableValue< QDeclarativeScriptString > yString
virtual void clearBindings()
QList< QDeclarativeAction > additionalActions()
QDeclarativeGuard< QDeclarativeItem > origStackBefore
const QObjectList & children() const
Returns a list of child objects.
virtual bool changesBindings()
void setScale(QDeclarativeScriptString scale)
QDeclarativeAnchorLine bottom
void resetVerticalCenter()
The QDeclarativeContext class defines a context within a QML engine.
virtual bool isReversable()
qreal y() const
Returns the y-coordinate of this point.
QDeclarativeAnchorSet(QObject *parent=0)
~QDeclarativeStateChangeScript()
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QDeclarativeNullableValue< qreal > origWidth
void setObject(QDeclarativeItem *)
void setScale(qreal scale)
Sets the scale factor of the item.
virtual void execute(Reason reason=ActualChange)
QDeclarativeActionEvent * event
QDeclarativeNullableValue< QDeclarativeScriptString > widthString
virtual void execute(Reason reason=ActualChange)
QDeclarativeNullableValue< qreal > origHeight
QDeclarativeAbstractBinding * origHCenterBinding
void setX(QDeclarativeScriptString x)
bool rotationIsSet() const
QDeclarativeProperty property() const
The QDeclarativeExpression class evaluates JavaScript in a QML context.
QDeclarativeBinding * leftBinding
QDeclarativeInfo qmlInfo(const QObject *me)
void setRotation(qreal angle)
Sets the clockwise rotation angle, in degrees, around the Z axis.
void setHeight(QDeclarativeScriptString height)
void setWidth(QDeclarativeScriptString width)
QDeclarativeAnchorLine rewindHCenter
QDeclarativeScriptString bottom() const
QDeclarativeScriptString bottomScript
QDeclarativeAnchorLine right
QDeclarativeItem * target
QDeclarativeAbstractBinding * origVCenterBinding
QDeclarativeBinding * baselineBinding
void setTop(const QDeclarativeScriptString &edge)
QString script() const
Returns the script text.
QDeclarativeProperty leftProp
QDeclarativeItem * parent() const
QDeclarativeAnchorLine rewindLeft
QDeclarativeProperty topProp
QDeclarativeItem * originalParent() const
QVariant read() const
Returns the property value.
QDeclarativeNullableValue< qreal > x
QDeclarativeScriptString scale() const