Qt 4.8
Public Functions | Public Variables | List of all members
QDeclarativeParentChangePrivate Class Reference
Inheritance diagram for QDeclarativeParentChangePrivate:
QDeclarativeStateOperationPrivate QObjectPrivate QObjectData

Public Functions

void doChange (QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore=0)
 
 QDeclarativeParentChangePrivate ()
 
- Public Functions inherited from QDeclarativeStateOperationPrivate
 QDeclarativeStateOperationPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QDeclarativeNullableValue< qrealheight
 
QDeclarativeNullableValue< QDeclarativeScriptStringheightString
 
QDeclarativeGuard< QDeclarativeItemorigParent
 
QDeclarativeGuard< QDeclarativeItemorigStackBefore
 
QDeclarativeGuard< QDeclarativeItemparent
 
QDeclarativeItemrewindParent
 
QDeclarativeItemrewindStackBefore
 
QDeclarativeNullableValue< qrealrotation
 
QDeclarativeNullableValue< QDeclarativeScriptStringrotationString
 
QDeclarativeNullableValue< qrealscale
 
QDeclarativeNullableValue< QDeclarativeScriptStringscaleString
 
QDeclarativeItemtarget
 
QDeclarativeNullableValue< qrealwidth
 
QDeclarativeNullableValue< QDeclarativeScriptStringwidthString
 
QDeclarativeNullableValue< qrealx
 
QDeclarativeNullableValue< QDeclarativeScriptStringxString
 
QDeclarativeNullableValue< qrealy
 
QDeclarativeNullableValue< QDeclarativeScriptStringyString
 
- Public Variables inherited from QDeclarativeStateOperationPrivate
QDeclarativeStatem_state
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 72 of file qdeclarativestateoperations.cpp.

Constructors and Destructors

◆ QDeclarativeParentChangePrivate()

QDeclarativeParentChangePrivate::QDeclarativeParentChangePrivate ( )
inline

Definition at line 76 of file qdeclarativestateoperations.cpp.

76  : target(0), parent(0), origParent(0), origStackBefore(0),
QDeclarativeGuard< QDeclarativeItem > parent
QDeclarativeGuard< QDeclarativeItem > origParent
QDeclarativeGuard< QDeclarativeItem > origStackBefore

Functions

◆ doChange()

void QDeclarativeParentChangePrivate::doChange ( QDeclarativeItem targetParent,
QDeclarativeItem stackBefore = 0 
)

Definition at line 103 of file qdeclarativestateoperations.cpp.

104 {
105  if (targetParent && target && target->parentItem()) {
107  bool ok;
108  const QTransform &transform = target->parentItem()->itemTransform(targetParent, &ok);
109  if (transform.type() >= QTransform::TxShear || !ok) {
110  qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under complex transform");
111  ok = false;
112  }
113 
114  qreal scale = 1;
115  qreal rotation = 0;
116  bool isRotate = (transform.type() == QTransform::TxRotate) || (transform.m11() < 0);
117  if (ok && !isRotate) {
118  if (transform.m11() == transform.m22())
119  scale = transform.m11();
120  else {
121  qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale");
122  ok = false;
123  }
124  } else if (ok && isRotate) {
125  if (transform.m11() == transform.m22())
126  scale = qSqrt(transform.m11()*transform.m11() + transform.m12()*transform.m12());
127  else {
128  qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under non-uniform scale");
129  ok = false;
130  }
131 
132  if (scale != 0)
133  rotation = atan2(transform.m12()/scale, transform.m11()/scale) * 180/qreal(M_PI);
134  else {
135  qmlInfo(q) << QDeclarativeParentChange::tr("Unable to preserve appearance under scale of 0");
136  ok = false;
137  }
138  }
139 
140  const QPointF &point = transform.map(QPointF(target->x(),target->y()));
141  qreal x = point.x();
142  qreal y = point.y();
143 
144  // setParentItem will update the transformOriginPoint if needed
145  target->setParentItem(targetParent);
146 
148  qreal tempxt = target->transformOriginPoint().x();
149  qreal tempyt = target->transformOriginPoint().y();
150  QTransform t;
151  t.translate(-tempxt, -tempyt);
152  t.rotate(rotation);
153  t.scale(scale, scale);
154  t.translate(tempxt, tempyt);
155  const QPointF &offset = t.map(QPointF(0,0));
156  x += offset.x();
157  y += offset.y();
158  }
159 
160  if (ok) {
161  //qDebug() << x << y << rotation << scale;
162  target->setX(x);
163  target->setY(y);
166  }
167  } else if (target) {
168  target->setParentItem(targetParent);
169  }
170 
171  //restore the original stack position.
172  //### if stackBefore has also been reparented this won't work
173  if (stackBefore)
174  target->stackBefore(stackBefore);
175 }
double qreal
Definition: qglobal.h:1193
QDeclarativeNullableValue< qreal > rotation
QTransform itemTransform(const QGraphicsItem *other, bool *ok=0) const
Returns a QTransform that maps coordinates from this item to other.
QDeclarativeNullableValue< qreal > scale
void scale(qreal sx, qreal sy)
Use.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
TransformOrigin transformOrigin
Returns the current transform origin.
QPointF transformOriginPoint
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
Definition: qtransform.cpp:417
TransformationType type() const
Returns the transformation type of this matrix.
#define M_PI
Definition: qmath.h:261
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define Q_Q(Class)
Definition: qglobal.h:2483
void setParentItem(QDeclarativeItem *parent)
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
QDeclarativeNullableValue< qreal > y
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis)
Rotates the coordinate system counterclockwise by the given angle about the specified axis and return...
Definition: qtransform.cpp:615
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
qreal rotation() const
Returns the clockwise rotation, in degrees, around the Z axis.
void setX(qreal x)
Set&#39;s the x coordinate of the item&#39;s position.
qreal y() const
This convenience function is equivalent to calling pos().
QDeclarativeItem * parentItem() const
Returns the QDeclarativeItem parent of this item.
void stackBefore(const QGraphicsItem *sibling)
Stacks this item before sibling, which must be a sibling item (i.
qreal x() const
This convenience function is equivalent to calling pos().
void setY(qreal y)
Set&#39;s the y coordinate of the item&#39;s position.
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void setScale(qreal scale)
Sets the scale factor of the item.
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
QDeclarativeInfo qmlInfo(const QObject *me)
void setRotation(qreal angle)
Sets the clockwise rotation angle, in degrees, around the Z axis.
qreal qSqrt(qreal v)
Definition: qmath.h:205
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65
QDeclarativeNullableValue< qreal > x

Properties

◆ height

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::height

Definition at line 96 of file qdeclarativestateoperations.cpp.

◆ heightString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::heightString

Definition at line 89 of file qdeclarativestateoperations.cpp.

◆ origParent

QDeclarativeGuard<QDeclarativeItem> QDeclarativeParentChangePrivate::origParent

Definition at line 81 of file qdeclarativestateoperations.cpp.

◆ origStackBefore

QDeclarativeGuard<QDeclarativeItem> QDeclarativeParentChangePrivate::origStackBefore

Definition at line 82 of file qdeclarativestateoperations.cpp.

◆ parent

QDeclarativeGuard<QDeclarativeItem> QDeclarativeParentChangePrivate::parent

Definition at line 80 of file qdeclarativestateoperations.cpp.

◆ rewindParent

QDeclarativeItem* QDeclarativeParentChangePrivate::rewindParent

Definition at line 83 of file qdeclarativestateoperations.cpp.

◆ rewindStackBefore

QDeclarativeItem* QDeclarativeParentChangePrivate::rewindStackBefore

Definition at line 84 of file qdeclarativestateoperations.cpp.

◆ rotation

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::rotation

Definition at line 98 of file qdeclarativestateoperations.cpp.

Referenced by doChange().

◆ rotationString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::rotationString

Definition at line 91 of file qdeclarativestateoperations.cpp.

◆ scale

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::scale

Definition at line 97 of file qdeclarativestateoperations.cpp.

Referenced by doChange().

◆ scaleString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::scaleString

Definition at line 90 of file qdeclarativestateoperations.cpp.

◆ target

QDeclarativeItem* QDeclarativeParentChangePrivate::target

Definition at line 79 of file qdeclarativestateoperations.cpp.

Referenced by doChange().

◆ width

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::width

Definition at line 95 of file qdeclarativestateoperations.cpp.

◆ widthString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::widthString

Definition at line 88 of file qdeclarativestateoperations.cpp.

◆ x

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::x

Definition at line 93 of file qdeclarativestateoperations.cpp.

Referenced by doChange().

◆ xString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::xString

Definition at line 86 of file qdeclarativestateoperations.cpp.

◆ y

QDeclarativeNullableValue<qreal> QDeclarativeParentChangePrivate::y

Definition at line 94 of file qdeclarativestateoperations.cpp.

Referenced by doChange().

◆ yString

QDeclarativeNullableValue<QDeclarativeScriptString> QDeclarativeParentChangePrivate::yString

Definition at line 87 of file qdeclarativestateoperations.cpp.


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