Qt 4.8
Public Functions | Properties | List of all members
QDeclarativeAnchorChanges Class Reference

#include <qdeclarativestateoperations_p.h>

Inheritance diagram for QDeclarativeAnchorChanges:
QDeclarativeStateOperation QDeclarativeActionEvent QObject

Public Functions

virtual ActionList actions ()
 
QList< QDeclarativeActionadditionalActions ()
 
QDeclarativeAnchorSetanchors ()
 
virtual bool changesBindings ()
 
virtual void clearBindings ()
 
virtual void copyOriginals (QDeclarativeActionEvent *)
 
virtual void execute (Reason reason=ActualChange)
 
virtual bool isReversable ()
 
virtual bool needsCopy ()
 
QDeclarativeItemobject () const
 
virtual bool override (QDeclarativeActionEvent *other)
 
 QDeclarativeAnchorChanges (QObject *parent=0)
 
virtual void reverse (Reason reason=ActualChange)
 
virtual void rewind ()
 
virtual void saveCurrentValues ()
 
virtual void saveOriginals ()
 
virtual void saveTargetValues ()
 
void setObject (QDeclarativeItem *)
 
virtual QString typeName () const
 
 ~QDeclarativeAnchorChanges ()
 
- Public Functions inherited from QDeclarativeStateOperation
 QDeclarativeStateOperation (QObject *parent=0)
 
void setState (QDeclarativeState *state)
 
QDeclarativeStatestate () const
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QDeclarativeActionEvent
virtual bool isRewindable ()
 
virtual ~QDeclarativeActionEvent ()
 

Properties

QDeclarativeAnchorSetanchors
 
QDeclarativeItemtarget
 

Additional Inherited Members

- Public Types inherited from QDeclarativeStateOperation
typedef QList< QDeclarativeActionActionList
 
- Public Types inherited from QDeclarativeActionEvent
enum  Reason { ActualChange, FastForward }
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QDeclarativeStateOperation
 QDeclarativeStateOperation (QObjectPrivate &dd, QObject *parent=0)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 262 of file qdeclarativestateoperations_p.h.

Constructors and Destructors

◆ QDeclarativeAnchorChanges()

QDeclarativeAnchorChanges::QDeclarativeAnchorChanges ( QObject parent = 0)

◆ ~QDeclarativeAnchorChanges()

QDeclarativeAnchorChanges::~QDeclarativeAnchorChanges ( )

Definition at line 1080 of file qdeclarativestateoperations.cpp.

1081 {
1082 }

Functions

◆ actions()

QDeclarativeAnchorChanges::ActionList QDeclarativeAnchorChanges::actions ( )
virtual

Reimplemented from QDeclarativeStateOperation.

Definition at line 1084 of file qdeclarativestateoperations.cpp.

1085 {
1087  d->leftBinding = d->rightBinding = d->hCenterBinding = d->topBinding
1088  = d->bottomBinding = d->vCenterBinding = d->baselineBinding = 0;
1089 
1090  d->leftProp = QDeclarativeProperty(d->target, QLatin1String("anchors.left"));
1091  d->rightProp = QDeclarativeProperty(d->target, QLatin1String("anchors.right"));
1092  d->hCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.horizontalCenter"));
1093  d->topProp = QDeclarativeProperty(d->target, QLatin1String("anchors.top"));
1094  d->bottomProp = QDeclarativeProperty(d->target, QLatin1String("anchors.bottom"));
1095  d->vCenterProp = QDeclarativeProperty(d->target, QLatin1String("anchors.verticalCenter"));
1096  d->baselineProp = QDeclarativeProperty(d->target, QLatin1String("anchors.baseline"));
1097 
1098  QDeclarativeContext *ctxt = qmlContext(this);
1099 
1100  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::LeftAnchor) {
1101  d->leftBinding = new QDeclarativeBinding(d->anchorSet->d_func()->leftScript.script(), d->target, ctxt);
1102  d->leftBinding->setTarget(d->leftProp);
1103  }
1104  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::RightAnchor) {
1105  d->rightBinding = new QDeclarativeBinding(d->anchorSet->d_func()->rightScript.script(), d->target, ctxt);
1106  d->rightBinding->setTarget(d->rightProp);
1107  }
1108  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::HCenterAnchor) {
1109  d->hCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->hCenterScript.script(), d->target, ctxt);
1110  d->hCenterBinding->setTarget(d->hCenterProp);
1111  }
1112  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::TopAnchor) {
1113  d->topBinding = new QDeclarativeBinding(d->anchorSet->d_func()->topScript.script(), d->target, ctxt);
1114  d->topBinding->setTarget(d->topProp);
1115  }
1116  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BottomAnchor) {
1117  d->bottomBinding = new QDeclarativeBinding(d->anchorSet->d_func()->bottomScript.script(), d->target, ctxt);
1118  d->bottomBinding->setTarget(d->bottomProp);
1119  }
1120  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::VCenterAnchor) {
1121  d->vCenterBinding = new QDeclarativeBinding(d->anchorSet->d_func()->vCenterScript.script(), d->target, ctxt);
1122  d->vCenterBinding->setTarget(d->vCenterProp);
1123  }
1124  if (d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::BaselineAnchor) {
1125  d->baselineBinding = new QDeclarativeBinding(d->anchorSet->d_func()->baselineScript.script(), d->target, ctxt);
1126  d->baselineBinding->setTarget(d->baselineProp);
1127  }
1128 
1130  a.event = this;
1131  return ActionList() << a;
1132 }
double d
Definition: qnumeric_p.h:62
QList< QDeclarativeAction > ActionList
long ASN1_INTEGER_get ASN1_INTEGER * a
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
The QDeclarativeContext class defines a context within a QML engine.
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QDeclarativeActionEvent * event

◆ additionalActions()

QList< QDeclarativeAction > QDeclarativeAnchorChanges::additionalActions ( )

Definition at line 1398 of file qdeclarativestateoperations.cpp.

1399 {
1402 
1403  QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->usedAnchors | d->anchorSet->d_func()->resetAnchors;
1404  bool hChange = combined & QDeclarativeAnchors::Horizontal_Mask;
1405  bool vChange = combined & QDeclarativeAnchors::Vertical_Mask;
1406 
1407  if (d->target) {
1408  QDeclarativeContext *ctxt = qmlContext(this);
1410  if (hChange && d->fromX != d->toX) {
1411  a.property = QDeclarativeProperty(d->target, QLatin1String("x"), ctxt);
1412  a.toValue = d->toX;
1413  extra << a;
1414  }
1415  if (vChange && d->fromY != d->toY) {
1416  a.property = QDeclarativeProperty(d->target, QLatin1String("y"), ctxt);
1417  a.toValue = d->toY;
1418  extra << a;
1419  }
1420  if (hChange && d->fromWidth != d->toWidth) {
1421  a.property = QDeclarativeProperty(d->target, QLatin1String("width"), ctxt);
1422  a.toValue = d->toWidth;
1423  extra << a;
1424  }
1425  if (vChange && d->fromHeight != d->toHeight) {
1426  a.property = QDeclarativeProperty(d->target, QLatin1String("height"), ctxt);
1427  a.toValue = d->toHeight;
1428  extra << a;
1429  }
1430  }
1431 
1432  return extra;
1433 }
double d
Definition: qnumeric_p.h:62
QDeclarativeProperty property
long ASN1_INTEGER_get ASN1_INTEGER * a
Q_DECLARATIVE_EXPORT QDeclarativeContext * qmlContext(const QObject *)
#define Q_D(Class)
Definition: qglobal.h:2482
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
The QDeclarativeContext class defines a context within a QML engine.
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...

◆ anchors()

QDeclarativeAnchorSet* QDeclarativeAnchorChanges::anchors ( )

Referenced by actions().

◆ changesBindings()

bool QDeclarativeAnchorChanges::changesBindings ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1435 of file qdeclarativestateoperations.cpp.

1436 {
1437  return true;
1438 }

◆ clearBindings()

void QDeclarativeAnchorChanges::clearBindings ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1506 of file qdeclarativestateoperations.cpp.

1507 {
1509  if (!d->target)
1510  return;
1511 
1512  //### should this (saving "from" values) be moved to saveCurrentValues()?
1513  d->fromX = d->target->x();
1514  d->fromY = d->target->y();
1515  d->fromWidth = d->target->width();
1516  d->fromHeight = d->target->height();
1517 
1518  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1519  //reset any anchors with corresponding reverts
1520  //reset any anchors that have been specified as "undefined"
1521  //reset any anchors that we'll be setting in the state
1522  QDeclarativeAnchors::Anchors combined = d->anchorSet->d_func()->resetAnchors |
1523  d->anchorSet->d_func()->usedAnchors;
1524  if (d->applyOrigLeft || (combined & QDeclarativeAnchors::LeftAnchor)) {
1525  targetPrivate->anchors()->resetLeft();
1527  }
1528  if (d->applyOrigRight || (combined & QDeclarativeAnchors::RightAnchor)) {
1529  targetPrivate->anchors()->resetRight();
1531  }
1532  if (d->applyOrigHCenter || (combined & QDeclarativeAnchors::HCenterAnchor)) {
1533  targetPrivate->anchors()->resetHorizontalCenter();
1534  QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
1535  }
1536  if (d->applyOrigTop || (combined & QDeclarativeAnchors::TopAnchor)) {
1537  targetPrivate->anchors()->resetTop();
1539  }
1540  if (d->applyOrigBottom || (combined & QDeclarativeAnchors::BottomAnchor)) {
1541  targetPrivate->anchors()->resetBottom();
1543  }
1544  if (d->applyOrigVCenter || (combined & QDeclarativeAnchors::VCenterAnchor)) {
1545  targetPrivate->anchors()->resetVerticalCenter();
1546  QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
1547  }
1548  if (d->applyOrigBaseline || (combined & QDeclarativeAnchors::BaselineAnchor)) {
1549  targetPrivate->anchors()->resetBaseline();
1550  QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
1551  }
1552 }
double d
Definition: qnumeric_p.h:62
QDeclarativeAnchors * anchors()
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)

◆ copyOriginals()

void QDeclarativeAnchorChanges::copyOriginals ( QDeclarativeActionEvent other)
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1468 of file qdeclarativestateoperations.cpp.

1469 {
1471  QDeclarativeAnchorChanges *ac = static_cast<QDeclarativeAnchorChanges*>(other);
1472  QDeclarativeAnchorChangesPrivate *acp = ac->d_func();
1473 
1474  QDeclarativeAnchors::Anchors combined = acp->anchorSet->d_func()->usedAnchors |
1475  acp->anchorSet->d_func()->resetAnchors;
1476 
1477  //probably also need to revert some things
1478  d->applyOrigLeft = (combined & QDeclarativeAnchors::LeftAnchor);
1479  d->applyOrigRight = (combined & QDeclarativeAnchors::RightAnchor);
1480  d->applyOrigHCenter = (combined & QDeclarativeAnchors::HCenterAnchor);
1481  d->applyOrigTop = (combined & QDeclarativeAnchors::TopAnchor);
1482  d->applyOrigBottom = (combined & QDeclarativeAnchors::BottomAnchor);
1483  d->applyOrigVCenter = (combined & QDeclarativeAnchors::VCenterAnchor);
1484  d->applyOrigBaseline = (combined & QDeclarativeAnchors::BaselineAnchor);
1485 
1486  d->origLeftBinding = acp->origLeftBinding;
1487  d->origRightBinding = acp->origRightBinding;
1488  d->origHCenterBinding = acp->origHCenterBinding;
1489  d->origTopBinding = acp->origTopBinding;
1490  d->origBottomBinding = acp->origBottomBinding;
1491  d->origVCenterBinding = acp->origVCenterBinding;
1492  d->origBaselineBinding = acp->origBaselineBinding;
1493 
1494  d->origWidth = acp->origWidth;
1495  d->origHeight = acp->origHeight;
1496  d->origX = acp->origX;
1497  d->origY = acp->origY;
1498 
1499  d->oldBindings.clear();
1500  d->oldBindings << acp->leftBinding << acp->rightBinding << acp->hCenterBinding
1501  << acp->topBinding << acp->bottomBinding << acp->baselineBinding;
1502 
1504 }
double d
Definition: qnumeric_p.h:62
QDeclarativeAbstractBinding * origLeftBinding
QDeclarativeAnchors::Anchors usedAnchors() const
#define Q_D(Class)
Definition: qglobal.h:2482
QDeclarativeAbstractBinding * origRightBinding
QDeclarativeAbstractBinding * origTopBinding
QDeclarativeAbstractBinding * origBaselineBinding
QDeclarativeAbstractBinding * origBottomBinding
QDeclarativeNullableValue< qreal > origWidth
QDeclarativeNullableValue< qreal > origHeight
QDeclarativeAbstractBinding * origHCenterBinding
QDeclarativeAbstractBinding * origVCenterBinding

◆ execute()

void QDeclarativeAnchorChanges::execute ( Reason  reason = ActualChange)
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1176 of file qdeclarativestateoperations.cpp.

1177 {
1179  if (!d->target)
1180  return;
1181 
1182  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1183  //incorporate any needed "reverts"
1184  if (d->applyOrigLeft) {
1185  if (!d->origLeftBinding)
1186  targetPrivate->anchors()->resetLeft();
1187  QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
1188  }
1189  if (d->applyOrigRight) {
1190  if (!d->origRightBinding)
1191  targetPrivate->anchors()->resetRight();
1192  QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
1193  }
1194  if (d->applyOrigHCenter) {
1195  if (!d->origHCenterBinding)
1196  targetPrivate->anchors()->resetHorizontalCenter();
1197  QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
1198  }
1199  if (d->applyOrigTop) {
1200  if (!d->origTopBinding)
1201  targetPrivate->anchors()->resetTop();
1202  QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
1203  }
1204  if (d->applyOrigBottom) {
1205  if (!d->origBottomBinding)
1206  targetPrivate->anchors()->resetBottom();
1207  QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
1208  }
1209  if (d->applyOrigVCenter) {
1210  if (!d->origVCenterBinding)
1211  targetPrivate->anchors()->resetVerticalCenter();
1212  QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
1213  }
1214  if (d->applyOrigBaseline) {
1215  if (!d->origBaselineBinding)
1216  targetPrivate->anchors()->resetBaseline();
1217  QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
1218  }
1219 
1220  //destroy old bindings
1221  if (reason == ActualChange) {
1222  for (int i = 0; i < d->oldBindings.size(); ++i) {
1223  QDeclarativeAbstractBinding *binding = d->oldBindings.at(i);
1224  if (binding)
1225  binding->destroy();
1226  }
1227  d->oldBindings.clear();
1228  }
1229 
1230  //reset any anchors that have been specified as "undefined"
1231  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::LeftAnchor) {
1232  targetPrivate->anchors()->resetLeft();
1234  }
1235  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::RightAnchor) {
1236  targetPrivate->anchors()->resetRight();
1238  }
1239  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::HCenterAnchor) {
1240  targetPrivate->anchors()->resetHorizontalCenter();
1241  QDeclarativePropertyPrivate::setBinding(d->hCenterProp, 0);
1242  }
1243  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::TopAnchor) {
1244  targetPrivate->anchors()->resetTop();
1246  }
1247  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BottomAnchor) {
1248  targetPrivate->anchors()->resetBottom();
1250  }
1251  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::VCenterAnchor) {
1252  targetPrivate->anchors()->resetVerticalCenter();
1253  QDeclarativePropertyPrivate::setBinding(d->vCenterProp, 0);
1254  }
1255  if (d->anchorSet->d_func()->resetAnchors & QDeclarativeAnchors::BaselineAnchor) {
1256  targetPrivate->anchors()->resetBaseline();
1257  QDeclarativePropertyPrivate::setBinding(d->baselineProp, 0);
1258  }
1259 
1260  //set any anchors that have been specified
1261  if (d->leftBinding)
1262  QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), d->leftBinding);
1263  if (d->rightBinding)
1264  QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), d->rightBinding);
1265  if (d->hCenterBinding)
1266  QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), d->hCenterBinding);
1267  if (d->topBinding)
1268  QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), d->topBinding);
1269  if (d->bottomBinding)
1270  QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), d->bottomBinding);
1271  if (d->vCenterBinding)
1272  QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), d->vCenterBinding);
1273  if (d->baselineBinding)
1274  QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), d->baselineBinding);
1275 }
double d
Definition: qnumeric_p.h:62
QDeclarativeAnchors * anchors()
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)

◆ isReversable()

bool QDeclarativeAnchorChanges::isReversable ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1277 of file qdeclarativestateoperations.cpp.

1278 {
1279  return true;
1280 }

◆ needsCopy()

virtual bool QDeclarativeAnchorChanges::needsCopy ( )
inlinevirtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 288 of file qdeclarativestateoperations_p.h.

288 { return true; }

◆ object()

QDeclarativeItem * QDeclarativeAnchorChanges::object ( ) const

Definition at line 1140 of file qdeclarativestateoperations.cpp.

Referenced by override().

1141 {
1143  return d->target;
1144 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ override()

bool QDeclarativeAnchorChanges::override ( QDeclarativeActionEvent other)
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1554 of file qdeclarativestateoperations.cpp.

1555 {
1556  if (other->typeName() != QLatin1String("AnchorChanges"))
1557  return false;
1558  if (static_cast<QDeclarativeActionEvent*>(this) == other)
1559  return true;
1560  if (static_cast<QDeclarativeAnchorChanges*>(other)->object() == object())
1561  return true;
1562  return false;
1563 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual QString typeName() const

◆ reverse()

void QDeclarativeAnchorChanges::reverse ( Reason  reason = ActualChange)
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1282 of file qdeclarativestateoperations.cpp.

1283 {
1285  if (!d->target)
1286  return;
1287 
1288  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1289  //reset any anchors set by the state
1290  if (d->leftBinding) {
1291  targetPrivate->anchors()->resetLeft();
1292  QDeclarativePropertyPrivate::setBinding(d->leftBinding->property(), 0);
1293  if (reason == ActualChange) {
1294  d->leftBinding->destroy(); d->leftBinding = 0;
1295  }
1296  }
1297  if (d->rightBinding) {
1298  targetPrivate->anchors()->resetRight();
1299  QDeclarativePropertyPrivate::setBinding(d->rightBinding->property(), 0);
1300  if (reason == ActualChange) {
1301  d->rightBinding->destroy(); d->rightBinding = 0;
1302  }
1303  }
1304  if (d->hCenterBinding) {
1305  targetPrivate->anchors()->resetHorizontalCenter();
1306  QDeclarativePropertyPrivate::setBinding(d->hCenterBinding->property(), 0);
1307  if (reason == ActualChange) {
1308  d->hCenterBinding->destroy(); d->hCenterBinding = 0;
1309  }
1310  }
1311  if (d->topBinding) {
1312  targetPrivate->anchors()->resetTop();
1313  QDeclarativePropertyPrivate::setBinding(d->topBinding->property(), 0);
1314  if (reason == ActualChange) {
1315  d->topBinding->destroy(); d->topBinding = 0;
1316  }
1317  }
1318  if (d->bottomBinding) {
1319  targetPrivate->anchors()->resetBottom();
1320  QDeclarativePropertyPrivate::setBinding(d->bottomBinding->property(), 0);
1321  if (reason == ActualChange) {
1322  d->bottomBinding->destroy(); d->bottomBinding = 0;
1323  }
1324  }
1325  if (d->vCenterBinding) {
1326  targetPrivate->anchors()->resetVerticalCenter();
1327  QDeclarativePropertyPrivate::setBinding(d->vCenterBinding->property(), 0);
1328  if (reason == ActualChange) {
1329  d->vCenterBinding->destroy(); d->vCenterBinding = 0;
1330  }
1331  }
1332  if (d->baselineBinding) {
1333  targetPrivate->anchors()->resetBaseline();
1334  QDeclarativePropertyPrivate::setBinding(d->baselineBinding->property(), 0);
1335  if (reason == ActualChange) {
1336  d->baselineBinding->destroy(); d->baselineBinding = 0;
1337  }
1338  }
1339 
1340  //restore previous anchors
1341  if (d->origLeftBinding)
1342  QDeclarativePropertyPrivate::setBinding(d->leftProp, d->origLeftBinding);
1343  if (d->origRightBinding)
1344  QDeclarativePropertyPrivate::setBinding(d->rightProp, d->origRightBinding);
1345  if (d->origHCenterBinding)
1346  QDeclarativePropertyPrivate::setBinding(d->hCenterProp, d->origHCenterBinding);
1347  if (d->origTopBinding)
1348  QDeclarativePropertyPrivate::setBinding(d->topProp, d->origTopBinding);
1349  if (d->origBottomBinding)
1350  QDeclarativePropertyPrivate::setBinding(d->bottomProp, d->origBottomBinding);
1351  if (d->origVCenterBinding)
1352  QDeclarativePropertyPrivate::setBinding(d->vCenterProp, d->origVCenterBinding);
1353  if (d->origBaselineBinding)
1354  QDeclarativePropertyPrivate::setBinding(d->baselineProp, d->origBaselineBinding);
1355 
1356  //restore any absolute geometry changed by the state's anchors
1357  QDeclarativeAnchors::Anchors stateVAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::Vertical_Mask;
1358  QDeclarativeAnchors::Anchors origVAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarativeAnchors::Vertical_Mask;
1359  QDeclarativeAnchors::Anchors stateHAnchors = d->anchorSet->d_func()->usedAnchors & QDeclarativeAnchors::Horizontal_Mask;
1360  QDeclarativeAnchors::Anchors origHAnchors = targetPrivate->anchors()->usedAnchors() & QDeclarativeAnchors::Horizontal_Mask;
1361 
1362  bool stateSetWidth = (stateHAnchors &&
1363  stateHAnchors != QDeclarativeAnchors::LeftAnchor &&
1364  stateHAnchors != QDeclarativeAnchors::RightAnchor &&
1365  stateHAnchors != QDeclarativeAnchors::HCenterAnchor);
1366  bool origSetWidth = (origHAnchors &&
1367  origHAnchors != QDeclarativeAnchors::LeftAnchor &&
1368  origHAnchors != QDeclarativeAnchors::RightAnchor &&
1369  origHAnchors != QDeclarativeAnchors::HCenterAnchor);
1370  if (d->origWidth.isValid() && stateSetWidth && !origSetWidth)
1371  d->target->setWidth(d->origWidth.value);
1372 
1373  bool stateSetHeight = (stateVAnchors &&
1374  stateVAnchors != QDeclarativeAnchors::TopAnchor &&
1375  stateVAnchors != QDeclarativeAnchors::BottomAnchor &&
1376  stateVAnchors != QDeclarativeAnchors::VCenterAnchor &&
1377  stateVAnchors != QDeclarativeAnchors::BaselineAnchor);
1378  bool origSetHeight = (origVAnchors &&
1379  origVAnchors != QDeclarativeAnchors::TopAnchor &&
1380  origVAnchors != QDeclarativeAnchors::BottomAnchor &&
1381  origVAnchors != QDeclarativeAnchors::VCenterAnchor &&
1382  origVAnchors != QDeclarativeAnchors::BaselineAnchor);
1383  if (d->origHeight.isValid() && stateSetHeight && !origSetHeight)
1384  d->target->setHeight(d->origHeight.value);
1385 
1386  if (stateHAnchors && !origHAnchors)
1387  d->target->setX(d->origX);
1388 
1389  if (stateVAnchors && !origVAnchors)
1390  d->target->setY(d->origY);
1391 }
double d
Definition: qnumeric_p.h:62
QDeclarativeAnchors * anchors()
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)

◆ rewind()

void QDeclarativeAnchorChanges::rewind ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1565 of file qdeclarativestateoperations.cpp.

1566 {
1568  if (!d->target)
1569  return;
1570 
1571  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1572 
1573  //restore previous values (but not previous bindings, i.e. anchors)
1574  d->target->setX(d->rewindX);
1575  d->target->setY(d->rewindY);
1576  if (targetPrivate->widthValid) {
1577  d->target->setWidth(d->rewindWidth);
1578  }
1579  if (targetPrivate->heightValid) {
1580  d->target->setHeight(d->rewindHeight);
1581  }
1582 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)

◆ saveCurrentValues()

void QDeclarativeAnchorChanges::saveCurrentValues ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1584 of file qdeclarativestateoperations.cpp.

Referenced by copyOriginals(), and saveOriginals().

1585 {
1587  if (!d->target)
1588  return;
1589 
1590  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1591  d->rewindLeft = targetPrivate->anchors()->left();
1592  d->rewindRight = targetPrivate->anchors()->right();
1593  d->rewindHCenter = targetPrivate->anchors()->horizontalCenter();
1594  d->rewindTop = targetPrivate->anchors()->top();
1595  d->rewindBottom = targetPrivate->anchors()->bottom();
1596  d->rewindVCenter = targetPrivate->anchors()->verticalCenter();
1597  d->rewindBaseline = targetPrivate->anchors()->baseline();
1598 
1599  d->rewindX = d->target->x();
1600  d->rewindY = d->target->y();
1601  d->rewindWidth = d->target->width();
1602  d->rewindHeight = d->target->height();
1603 }
double d
Definition: qnumeric_p.h:62
QDeclarativeAnchorLine top
QDeclarativeAnchors * anchors()
QDeclarativeAnchorLine baseline
#define Q_D(Class)
Definition: qglobal.h:2482
QDeclarativeAnchorLine horizontalCenter
QDeclarativeAnchorLine verticalCenter
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)
QDeclarativeAnchorLine left
QDeclarativeAnchorLine bottom
QDeclarativeAnchorLine right

◆ saveOriginals()

void QDeclarativeAnchorChanges::saveOriginals ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1440 of file qdeclarativestateoperations.cpp.

1441 {
1443  if (!d->target)
1444  return;
1445 
1446  d->origLeftBinding = QDeclarativePropertyPrivate::binding(d->leftProp);
1447  d->origRightBinding = QDeclarativePropertyPrivate::binding(d->rightProp);
1448  d->origHCenterBinding = QDeclarativePropertyPrivate::binding(d->hCenterProp);
1449  d->origTopBinding = QDeclarativePropertyPrivate::binding(d->topProp);
1450  d->origBottomBinding = QDeclarativePropertyPrivate::binding(d->bottomProp);
1451  d->origVCenterBinding = QDeclarativePropertyPrivate::binding(d->vCenterProp);
1452  d->origBaselineBinding = QDeclarativePropertyPrivate::binding(d->baselineProp);
1453 
1454  QDeclarativeItemPrivate *targetPrivate = QDeclarativeItemPrivate::get(d->target);
1455  if (targetPrivate->widthValid)
1456  d->origWidth = d->target->width();
1457  if (targetPrivate->heightValid)
1458  d->origHeight = d->target->height();
1459  d->origX = d->target->x();
1460  d->origY = d->target->y();
1461 
1462  d->applyOrigLeft = d->applyOrigRight = d->applyOrigHCenter = d->applyOrigTop
1463  = d->applyOrigBottom = d->applyOrigVCenter = d->applyOrigBaseline = false;
1464 
1466 }
double d
Definition: qnumeric_p.h:62
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeItemPrivate * get(QDeclarativeItem *item)

◆ saveTargetValues()

void QDeclarativeAnchorChanges::saveTargetValues ( )
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1605 of file qdeclarativestateoperations.cpp.

1606 {
1608  if (!d->target)
1609  return;
1610 
1611  d->toX = d->target->x();
1612  d->toY = d->target->y();
1613  d->toWidth = d->target->width();
1614  d->toHeight = d->target->height();
1615 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setObject()

void QDeclarativeAnchorChanges::setObject ( QDeclarativeItem target)

Definition at line 1146 of file qdeclarativestateoperations.cpp.

1147 {
1149  d->target = target;
1150 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ typeName()

QString QDeclarativeAnchorChanges::typeName ( ) const
virtual

Reimplemented from QDeclarativeActionEvent.

Definition at line 1393 of file qdeclarativestateoperations.cpp.

1394 {
1395  return QLatin1String("AnchorChanges");
1396 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

Properties

◆ anchors

QDeclarativeAnchorSet * QDeclarativeAnchorChanges::anchors
private

Definition at line 268 of file qdeclarativestateoperations_p.h.

◆ target

QDeclarativeItem* QDeclarativeAnchorChanges::target
private

Definition at line 267 of file qdeclarativestateoperations_p.h.

Referenced by setObject().


The documentation for this class was generated from the following files: