summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-07-29 05:30:16 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-07-29 05:30:16 (GMT)
commit9abd22080de9898a5edf0cb4d9973d3ce611af62 (patch)
treeb1c54dd743f57e5cc0fd3901910257cb492b473a /src/declarative
parentcfa69f8f9710a249b25987cf9b1ec1358cd317ca (diff)
parent282e9bf50ac0c9a33338816968edc64a4f528b91 (diff)
downloadQt-9abd22080de9898a5edf0cb4d9973d3ce611af62.zip
Qt-9abd22080de9898a5edf0cb4d9973d3ce611af62.tar.gz
Qt-9abd22080de9898a5edf0cb4d9973d3ce611af62.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/fx/fx.pri2
-rw-r--r--src/declarative/fx/qfxanchors.cpp58
-rw-r--r--src/declarative/fx/qfxcomponentinstance.cpp2
-rw-r--r--src/declarative/fx/qfxflipable.cpp162
-rw-r--r--src/declarative/fx/qfxflipable.h14
-rw-r--r--src/declarative/fx/qfxgridview.cpp4
-rw-r--r--src/declarative/fx/qfxitem.cpp310
-rw-r--r--src/declarative/fx/qfxitem.h39
-rw-r--r--src/declarative/fx/qfxitem_p.h33
-rw-r--r--src/declarative/fx/qfxlayouts.cpp8
-rw-r--r--src/declarative/fx/qfxlineedit.cpp2
-rw-r--r--src/declarative/fx/qfxlistview.cpp2
-rw-r--r--src/declarative/fx/qfxmouseregion.cpp3
-rw-r--r--src/declarative/fx/qfxpathview.cpp2
-rw-r--r--src/declarative/fx/qfxpathview_p.h2
-rw-r--r--src/declarative/fx/qfxrepeater.cpp4
-rw-r--r--src/declarative/fx/qfxtextedit.cpp2
-rw-r--r--src/declarative/fx/qfxtransform.cpp919
-rw-r--r--src/declarative/fx/qfxtransform.h356
-rw-r--r--src/declarative/fx/qfxwebview.cpp1
-rw-r--r--src/declarative/qml/qmlvaluetype.cpp57
-rw-r--r--src/declarative/qml/qmlvaluetype_p.h46
-rw-r--r--src/declarative/util/qfxview.cpp2
-rw-r--r--src/declarative/util/qmlstateoperations.cpp10
24 files changed, 297 insertions, 1743 deletions
diff --git a/src/declarative/fx/fx.pri b/src/declarative/fx/fx.pri
index 24c5536..9b4b5ab 100644
--- a/src/declarative/fx/fx.pri
+++ b/src/declarative/fx/fx.pri
@@ -36,7 +36,6 @@ HEADERS += \
fx/qfxtextedit_p.h \
fx/qfxtext.h \
fx/qfxtext_p.h \
- fx/qfxtransform.h \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.h \
fx/qfxlistview.h \
@@ -65,7 +64,6 @@ SOURCES += \
fx/qfxlineedit.cpp \
fx/qfxtext.cpp \
fx/qfxtextedit.cpp \
- fx/qfxtransform.cpp \
fx/qfxpixmap.cpp \
fx/qfxvisualitemmodel.cpp \
fx/qfxlistview.cpp \
diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp
index 9704fef..9093c8e 100644
--- a/src/declarative/fx/qfxanchors.cpp
+++ b/src/declarative/fx/qfxanchors.cpp
@@ -152,9 +152,9 @@ void QFxAnchorsPrivate::fillChanged()
if (!fill || !isItemComplete())
return;
- if (fill == item->itemParent()) { //child-parent
+ if (fill == item->parentItem()) { //child-parent
setItemPos(QPointF(leftMargin, topMargin));
- } else if (fill->itemParent() == item->itemParent()) { //siblings
+ } else if (fill->parentItem() == item->parentItem()) { //siblings
setItemPos(QPointF(fill->x()+leftMargin, fill->y()+topMargin));
}
setItemWidth(fill->width()-leftMargin-rightMargin);
@@ -166,12 +166,12 @@ void QFxAnchorsPrivate::centeredInChanged()
if (!centeredIn || fill || !isItemComplete())
return;
- if (centeredIn == item->itemParent()) {
- QPointF p((item->itemParent()->width() - item->width()) / 2.,
- (item->itemParent()->height() - item->height()) / 2.);
+ if (centeredIn == item->parentItem()) {
+ QPointF p((item->parentItem()->width() - item->width()) / 2.,
+ (item->parentItem()->height() - item->height()) / 2.);
setItemPos(p);
- } else if (centeredIn->itemParent() == item->itemParent()) {
+ } else if (centeredIn->parentItem() == item->parentItem()) {
QPointF p(centeredIn->x() + (centeredIn->width() - item->width()) / 2.,
centeredIn->y() + (centeredIn->height() - item->height()) / 2.);
@@ -328,7 +328,7 @@ void QFxAnchors::setFill(QFxItem *f)
d->fill = f;
return;
}
- if (f != d->item->itemParent() && f->itemParent() != d->item->itemParent()){
+ if (f != d->item->parentItem() && f->parentItem() != d->item->parentItem()){
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
}
@@ -360,7 +360,7 @@ void QFxAnchors::setCenteredIn(QFxItem* c)
d->centeredIn = c;
return;
}
- if (c != d->item->itemParent() && c->itemParent() != d->item->itemParent()){
+ if (c != d->item->parentItem() && c->parentItem() != d->item->parentItem()){
qmlInfo(d->item) << "Can't anchor to an item that isn't a parent or sibling.";
return;
}
@@ -379,10 +379,10 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1,
QFxAnchorLine::AnchorLine line,
int &stretch)
{
- bool edge1IsParent = (edge1.item == item->itemParent());
- bool edge2IsParent = (edge2.item == item->itemParent());
- bool edge1IsSibling = (edge1.item->itemParent() == item->itemParent());
- bool edge2IsSibling = (edge2.item->itemParent() == item->itemParent());
+ bool edge1IsParent = (edge1.item == item->parentItem());
+ bool edge2IsParent = (edge2.item == item->parentItem());
+ bool edge1IsSibling = (edge1.item->parentItem() == item->parentItem());
+ bool edge2IsSibling = (edge2.item->parentItem() == item->parentItem());
bool invalid = false;
if ((edge2IsParent && edge1IsParent) || (edge2IsSibling && edge1IsSibling)) {
@@ -390,10 +390,10 @@ bool QFxAnchorsPrivate::calcStretch(const QFxAnchorLine &edge1,
- ((int)position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsParent && edge1IsSibling) {
stretch = ((int)position(edge2.item, edge2.anchorLine) + offset2)
- - ((int)position(item->itemParent(), line)
+ - ((int)position(item->parentItem(), line)
+ (int)position(edge1.item, edge1.anchorLine) + offset1);
} else if (edge2IsSibling && edge1IsParent) {
- stretch = ((int)position(item->itemParent(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
+ stretch = ((int)position(item->parentItem(), line) + (int)position(edge2.item, edge2.anchorLine) + offset2)
- ((int)position(edge1.item, edge1.anchorLine) + offset1);
} else
invalid = true;
@@ -422,9 +422,9 @@ void QFxAnchorsPrivate::updateVerticalAnchors()
setItemHeight(height);
//Handle top
- if (top.item == item->itemParent()) {
+ if (top.item == item->parentItem()) {
setItemY(adjustedPosition(top.item, top.anchorLine) + topMargin);
- } else if (top.item->itemParent() == item->itemParent()) {
+ } else if (top.item->parentItem() == item->parentItem()) {
setItemY(position(top.item, top.anchorLine) + topMargin);
}
} else if (usedAnchors & QFxAnchors::HasBottomAnchor) {
@@ -438,24 +438,24 @@ void QFxAnchorsPrivate::updateVerticalAnchors()
}
//Handle bottom
- if (bottom.item == item->itemParent()) {
+ if (bottom.item == item->parentItem()) {
setItemY(adjustedPosition(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
- } else if (bottom.item->itemParent() == item->itemParent()) {
+ } else if (bottom.item->parentItem() == item->parentItem()) {
setItemY(position(bottom.item, bottom.anchorLine) - item->height() - bottomMargin);
}
} else if (usedAnchors & QFxAnchors::HasVCenterAnchor) {
//(stetching handled above)
//Handle vCenter
- if (vCenter.item == item->itemParent()) {
+ if (vCenter.item == item->parentItem()) {
setItemY(adjustedPosition(vCenter.item, vCenter.anchorLine)
- item->height()/2 + vCenterOffset);
- } else if (vCenter.item->itemParent() == item->itemParent()) {
+ } else if (vCenter.item->parentItem() == item->parentItem()) {
setItemY(position(vCenter.item, vCenter.anchorLine) - item->height()/2 + vCenterOffset);
}
} else if (usedAnchors & QFxAnchors::HasBaselineAnchor) {
//Handle baseline
- if (baseline.item->itemParent() == item->itemParent()) {
+ if (baseline.item->parentItem() == item->parentItem()) {
setItemY(position(baseline.item, baseline.anchorLine) - item->baselineOffset());
}
}
@@ -488,9 +488,9 @@ void QFxAnchorsPrivate::updateHorizontalAnchors()
setItemWidth(width);
//Handle left
- if (left.item == item->itemParent()) {
+ if (left.item == item->parentItem()) {
setItemX(adjustedPosition(left.item, left.anchorLine) + leftMargin);
- } else if (left.item->itemParent() == item->itemParent()) {
+ } else if (left.item->parentItem() == item->parentItem()) {
setItemX(position(left.item, left.anchorLine) + leftMargin);
}
} else if (usedAnchors & QFxAnchors::HasRightAnchor) {
@@ -504,16 +504,16 @@ void QFxAnchorsPrivate::updateHorizontalAnchors()
}
//Handle right
- if (right.item == item->itemParent()) {
+ if (right.item == item->parentItem()) {
setItemX(adjustedPosition(right.item, right.anchorLine) - item->width() - rightMargin);
- } else if (right.item->itemParent() == item->itemParent()) {
+ } else if (right.item->parentItem() == item->parentItem()) {
setItemX(position(right.item, right.anchorLine) - item->width() - rightMargin);
}
} else if (usedAnchors & QFxAnchors::HasHCenterAnchor) {
//Handle hCenter
- if (hCenter.item == item->itemParent()) {
+ if (hCenter.item == item->parentItem()) {
setItemX(adjustedPosition(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
- } else if (hCenter.item->itemParent() == item->itemParent()) {
+ } else if (hCenter.item->parentItem() == item->parentItem()) {
setItemX(position(hCenter.item, hCenter.anchorLine) - item->width()/2 + hCenterOffset);
}
}
@@ -892,7 +892,7 @@ bool QFxAnchorsPrivate::checkHAnchorValid(QFxAnchorLine anchor) const
} else if (anchor.anchorLine & QFxAnchorLine::Vertical_Mask) {
qmlInfo(item) << "Can't anchor a horizontal edge to a vertical edge.";
return false;
- } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){
+ } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
return false;
} else if (anchor.item == item) {
@@ -929,7 +929,7 @@ bool QFxAnchorsPrivate::checkVAnchorValid(QFxAnchorLine anchor) const
} else if (anchor.anchorLine & QFxAnchorLine::Horizontal_Mask) {
qmlInfo(item) << "Can't anchor a vertical edge to a horizontal edge.";
return false;
- } else if (anchor.item != item->itemParent() && anchor.item->itemParent() != item->itemParent()){
+ } else if (anchor.item != item->parentItem() && anchor.item->parentItem() != item->parentItem()){
qmlInfo(item) << "Can't anchor to an item that isn't a parent or sibling.";
return false;
} else if (anchor.item == item){
diff --git a/src/declarative/fx/qfxcomponentinstance.cpp b/src/declarative/fx/qfxcomponentinstance.cpp
index 3ea45bd..a85b25d 100644
--- a/src/declarative/fx/qfxcomponentinstance.cpp
+++ b/src/declarative/fx/qfxcomponentinstance.cpp
@@ -113,7 +113,7 @@ void QFxComponentInstance::create()
QFxItem *objitem = qobject_cast<QFxItem *>(obj);
if (objitem) {
d->instance = objitem;
- objitem->setItemParent(this);
+ objitem->setParentItem(this);
objitem->setFocus(true);
connect(objitem, SIGNAL(widthChanged()), this, SLOT(updateSize()));
connect(objitem, SIGNAL(heightChanged()), this, SLOT(updateSize()));
diff --git a/src/declarative/fx/qfxflipable.cpp b/src/declarative/fx/qfxflipable.cpp
index fafd04a..228d938 100644
--- a/src/declarative/fx/qfxflipable.cpp
+++ b/src/declarative/fx/qfxflipable.cpp
@@ -41,7 +41,7 @@
#include "qfxflipable.h"
#include "private/qfxitem_p.h"
-#include "qfxtransform.h"
+#include "QtGui/qgraphicstransform.h"
#include <QtDeclarative/qmlinfo.h>
QT_BEGIN_NAMESPACE
@@ -50,18 +50,15 @@ QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Flipable,QFxFlipable)
class QFxFlipablePrivate : public QFxItemPrivate
{
+ Q_DECLARE_PUBLIC(QFxFlipable)
public:
- QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0), axis(0), rotation(0) {}
+ QFxFlipablePrivate() : current(QFxFlipable::Front), front(0), back(0) {}
- void setBackTransform();
- void _q_updateAxis();
+ void updateSceneTransformFromParent();
QFxFlipable::Side current;
QFxItem *front;
QFxItem *back;
- QFxAxis *axis;
- QFxRotation3D axisRotation;
- qreal rotation;
};
/*!
@@ -174,104 +171,6 @@ void QFxFlipable::setBack(QFxItem *back)
}
/*!
- \qmlproperty Axis Flipable::axis
-
- The axis to flip around. See the \l Axis documentation for more
- information on specifying an axis.
-*/
-
-QFxAxis *QFxFlipable::axis()
-{
- Q_D(QFxFlipable);
- return d->axis;
-}
-
-void QFxFlipable::setAxis(QFxAxis *axis)
-{
- Q_D(QFxFlipable);
- //### disconnect if we are already connected?
- if (d->axis)
- disconnect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis()));
- d->axis = axis;
- connect(d->axis, SIGNAL(updated()), this, SLOT(_q_updateAxis()));
- d->_q_updateAxis();
-}
-
-void QFxFlipablePrivate::_q_updateAxis()
-{
- axisRotation.axis()->setStartX(axis->startX());
- axisRotation.axis()->setStartY(axis->startY());
- axisRotation.axis()->setEndX(axis->endX());
- axisRotation.axis()->setEndY(axis->endY());
- axisRotation.axis()->setEndZ(axis->endZ());
-}
-
-void QFxFlipablePrivate::setBackTransform()
-{
- if (!back)
- return;
-
- QPointF p1(0, 0);
- QPointF p2(1, 0);
- QPointF p3(1, 1);
-
- axisRotation.setAngle(180);
- p1 = axisRotation.transform().map(p1);
- p2 = axisRotation.transform().map(p2);
- p3 = axisRotation.transform().map(p3);
- axisRotation.setAngle(rotation);
-
- QTransform mat;
- mat.translate(back->width()/2,back->height()/2);
- if (back->width() && p1.x() >= p2.x())
- mat.rotate(180, Qt::YAxis);
- if (back->height() && p2.y() >= p3.y())
- mat.rotate(180, Qt::XAxis);
- mat.translate(-back->width()/2,-back->height()/2);
- back->setTransform(mat);
-}
-
-/*!
- \qmlproperty real Flipable::rotation
- The angle to rotate the flipable. For example, to show the back side of the flipable
- you can set the rotation to 180.
-*/
-qreal QFxFlipable::rotation() const
-{
- Q_D(const QFxFlipable);
- return d->rotation;
-}
-
-void QFxFlipable::setRotation(qreal angle)
-{
- Q_D(QFxFlipable);
- d->rotation = angle;
- d->axisRotation.setAngle(angle);
- setTransform(d->axisRotation.transform());
-
-
- int simpleAngle = int(angle) % 360;
-
- Side newSide;
- if (simpleAngle < 91 || simpleAngle > 270) {
- newSide = Front;
- } else {
- newSide = Back;
- }
-
- if (newSide != d->current) {
- d->current = newSide;
- if (d->front)
- d->front->setOpacity((d->current==Front)?1.:0.);
- if (d->back) {
- d->setBackTransform();
- d->back->setOpacity((d->current==Back)?1.:0.);
- }
- emit sideChanged();
- }
-}
-
-/*!
\qmlproperty enumeration Flipable::side
The side of the Flippable currently visible. Possible values are \c
@@ -280,50 +179,55 @@ void QFxFlipable::setRotation(qreal angle)
QFxFlipable::Side QFxFlipable::side() const
{
Q_D(const QFxFlipable);
+ if (d->dirtySceneTransform)
+ const_cast<QFxFlipablePrivate *>(d)->updateSceneTransformFromParent();
+
return d->current;
}
-//in some cases the user may want to specify a more complex transformation.
-//in that case, we still allow the generic use of transform.
-//(the logic here should be kept in sync with setBackTransform and setRotation)
-void QFxFlipable::transformChanged(const QTransform &trans)
+// determination on the currently visible side of the flipable
+// has to be done on the complete scene transform to give
+// correct results.
+void QFxFlipablePrivate::updateSceneTransformFromParent()
{
- Q_D(QFxFlipable);
+ Q_Q(QFxFlipable);
+
+ QFxItemPrivate::updateSceneTransformFromParent();
QPointF p1(0, 0);
QPointF p2(1, 0);
QPointF p3(1, 1);
- p1 = trans.map(p1);
- p2 = trans.map(p2);
- p3 = trans.map(p3);
+ p1 = sceneTransform.map(p1);
+ p2 = sceneTransform.map(p2);
+ p3 = sceneTransform.map(p3);
qreal cross = (p1.x() - p2.x()) * (p3.y() - p2.y()) -
(p1.y() - p2.y()) * (p3.x() - p2.x());
- Side newSide;
+ QFxFlipable::Side newSide;
if (cross > 0) {
- newSide = Back;
+ newSide = QFxFlipable::Back;
} else {
- newSide = Front;
+ newSide = QFxFlipable::Front;
}
- if (newSide != d->current) {
- d->current = newSide;
- if (d->current==Back) {
+ if (newSide != current) {
+ current = newSide;
+ if (current == QFxFlipable::Back) {
QTransform mat;
- mat.translate(d->back->width()/2,d->back->height()/2);
- if (d->back->width() && p1.x() >= p2.x())
+ mat.translate(back->width()/2,back->height()/2);
+ if (back->width() && p1.x() >= p2.x())
mat.rotate(180, Qt::YAxis);
- if (d->back->height() && p2.y() >= p3.y())
+ if (back->height() && p2.y() >= p3.y())
mat.rotate(180, Qt::XAxis);
- mat.translate(-d->back->width()/2,-d->back->height()/2);
- d->back->setTransform(mat);
+ mat.translate(-back->width()/2,-back->height()/2);
+ back->setTransform(mat);
}
- if (d->front)
- d->front->setOpacity((d->current==Front)?1.:0.);
- if (d->back)
- d->back->setOpacity((d->current==Back)?1.:0.);
- emit sideChanged();
+ if (front)
+ front->setOpacity((current==QFxFlipable::Front)?1.:0.);
+ if (back)
+ back->setOpacity((current==QFxFlipable::Back)?1.:0.);
+ emit q->sideChanged();
}
}
diff --git a/src/declarative/fx/qfxflipable.h b/src/declarative/fx/qfxflipable.h
index 5aa038d..0ab8fd2 100644
--- a/src/declarative/fx/qfxflipable.h
+++ b/src/declarative/fx/qfxflipable.h
@@ -45,6 +45,7 @@
#include <QtCore/QObject>
#include <QtGui/QTransform>
#include <QtDeclarative/qfxitem.h>
+#include <QtGui/qvector3d.h>
QT_BEGIN_HEADER
@@ -52,7 +53,6 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
-class QFxAxis;
class QFxFlipablePrivate;
class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
{
@@ -61,8 +61,6 @@ class Q_DECLARATIVE_EXPORT QFxFlipable : public QFxItem
Q_ENUMS(Side)
Q_PROPERTY(QFxItem *front READ front WRITE setFront)
Q_PROPERTY(QFxItem *back READ back WRITE setBack)
- Q_PROPERTY(QFxAxis *axis READ axis WRITE setAxis)
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
Q_PROPERTY(Side side READ side NOTIFY sideChanged)
public:
QFxFlipable(QFxItem *parent=0);
@@ -74,23 +72,13 @@ public:
QFxItem *back();
void setBack(QFxItem *);
- QFxAxis *axis();
- void setAxis(QFxAxis *axis);
-
- qreal rotation() const;
- void setRotation(qreal angle);
-
enum Side { Front, Back };
Side side() const;
-protected:
- virtual void transformChanged(const QTransform &);
-
Q_SIGNALS:
void sideChanged();
private:
- Q_PRIVATE_SLOT(d_func(), void _q_updateAxis())
Q_DISABLE_COPY(QFxFlipable)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr, QFxFlipable)
};
diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp
index 27ac92d..8df6f2a 100644
--- a/src/declarative/fx/qfxgridview.cpp
+++ b/src/declarative/fx/qfxgridview.cpp
@@ -1380,9 +1380,9 @@ void QFxGridView::destroyRemoved()
void QFxGridView::createdItem(int index, QFxItem *item)
{
Q_D(QFxGridView);
- item->setItemParent(this);
+ item->setParentItem(this);
if (d->requestedIndex != index) {
- item->setItemParent(this);
+ item->setParentItem(this);
d->unrequestedItems.insert(item, index);
if (d->flow == QFxGridView::LeftToRight) {
item->setPos(QPointF(d->colPosAt(index), d->rowPosAt(index)));
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index f8ed7b4..a65b51a 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -48,6 +48,7 @@
#include <QGraphicsSceneMouseEvent>
#include <QtScript/qscriptengine.h>
#include <private/qfxperf_p.h>
+#include <QtGui/qgraphicstransform.h>
#include <QtDeclarative/qmlengine.h>
#include <private/qmlengine_p.h>
@@ -55,7 +56,6 @@
#include "qlistmodelinterface.h"
#include "qfxanchors_p.h"
-#include "qfxtransform.h"
#include "qfxscalegrid.h"
#include "qfxview.h"
#include "qmlstategroup.h"
@@ -74,6 +74,11 @@ QT_BEGIN_NAMESPACE
QML_DEFINE_NOCREATE_TYPE(QFxContents)
QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Item,QFxItem)
+QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform);
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QGraphicsScale)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QGraphicsRotation)
+QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QGraphicsRotation3D)
+
/*!
\group group_animation
\title Animation
@@ -308,12 +313,6 @@ void QFxContents::setItem(QFxItem *item)
*/
/*!
- \fn void QFxItem::scaleChanged()
-
- This signal is emitted when the scale of the item changes.
-*/
-
-/*!
\fn void QFxItem::stateChanged(const QString &state)
This signal is emitted when the \a state of the item changes.
@@ -354,7 +353,7 @@ void QFxContents::setItem(QFxItem *item)
This signal is emitted when the parent of the item changes.
- \sa setItemParent()
+ \sa setParentItem()
*/
/*!
@@ -440,22 +439,23 @@ QFxItem::~QFxItem()
\property QFxItem::parent
This property holds the parent of the item.
*/
-void QFxItem::setItemParent(QFxItem *parent)
+void QFxItem::setParentItem(QFxItem *parent)
{
- setParent(parent);
+ QFxItem *oldParent = parentItem();
+ if (parent == oldParent || !parent) return;
+
+ QObject::setParent(parent);
+ QGraphicsObject::setParentItem(parent);
+
+ parentChanged(parent, oldParent);
}
/*!
Returns the QFxItem parent of this item.
*/
-QFxItem *QFxItem::itemParent() const
-{
- return qobject_cast<QFxItem *>(QGraphicsItem::parentItem());
-}
-
QFxItem *QFxItem::parentItem() const
{
- return itemParent();
+ return qobject_cast<QFxItem *>(QGraphicsObject::parentItem());
}
/*!
@@ -638,6 +638,45 @@ void QFxItemPrivate::children_clear()
// ###
}
+
+void QFxItemPrivate::transform_removeAt(int i)
+{
+ if (!transformData)
+ return;
+ transformData->graphicsTransforms.removeAt(i);
+ dirtySceneTransform = 1;
+}
+
+int QFxItemPrivate::transform_count() const
+{
+ return transformData ? transformData->graphicsTransforms.size() : 0;
+}
+
+void QFxItemPrivate::transform_append(QGraphicsTransform *item)
+{
+ appendGraphicsTransform(item);
+}
+
+void QFxItemPrivate::transform_insert(int, QGraphicsTransform *)
+{
+ // ###
+}
+
+QGraphicsTransform *QFxItemPrivate::transform_at(int idx) const
+{
+ if (!transformData)
+ return 0;
+ return transformData->graphicsTransforms.at(idx);
+}
+
+void QFxItemPrivate::transform_clear()
+{
+ if (!transformData)
+ return;
+ Q_Q(QFxItem);
+ q->setTransformations(QList<QGraphicsTransform *>());
+}
+
/*!
\qmlproperty list<Object> Item::data
\default
@@ -820,7 +859,7 @@ void QFxItem::qmlLoaded()
QObject* o = c ? c->create(ctxt):0;
QFxItem* ret = qobject_cast<QFxItem*>(o);
if (ret) {
- ret->setItemParent(this);
+ ret->setParentItem(this);
QScriptValue v = QmlEnginePrivate::getScriptEngine(qmlEngine(this))->newQObject(ret);
emit newChildCreated(d->_qmlnewloading.at(i).toString(),v);
}
@@ -849,7 +888,7 @@ void QFxItem::qmlLoaded()
qWarning() << d->_qmlcomp->errors();
QFxItem *qmlChild = qobject_cast<QFxItem *>(obj);
if (qmlChild) {
- qmlChild->setItemParent(this);
+ qmlChild->setParentItem(this);
d->_qmlChildren.insert(d->_qml.toString(), qmlChild);
d->qmlItem = qmlChild;
} else {
@@ -999,12 +1038,8 @@ void QFxItem::geometryChanged(const QRectF &newGeometry,
if (d->_anchors)
d->_anchors->d_func()->updateMe();
- if (newGeometry.size() != oldGeometry.size()) {
- if (rotation() && transformOrigin() != QFxItem::TopLeft)
- setRotation(rotation());
- if (scale() && transformOrigin() != QFxItem::TopLeft)
- setScale(scale());
- }
+ if (transformOrigin() != QFxItem::TopLeft)
+ setTransformOriginPoint(d->computeTransformOrigin());
if (newGeometry.x() != oldGeometry.x())
emit xChanged();
@@ -1037,8 +1072,8 @@ void QFxItem::keyPressEvent(QKeyEvent *event)
QFxKeyEvent ke(*event);
emit keyPress(&ke);
event->setAccepted(ke.isAccepted());
- if (itemParent() && !ke.isAccepted())
- itemParent()->keyPressEvent(event);
+ if (parentItem() && !ke.isAccepted())
+ parentItem()->keyPressEvent(event);
}
/*!
@@ -1049,8 +1084,8 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event)
QFxKeyEvent ke(*event);
emit keyRelease(&ke);
event->setAccepted(ke.isAccepted());
- if (itemParent() && !ke.isAccepted())
- itemParent()->keyReleaseEvent(event);
+ if (parentItem() && !ke.isAccepted())
+ parentItem()->keyReleaseEvent(event);
}
/*!
@@ -1333,29 +1368,6 @@ void QFxItem::setBaselineOffset(qreal offset)
*/
/*!
- \property QFxItem::rotation
- This property holds the rotation of the item in degrees.
-
- This specifies how many degrees to rotate the item around its transformOrigin.
- The default rotation is 0 degrees (i.e. not rotated at all).
-*/
-qreal QFxItem::rotation() const
-{
- Q_D(const QFxItem);
- return d->_rotation;
-}
-
-void QFxItem::setRotation(qreal rotation)
-{
- Q_D(QFxItem);
- if (d->_rotation == rotation)
- return;
- d->_rotation = rotation;
- setTransform(d->transform);
- emit rotationChanged();
-}
-
-/*!
\qmlproperty real Item::scale
This property holds the scale of the item.
@@ -1392,21 +1404,6 @@ void QFxItem::setRotation(qreal rotation)
*/
/*!
- \property QFxItem::scale
- This property holds the scale of the item.
-
- A scale of less than 1 means the item will be displayed smaller than
- normal, and a scale of greater than 1 means the item will be
- displayed larger than normal. A negative scale means the item will
- be mirrored.
-
- By default, items are displayed at a scale of 1 (i.e. at their
- normal size).
-
- Scaling is from the item's transformOrigin.
-*/
-
-/*!
\qmlproperty real Item::opacity
The opacity of the item. Opacity is specified as a number between 0
@@ -1695,17 +1692,14 @@ void QFxItem::setState(const QString &state)
/*!
\property QFxItem::transform
- This property holds the list of transformations to apply.
-
- For more information see \l Transform.
+ This property holds a list of transformations set on the item.
*/
-QList<QFxTransform *> *QFxItem::transform()
+QmlList<QGraphicsTransform *>* QFxItem::transform()
{
Q_D(QFxItem);
- return &(d->_transform);
+ return &(d->transform);
}
-
/*!
Creates a new child of the given component \a type. The
newChildCreated() signal will be emitted when and if the child is
@@ -1776,32 +1770,6 @@ void QFxItem::componentComplete()
d->_stateGroup->componentComplete();
if (d->_anchors)
d->anchors()->d_func()->updateOnComplete();
- if (!d->_transform.isEmpty())
- updateTransform();
-}
-
-/*!
- \internal
-*/
-void QFxItem::updateTransform()
-{
- Q_D(QFxItem);
- QTransform trans;
- for (int ii = d->_transform.count() - 1; ii >= 0; --ii) {
- QFxTransform *a = d->_transform.at(ii);
- if (!a->isIdentity())
- trans = a->transform() * trans;
- }
-
- setTransform(trans);
- transformChanged(trans);
-}
-
-/*!
- \internal
-*/
-void QFxItem::transformChanged(const QTransform &)
-{
}
QmlStateGroup *QFxItemPrivate::states()
@@ -1836,7 +1804,7 @@ QFxItemPrivate::AnchorLines::AnchorLines(QFxItem *q)
baseline.anchorLine = QFxAnchorLine::Baseline;
}
-QPointF QFxItemPrivate::transformOrigin() const
+QPointF QFxItemPrivate::computeTransformOrigin() const
{
Q_Q(const QFxItem);
@@ -1897,8 +1865,6 @@ QVariant QFxItem::itemChange(GraphicsItemChange change,
if (options() & QFxItem::MouseFilter)
d->gvAddMouseFilter();
- if (d->canvas && d->isFocusItemForArea)
- d->canvas->setFocusItem(this);
} else if (change == ItemChildAddedChange ||
change == ItemChildRemovedChange) {
childrenChanged();
@@ -1941,14 +1907,6 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *)
}
/*!
- Returns the item's (0, 0) point mapped to scene coordinates.
- */
-QPointF QFxItem::scenePos() const
-{
- return mapToScene(QPointF(0, 0));
-}
-
-/*!
\enum QFxItem::TransformOrigin
Controls the point about which simple transforms like scale apply.
@@ -1981,16 +1939,10 @@ void QFxItem::setTransformOrigin(TransformOrigin origin)
Q_D(QFxItem);
if (origin != d->origin) {
d->origin = origin;
- update();
+ QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin());
}
}
-QPointF QFxItem::transformOriginPoint() const
-{
- Q_D(const QFxItem);
- return d->transformOrigin();
-}
-
qreal QFxItem::width() const
{
Q_D(const QFxItem);
@@ -2081,61 +2033,6 @@ bool QFxItem::heightValid() const
return d->heightValid;
}
-qreal QFxItem::scale() const
-{
- Q_D(const QFxItem);
- return d->scale;
-}
-
-void QFxItem::setScale(qreal s)
-{
- Q_D(QFxItem);
- if (d->scale == s)
- return;
-
- d->scale = s;
- setTransform(d->transform);
-
- emit scaleChanged();
-}
-
-QRect QFxItem::itemBoundingRect()
-{
- return boundingRect().toAlignedRect();
-}
-
-QTransform QFxItem::transform() const
-{
- Q_D(const QFxItem);
- return d->transform;
-}
-
-//### optimize (perhaps cache scale and rot transforms, and have dirty flags)
-//### we rely on there not being an "if (d->transform == m) return;" check
-void QFxItem::setTransform(const QTransform &m)
-{
- Q_D(QFxItem);
- d->transform = m;
- QTransform scaleTransform, rotTransform;
- if (d->scale != 1) {
- QPointF to = transformOriginPoint();
- if (to.x() != 0. || to.y() != 0.)
- scaleTransform.translate(to.x(), to.y());
- scaleTransform.scale(d->scale, d->scale);
- if (to.x() != 0. || to.y() != 0.)
- scaleTransform.translate(-to.x(), -to.y());
- }
- if (d->_rotation != 0) {
- QPointF to = d->transformOrigin();
- if (to.x() != 0. || to.y() != 0.)
- rotTransform.translate(to.x(), to.y());
- rotTransform.rotate(d->_rotation);
- if (to.x() != 0. || to.y() != 0.)
- rotTransform.translate(-to.x(), -to.y());
- }
- QGraphicsItem::setTransform(scaleTransform * rotTransform * d->transform);
-}
-
QFxItem *QFxItem::mouseGrabberItem() const
{
QGraphicsScene *s = scene();
@@ -2154,28 +2051,49 @@ QFxItem *QFxItem::mouseGrabberItem() const
bool QFxItem::hasFocus() const
{
- Q_D(const QFxItem);
- return d->isFocusItemForArea;
+ const QGraphicsItem *current = this->parentItem();
+ while (current && !(current->flags() & ItemAutoDetectsFocusProxy))
+ current = current->parentItem();
+
+ if (current)
+ return current->focusProxy() == this;
+ else
+ return QGraphicsItem::hasFocus();
}
void QFxItem::setFocus(bool focus)
{
- Q_D(QFxItem);
QGraphicsScene *s = scene();
- if (s) {
- if (d->hasActiveFocus)
- s->setFocusItem(focus ? this : 0);
- else if (focus)
- s->setFocusItem(this);
- else {
- d->isFocusItemForArea = false;
- focusChanged(false);
- }
+ if (!s) {
+ if (focus) QGraphicsItem::setFocus(Qt::OtherFocusReason);
+ else QGraphicsItem::clearFocus();
+ focusChanged(focus);
+ return;
+ }
- } else {
- d->isFocusItemForArea = focus;
+ QGraphicsItem *current = this->parentItem();
+ while (current && !(current->flags() & ItemAutoDetectsFocusProxy))
+ current = current->parentItem();
+
+ if (!current) {
+ if (focus) QGraphicsItem::setFocus(Qt::OtherFocusReason);
+ else QGraphicsItem::clearFocus();
focusChanged(focus);
+ return;
+ }
+
+ if (current->focusProxy() && current->focusProxy() != this) {
+ QFxItem *currentItem = qobject_cast<QFxItem *>(current->focusProxy());
+ if (currentItem)
+ currentItem->setFocus(false);
}
+
+ if (current->focusProxy() == this && !focus)
+ current->setFocusProxy(0);
+ else if (focus)
+ current->setFocusProxy(this);
+
+ focusChanged(focus);
}
/*!
@@ -2185,8 +2103,7 @@ void QFxItem::setFocus(bool focus)
bool QFxItem::hasActiveFocus() const
{
- Q_D(const QFxItem);
- return d->hasActiveFocus;
+ return QGraphicsItem::hasFocus();
}
bool QFxItem::activeFocusPanel() const
@@ -2242,7 +2159,8 @@ void QFxItem::setOptions(Options options, bool set)
setFiltersChildEvents(d->options & ChildMouseFilter);
setFlag(QGraphicsItem::ItemAcceptsInputMethod, (d->options & AcceptsInputMethods));
setAcceptHoverEvents(d->options & HoverEvents);
- d->isFocusRealm = static_cast<bool>(d->options & IsFocusRealm);
+
+ setFlag(QGraphicsItem::ItemAutoDetectsFocusProxy, d->options & IsFocusRealm);
if ((old & MouseFilter) != (d->options & MouseFilter)) {
if (d->options & MouseFilter)
@@ -2252,22 +2170,6 @@ void QFxItem::setOptions(Options options, bool set)
}
}
-/*!
- \fn void QFxItem::setParent(QFxItem *parent)
-
- Sets the parent of the item to \a parent.
- */
-void QFxItem::setParent(QFxItem *p)
-{
- if (p == parent() || !p) return;
-
- QObject::setParent(p);
-
- QFxItem *oldParent = itemParent();
- setParentItem(p);
- parentChanged(p, oldParent);
-}
-
void QFxItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
paintContents(*p);
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index a75bdcd..4837881 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -49,6 +49,7 @@
#include <QtDeclarative/qml.h>
#include <QtDeclarative/qmlcomponent.h>
#include <QtGui/qgraphicsitem.h>
+#include <QtGui/qgraphicstransform.h>
#include <QtGui/qfont.h>
QT_BEGIN_HEADER
@@ -57,6 +58,8 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
+class QGraphicsTransform;
+
class QFxItem;
class Q_DECLARATIVE_EXPORT QFxContents : public QObject
{
@@ -112,7 +115,6 @@ public:
class QmlState;
class QmlTransition;
-class QFxTransform;
class QFxKeyEvent;
class QFxAnchors;
class QFxItemPrivate;
@@ -121,7 +123,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_OBJECT
Q_INTERFACES(QmlParserStatus)
- Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL)
+ Q_PROPERTY(QFxItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QmlList<QFxItem *>* children READ children DESIGNABLE false)
Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL)
@@ -142,12 +144,10 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta
Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL)
Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL)
Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged)
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) // ## remove me
- Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) // ### remove me
Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY
Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL)
Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL)
- Q_PROPERTY(QList<QFxTransform *>* transform READ transform) // ## QGI/QGO
+ Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) // ## QGI/QGO
Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI
Q_ENUMS(TransformOrigin)
Q_CLASSINFO("DefaultProperty", "data")
@@ -176,9 +176,9 @@ public:
QFxItem(QFxItem *parent = 0);
virtual ~QFxItem();
- QFxItem *itemParent() const; // ### remove me
QFxItem *parentItem() const;
- void setItemParent(QFxItem *parent); // ## setParentItem
+ void setParentItem(QFxItem *parent);
+ void setParent(QFxItem *parent) { setParentItem(parent); }
QmlList<QObject *> *data();
QmlList<QFxItem *> *children();
@@ -206,19 +206,11 @@ public:
qreal baselineOffset() const;
void setBaselineOffset(qreal);
- qreal rotation() const;
- void setRotation(qreal);
-
- qreal scale() const;
- void setScale(qreal);
-
- QList<QFxTransform *> *transform();
+ QmlList<QGraphicsTransform *> *transform();
bool isClassComplete() const;
bool isComponentComplete() const;
- void updateTransform(); // ### private!
-
bool keepMouseGrab() const;
void setKeepMouseGrab(bool);
@@ -234,23 +226,13 @@ public:
void setImplicitHeight(qreal);
bool heightValid() const; // ### better name?
- QPointF scenePos() const; // ### remove me
-
TransformOrigin transformOrigin() const;
void setTransformOrigin(TransformOrigin);
- QPointF transformOriginPoint() const;
-
- void setParent(QFxItem *);
-
- QRect itemBoundingRect(); // ### remove me
void setPaintMargin(qreal margin);
QRectF boundingRect() const;
virtual void paintContents(QPainter &);
- QTransform transform() const; // ### remove me
- void setTransform(const QTransform &); // ### remove me
-
QFxItem *mouseGrabberItem() const;
virtual bool hasFocus() const;
@@ -293,7 +275,6 @@ protected:
virtual bool mouseFilter(QGraphicsSceneMouseEvent *);
virtual void mouseUngrabEvent();
- virtual void transformChanged(const QTransform &);
virtual void classBegin();
virtual void classComplete();
virtual void componentComplete();
@@ -345,6 +326,10 @@ QT_END_NAMESPACE
QML_DECLARE_TYPE(QFxContents)
QML_DECLARE_TYPE(QFxItem)
+QML_DECLARE_TYPE(QGraphicsTransform)
+QML_DECLARE_TYPE(QGraphicsScale)
+QML_DECLARE_TYPE(QGraphicsRotation)
+QML_DECLARE_TYPE(QGraphicsRotation3D)
QT_END_HEADER
diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h
index bb3a97a..ebd77f8 100644
--- a/src/declarative/fx/qfxitem_p.h
+++ b/src/declarative/fx/qfxitem_p.h
@@ -76,13 +76,13 @@ class QFxItemPrivate : public QGraphicsItemPrivate
public:
QFxItemPrivate()
: _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0),
- _baselineOffset(0), _rotation(0.),
+ _baselineOffset(0),
_classComplete(true), _componentComplete(true), _keepMouse(false),
_anchorLines(0),
_stateGroup(0), canvas(0), origin(QFxItem::TopLeft),
options(QFxItem::NoOption),
widthValid(false), heightValid(false), width(0), height(0),
- paintmargin(0), scale(1)
+ paintmargin(0)
{}
~QFxItemPrivate()
{ delete _anchors; }
@@ -92,7 +92,7 @@ public:
Q_Q(QFxItem);
if (parent)
- q->setItemParent(parent);
+ q->setParentItem(parent);
_baselineOffset.invalidate();
q->setAcceptedMouseButtons(Qt::NoButton);
q->setFlags(QGraphicsItem::ItemHasNoContents |
@@ -130,7 +130,15 @@ public:
void children_clear();
QML_DECLARE_LIST_PROXY(QFxItemPrivate, QFxItem *, children)
- QList<QFxTransform *> _transform;
+ // transform property
+ void transform_removeAt(int);
+ int transform_count() const;
+ void transform_append(QGraphicsTransform *);
+ void transform_insert(int, QGraphicsTransform *);
+ QGraphicsTransform *transform_at(int) const;
+ void transform_clear();
+ QML_DECLARE_LIST_PROXY(QFxItemPrivate, QGraphicsTransform *, transform)
+
QFxAnchors *anchors() {
if (!_anchors) {
Q_Q(QFxItem);
@@ -149,7 +157,6 @@ public:
QList<QmlComponent*> _qmlnewcomp;
QmlNullableValue<qreal> _baselineOffset;
- float _rotation;
bool _classComplete:1;
bool _componentComplete:1;
@@ -189,26 +196,12 @@ public:
qreal width;
qreal height;
qreal paintmargin;
- qreal scale;
- QPointF transformOrigin() const;
- QTransform transform;
+ QPointF computeTransformOrigin() const;
void gvRemoveMouseFilter();
void gvAddMouseFilter();
- virtual void setActiveFocus(bool b) {
- Q_Q(QFxItem);
- QGraphicsItemPrivate::setActiveFocus(b);
- q->activeFocusChanged(b);
- }
-
- virtual void setFocusItemForArea(bool b) {
- Q_Q(QFxItem);
- QGraphicsItemPrivate::setFocusItemForArea(b);
- q->focusChanged(b);
- }
-
virtual void setPosHelper(const QPointF &pos)
{
Q_Q(QFxItem);
diff --git a/src/declarative/fx/qfxlayouts.cpp b/src/declarative/fx/qfxlayouts.cpp
index 6b94321..0546845 100644
--- a/src/declarative/fx/qfxlayouts.cpp
+++ b/src/declarative/fx/qfxlayouts.cpp
@@ -378,12 +378,12 @@ void QFxBaseLayout::preLayout()
if (d->aut & Horizontal)
setWidth(int(width));
- else if (itemParent())
- setImplicitWidth(itemParent()->width());
+ else if (parentItem())
+ setImplicitWidth(parentItem()->width());
if (d->aut & Vertical)
setHeight(int(height));
- else if (itemParent())
- setImplicitHeight(itemParent()->height());
+ else if (parentItem())
+ setImplicitHeight(parentItem()->height());
setLayoutItem(0);
}
diff --git a/src/declarative/fx/qfxlineedit.cpp b/src/declarative/fx/qfxlineedit.cpp
index 4ff3504..a185383 100644
--- a/src/declarative/fx/qfxlineedit.cpp
+++ b/src/declarative/fx/qfxlineedit.cpp
@@ -367,7 +367,7 @@ void QFxLineEdit::createCursor()
return;
}
- d->cursorItem->setItemParent(this);
+ d->cursorItem->setParentItem(this);
d->cursorItem->setX(d->control->cursorToX());
d->cursorItem->setHeight(d->control->height());
}
diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp
index 36ecddd..5f1defd 100644
--- a/src/declarative/fx/qfxlistview.cpp
+++ b/src/declarative/fx/qfxlistview.cpp
@@ -1615,7 +1615,7 @@ void QFxListView::createdItem(int index, QFxItem *item)
{
Q_D(QFxListView);
if (d->requestedIndex != index) {
- item->setItemParent(viewport());
+ item->setParentItem(viewport());
d->unrequestedItems.insert(item, index);
if (d->orient == Qt::Vertical)
item->setY(d->positionAt(index));
diff --git a/src/declarative/fx/qfxmouseregion.cpp b/src/declarative/fx/qfxmouseregion.cpp
index bc19c23..e4e7442 100644
--- a/src/declarative/fx/qfxmouseregion.cpp
+++ b/src/declarative/fx/qfxmouseregion.cpp
@@ -333,8 +333,7 @@ void QFxMouseRegion::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// ### we should skip this if these signals aren't used
// ### can GV handle this for us?
- const QRect &bounds = itemBoundingRect();
- bool contains = bounds.contains(d->lastPos.toPoint());
+ bool contains = boundingRect().contains(d->lastPos);
if (d->hovered && !contains)
setHovered(false);
else if (!d->hovered && contains)
diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp
index 2a36c25..98121e6 100644
--- a/src/declarative/fx/qfxpathview.cpp
+++ b/src/declarative/fx/qfxpathview.cpp
@@ -737,7 +737,7 @@ void QFxPathView::createdItem(int index, QFxItem *item)
{
Q_D(QFxPathView);
if (d->requestedIndex != index) {
- item->setItemParent(this);
+ item->setParentItem(this);
d->updateItem(item, index < d->firstIndex ? 0.0 : 1.0);
}
}
diff --git a/src/declarative/fx/qfxpathview_p.h b/src/declarative/fx/qfxpathview_p.h
index 63c8224..be9509f 100644
--- a/src/declarative/fx/qfxpathview_p.h
+++ b/src/declarative/fx/qfxpathview_p.h
@@ -96,7 +96,7 @@ public:
requestedIndex = modelIndex;
QFxItem *item = model->item(modelIndex);
if (item)
- item->setItemParent(q);
+ item->setParentItem(q);
requestedIndex = -1;
return item;
}
diff --git a/src/declarative/fx/qfxrepeater.cpp b/src/declarative/fx/qfxrepeater.cpp
index 084921b..a231f20 100644
--- a/src/declarative/fx/qfxrepeater.cpp
+++ b/src/declarative/fx/qfxrepeater.cpp
@@ -62,7 +62,7 @@ QFxItem *QFxRepeaterPrivate::addItem(QmlContext *ctxt, QFxItem *lastItem)
QObject *nobj = component->create(ctxt);
QFxItem *item = qobject_cast<QFxItem *>(nobj);
if (item) {
- item->setParent(q->itemParent());
+ item->setParent(q->parentItem());
// item->stackUnder(lastItem);
deletables << nobj;
} else {
@@ -259,7 +259,7 @@ void QFxRepeater::regenerate()
qDeleteAll(d->deletables);
d->deletables.clear();
- if (!d->component || !itemParent() || !isComponentComplete())
+ if (!d->component || !parentItem() || !isComponentComplete())
return;
QFxItem *lastItem = this;
diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp
index fbb2d53..abad7fc 100644
--- a/src/declarative/fx/qfxtextedit.cpp
+++ b/src/declarative/fx/qfxtextedit.cpp
@@ -531,7 +531,7 @@ void QFxTextEdit::loadCursorDelegate()
this, SLOT(moveCursorDelegate()));
d->control->setCursorWidth(0);
dirtyCache(cursorRect());
- d->cursor->setItemParent(this);
+ d->cursor->setParentItem(this);
d->cursor->setHeight(QFontMetrics(d->font.font()).height());
moveCursorDelegate();
}else{
diff --git a/src/declarative/fx/qfxtransform.cpp b/src/declarative/fx/qfxtransform.cpp
deleted file mode 100644
index 9fc66ef..0000000
--- a/src/declarative/fx/qfxtransform.cpp
+++ /dev/null
@@ -1,919 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include "private/qfxitem_p.h"
-#include "qfxtransform.h"
-#include <QtDeclarative/qmlinfo.h>
-
-#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QML_DEFINE_NOCREATE_TYPE(QFxTransform);
-
-/*!
- \qmlclass Transform
- \brief A transformation.
-*/
-QFxTransform::QFxTransform(QObject *parent) :
- QObject(parent)
-{
-}
-
-QFxTransform::~QFxTransform()
-{
-}
-
-bool QFxTransform::isIdentity() const
-{
- return true;
-}
-
-QTransform QFxTransform::transform() const
-{
- return QTransform();
-}
-
-void QFxTransform::update()
-{
- QFxItem *item = qobject_cast<QFxItem *>(parent());
- if (item)
- item->updateTransform();
-}
-
-/*!
- \qmlclass Scale
- \brief A Scale object provides a way to scale an Item.
-
- The scale object gives more control over scaling than using Item's scale property. Specifically,
- it allows a different scale for the x and y axes, and allows the scale to be relative to an
- arbitrary point.
-
- The following example scales the X axis of the Rect, relative to its interior point 25, 25:
- \qml
- Rect {
- width: 100; height: 100
- color: "blue"
- transform: Scale { originX: 25; originY: 25; xScale: 3}
- }
- \endqml
-*/
-
-QFxScale::QFxScale(QObject *parent)
-: QFxTransform(parent), _originX(0), _originY(0), _xScale(1), _yScale(1), _dirty(true)
-{
-}
-
-QFxScale::~QFxScale()
-{
-}
-
-/*!
- \qmlproperty real Scale::originX
- \qmlproperty real Scale::originY
-
- The origin point for the scale. The scale will be relative to this point.
-*/
-qreal QFxScale::originX() const
-{
- return _originX;
-}
-
-void QFxScale::setOriginX(qreal ox)
-{
- _originX = ox;
- update();
-}
-
-qreal QFxScale::originY() const
-{
- return _originY;
-}
-
-void QFxScale::setOriginY(qreal oy)
-{
- _originY = oy;
- update();
-}
-
-/*!
- \qmlproperty real Scale::xScale
-
- The scaling factor for the X axis.
-*/
-qreal QFxScale::xScale() const
-{
- return _xScale;
-}
-
-void QFxScale::setXScale(qreal scale)
-{
- if (_xScale == scale)
- return;
- _xScale = scale;
- update();
- emit scaleChanged();
-}
-
-/*!
- \qmlproperty real Scale::yScale
-
- The scaling factor for the Y axis.
-*/
-qreal QFxScale::yScale() const
-{
- return _yScale;
-}
-
-void QFxScale::setYScale(qreal scale)
-{
- if (_yScale == scale)
- return;
- _yScale = scale;
- update();
- emit scaleChanged();
-}
-
-bool QFxScale::isIdentity() const
-{
- return (_xScale == 1. && _yScale == 1.);
-}
-
-QTransform QFxScale::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.scale(_xScale, _yScale);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-
-void QFxScale::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Scale,QFxScale)
-
-
-/*!
- \qmlclass Axis
- \brief A Axis object defines an axis that can be used for rotation or translation.
-
- An axis is specified by 2 points in 3D space: a start point and
- an end point. While technically the axis is the line running through these two points
- (and thus many different sets of two points could define the same axis), the distance
- between the points does matter for translation along an axis.
-
- \image 3d-axis.png
-
- \qml
- Axis { startX: 20; startY: 0; endX: 40; endY: 60; endZ: 20 }
- \endqml
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Axis,QFxAxis)
-
-QFxAxis::QFxAxis(QObject *parent)
-: QObject(parent), _startX(0), _startY(0), _endX(0), _endY(0), _endZ(0)
-{
-}
-
-QFxAxis::~QFxAxis()
-{
-}
-
-/*!
- \qmlproperty real Axis::startX
- \qmlproperty real Axis::startY
-
- The start point of the axis. The z-position of the start point is assumed to be 0, and cannot
- be changed.
-*/
-qreal QFxAxis::startX() const
-{
- return _startX;
-}
-
-void QFxAxis::setStartX(qreal x)
-{
- _startX = x;
- emit updated();
-}
-
-qreal QFxAxis::startY() const
-{
- return _startY;
-}
-
-void QFxAxis::setStartY(qreal y)
-{
- _startY = y;
- emit updated();
-}
-
-/*!
- \qmlproperty real Axis::endX
- \qmlproperty real Axis::endY
- \qmlproperty real Axis::endZ
-
- The end point of the axis.
-*/
-qreal QFxAxis::endX() const
-{
- return _endX;
-}
-
-void QFxAxis::setEndX(qreal x)
-{
- _endX = x;
- emit updated();
-}
-
-qreal QFxAxis::endY() const
-{
- return _endY;
-}
-
-void QFxAxis::setEndY(qreal y)
-{
- _endY = y;
- emit updated();
-}
-
-qreal QFxAxis::endZ() const
-{
- return _endZ;
-}
-
-void QFxAxis::setEndZ(qreal z)
-{
- _endZ = z;
- emit updated();
-}
-
-/*!
- \qmlclass Rotation
- \brief A Rotation object provides a way to rotate an Item around a point.
-
- The following example rotates a Rect around its interior point 25, 25:
- \qml
- Rect {
- width: 100; height: 100
- color: "blue"
- transform: Rotation { originX: 25; originY: 25; angle: 45}
- }
- \endqml
-*/
-
-QFxRotation::QFxRotation(QObject *parent)
-: QFxTransform(parent), _originX(0), _originY(0), _angle(0), _dirty(true)
-{
-}
-
-QFxRotation::~QFxRotation()
-{
-}
-
-/*!
- \qmlproperty real Rotation::originX
- \qmlproperty real Rotation::originY
-
- The point to rotate around.
-*/
-qreal QFxRotation::originX() const
-{
- return _originX;
-}
-
-void QFxRotation::setOriginX(qreal ox)
-{
- _originX = ox;
- update();
-}
-
-qreal QFxRotation::originY() const
-{
- return _originY;
-}
-
-void QFxRotation::setOriginY(qreal oy)
-{
- _originY = oy;
- update();
-}
-
-/*!
- \qmlproperty real Rotation::angle
-
- The angle, in degrees, to rotate.
-*/
-qreal QFxRotation::angle() const
-{
- return _angle;
-}
-
-void QFxRotation::setAngle(qreal angle)
-{
- if (_angle == angle)
- return;
- _angle = angle;
- update();
- emit angleChanged();
-}
-
-bool QFxRotation::isIdentity() const
-{
- return (_angle == 0.);
-}
-
-QTransform QFxRotation::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
- _dirty = false;
- _transform.translate(_originX, _originY);
- _transform.rotate(_angle);
- _transform.translate(-_originX, -_originY);
- }
- return _transform;
-}
-
-void QFxRotation::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation,QFxRotation)
-
-/*!
- \qmlclass Rotation3D
- \brief A Rotation3D object provides a way to rotate an Item around an axis.
-
- Here is an example of various rotations applied to an \l Image.
- \snippet doc/src/snippets/declarative/rotation.qml 0
-
- \image axisrotation.png
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Rotation3D,QFxRotation3D)
-
-QFxRotation3D::QFxRotation3D(QObject *parent)
-: QFxTransform(parent), _angle(0), _dirty(true)
-{
- connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
-}
-
-QFxRotation3D::~QFxRotation3D()
-{
-}
-
-/*!
- \qmlproperty real Rotation3D::axis.startX
- \qmlproperty real Rotation3D::axis.startY
- \qmlproperty real Rotation3D::axis.endX
- \qmlproperty real Rotation3D::axis.endY
- \qmlproperty real Rotation3D::axis.endZ
-
- A rotation axis is specified by 2 points in 3D space: a start point and
- an end point. The z-position of the start point is assumed to be 0, and cannot
- be changed.
-
- \image 3d-rotation-axis.png
-
- \sa Axis
-*/
-QFxAxis *QFxRotation3D::axis()
-{
- return &_axis;
-}
-
-/*!
- \qmlproperty real Rotation3D::angle
-
- The angle, in degrees, to rotate around the specified axis.
-*/
-qreal QFxRotation3D::angle() const
-{
- return _angle;
-}
-
-void QFxRotation3D::setAngle(qreal angle)
-{
- _angle = angle;
- update();
-}
-
-bool QFxRotation3D::isIdentity() const
-{
- return (_angle == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
-}
-
-const qreal inv_dist_to_plane = 1. / 1024.;
-QTransform QFxRotation3D::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
-
- if (!isIdentity()) {
- if (angle() != 0.) {
- QTransform rotTrans;
- rotTrans.translate(-_axis.startX(), -_axis.startY());
- QTransform rotTrans2;
- rotTrans2.translate(_axis.startX(), _axis.startY());
-
- qreal rad = angle() * 2. * M_PI / 360.;
- qreal c = ::cos(rad);
- qreal s = ::sin(rad);
-
- qreal x = _axis.endX() - _axis.startX();
- qreal y = _axis.endY() - _axis.startY();
- qreal z = _axis.endZ();
-
- qreal len = x * x + y * y + z * z;
- if (len != 1.) {
- len = ::sqrt(len);
- x /= len;
- y /= len;
- z /= len;
- }
-
- QTransform rot(x*x*(1-c)+c, x*y*(1-c)-z*s, x*z*(1-c)+y*s*inv_dist_to_plane,
- y*x*(1-c)+z*s, y*y*(1-c)+c, y*z*(1-c)-x*s*inv_dist_to_plane,
- 0, 0, 1);
-
- _transform *= rotTrans;
- _transform *= rot;
- _transform *= rotTrans2;
- }
- }
-
- _dirty = false;
- }
-
- return _transform;
-}
-
-void QFxRotation3D::update()
-{
- _dirty = true;
- QFxTransform::update();
-}
-
-/*!
- \internal
- \qmlclass Translation3D
- \brief A Translation3D object provides a way to move an Item along an axis.
-
- The following example translates the image to 10, 3.
- \qml
-Image {
- source: "logo.png"
- transform: [
- Translation3D {
- axis.startX: 0
- axis.startY: 0
- axis.endX: 1
- axis.endY: .3
- distance: 10
- }
- ]
-}
- \endqml
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Translation3D,QFxTranslation3D)
-
-QFxTranslation3D::QFxTranslation3D(QObject *parent)
-: QFxTransform(parent), _distance(0), _dirty(true)
-{
- connect(&_axis, SIGNAL(updated()), this, SLOT(update()));
-}
-
-QFxTranslation3D::~QFxTranslation3D()
-{
-}
-
-/*!
- \qmlproperty real Translation3D::axis.startX
- \qmlproperty real Translation3D::axis.startY
- \qmlproperty real Translation3D::axis.endX
- \qmlproperty real Translation3D::axis.endY
- \qmlproperty real Translation3D::axis.endZ
-
- A translation axis is specified by 2 points in 3D space: a start
- point and an end point. The z-position of the start point is assumed
- to be 0, and cannot be changed. Changing the z-position of the end
- point is only valid when running under OpenGL.
-
- \sa Axis
-*/
-QFxAxis *QFxTranslation3D::axis()
-{
- return &_axis;
-}
-
-/*!
- \qmlproperty real Translation3D::distance
-
- The distance to translate along the specified axis. distance is a
- multiplier; in the example below, a distance of 1 would translate to
- 100, 50, while a distance of 0.5 would translate to 50, 25.
-
- \qml
- Translation3D { axis.startX: 0; axis.startY: 0; axis.endX: 100; axis.endY: 50 }
- \endqml
-*/
-qreal QFxTranslation3D::distance() const
-{
- return _distance;
-}
-
-void QFxTranslation3D::setDistance(qreal distance)
-{
- _distance = distance;
- update();
-}
-
-bool QFxTranslation3D::isIdentity() const
-{
- return (_distance == 0.) || (_axis.endZ() == 0. && _axis.endY() == _axis.startY() && _axis.endX() == _axis.startX());
-}
-
-QTransform QFxTranslation3D::transform() const
-{
- if (_dirty) {
- _transform = QTransform();
-
- if (!isIdentity()) {
- if (distance() != 0.) {
- QTransform trans;
- trans.translate((_axis.endX() - _axis.startX()) * distance(),
- (_axis.endY() - _axis.startY()) * distance());
- _transform *= trans;
- }
- }
-
- _dirty = false;
- }
-
- return _transform;
-}
-
-void QFxTranslation3D::update()
-{
- _dirty = true;
-
- if (_axis.endZ() != 0. && distance() != 0.) {
- qmlInfo(this) << "QTransform cannot translate along Z-axis.";
- }
-
- QFxTransform::update();
-}
-
-/*!
- \internal
- \qmlclass Perspective
- \brief A Perspective object specifies a perspective transformation.
-
- A Perspective transform only affects an item when running under
- OpenGL. When running under software rasterization it has no effect.
-*/
-
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Perspective,QFxPerspective)
-
-QFxPerspective::QFxPerspective(QObject *parent)
- : QFxTransform(parent)
-{
-}
-
-QFxPerspective::~QFxPerspective()
-{
-}
-
-/*!
- \qmlproperty real Perspective::angle
-*/
-
-/*!
- \qmlproperty real Perspective::aspect
-*/
-
-/*!
- \qmlproperty real Perspective::x
-*/
-
-/*!
- \qmlproperty real Perspective::y
-*/
-
-/*!
- \qmlproperty real Perspective::scale
-*/
-
-/*!
- \qmlclass Squish
- \brief A Squish object allows you to distort an item's appearance by 'squishing' it.
-
- Conceptually, a Squish works by allowing you to move the four corners of an item,
- and distorting the item to fit into the newly created polygon.
-
- \image squish-transform.png
-
- Here is an example of various \l Image squishes.
- \qml
- Rect {
- id: Screen
- width: 360; height: 80
- color: "white"
-
- HorizontalLayout {
- margin: 10
- spacing: 10
- Image { source: "qt.png" }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:0
- topRightX:50; topRightY:10
- bottomLeftX:0; bottomLeftY:60
- bottomRightX: 60; bottomRightY:60
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:0
- topRightX:50; topRightY:0
- bottomLeftX:10; bottomLeftY:50
- bottomRightX: 60; bottomRightY:60
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:0; topLeftY:10
- topRightX:60; topRightY:10
- bottomLeftX:0; bottomLeftY:50
- bottomRightX: 60; bottomRightY:50
- }
- }
- Image {
- source: "qt.png"
- transform: Squish {
- x:0; y:0; width:60; height:60
- topLeftX:10; topLeftY:0
- topRightX:50; topRightY:0
- bottomLeftX:10; bottomLeftY:60
- bottomRightX: 50; bottomRightY:60
- }
- }
- }
- }
- \endqml
-
- \image squish.png
-*/
-QML_DEFINE_TYPE(Qt,4,6,(QT_VERSION&0x00ff00)>>8,Squish,QFxSquish)
-
-QFxSquish::QFxSquish(QObject *parent)
- : QFxTransform(parent)
-{
-}
-
-QFxSquish::~QFxSquish()
-{
-}
-
-/*!
- \qmlproperty real Squish::x
- \qmlproperty real Squish::y
- \qmlproperty real Squish::width
- \qmlproperty real Squish::height
-
- This is usually set to the original geometry of the item being squished.
-*/
-qreal QFxSquish::x() const
-{
- return p.x();
-}
-
-void QFxSquish::setX(qreal v)
-{
- p.setX(v);
- update();
-}
-
-qreal QFxSquish::y() const
-{
- return p.y();
-}
-
-void QFxSquish::setY(qreal v)
-{
- p.setY(v);
- update();
-}
-
-qreal QFxSquish::width() const
-{
- return s.width();
-}
-
-void QFxSquish::setWidth(qreal v)
-{
- s.setWidth(v);
- update();
-}
-
-qreal QFxSquish::height() const
-{
- return s.height();
-}
-
-void QFxSquish::setHeight(qreal v)
-{
- s.setHeight(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::topLeftX
- \qmlproperty real Squish::topLeftY
-
- The top left point for the squish.
-*/
-qreal QFxSquish::topLeft_x() const
-{
- return p1.x();
-}
-
-void QFxSquish::settopLeft_x(qreal v)
-{
- p1.setX(v);
- update();
-}
-
-qreal QFxSquish::topLeft_y() const
-{
- return p1.y();
-}
-
-void QFxSquish::settopLeft_y(qreal v)
-{
- p1.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::topRightX
- \qmlproperty real Squish::topRightY
-
- The top right point for the squish.
-*/
-qreal QFxSquish::topRight_x() const
-{
- return p2.x();
-}
-
-void QFxSquish::settopRight_x(qreal v)
-{
- p2.setX(v);
- update();
-}
-
-qreal QFxSquish::topRight_y() const
-{
- return p2.y();
-}
-
-void QFxSquish::settopRight_y(qreal v)
-{
- p2.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::bottomLeftX
- \qmlproperty real Squish::bottomLeftY
-
- The bottom left point for the squish.
-*/
-qreal QFxSquish::bottomLeft_x() const
-{
- return p3.x();
-}
-
-void QFxSquish::setbottomLeft_x(qreal v)
-{
- p3.setX(v);
- update();
-}
-
-qreal QFxSquish::bottomLeft_y() const
-{
- return p3.y();
-}
-
-void QFxSquish::setbottomLeft_y(qreal v)
-{
- p3.setY(v);
- update();
-}
-
-/*!
- \qmlproperty real Squish::bottomRightX
- \qmlproperty real Squish::bottomRightY
-
- The bottom right point for the squish.
-*/
-qreal QFxSquish::bottomRight_x() const
-{
- return p4.x();
-}
-
-void QFxSquish::setbottomRight_x(qreal v)
-{
- p4.setX(v);
- update();
-}
-
-qreal QFxSquish::bottomRight_y() const
-{
- return p4.y();
-}
-
-void QFxSquish::setbottomRight_y(qreal v)
-{
- p4.setY(v);
- update();
-}
-
-bool QFxSquish::isIdentity() const
-{
- return false;
-}
-
-QTransform QFxSquish::transform() const
-{
- QPolygonF poly;
- poly << p << QPointF(p.x() + s.width(), p.y()) << QPointF(p.x() + s.width(), p.y() + s.height()) << QPointF(p.x(), p.y() + s.height());
- QPolygonF poly2;
- poly2 << p1 << p2 << p4 << p3;
-
- QTransform t;
- QTransform::quadToQuad(poly, poly2, t);
- return t;
-}
-
-QT_END_NAMESPACE
diff --git a/src/declarative/fx/qfxtransform.h b/src/declarative/fx/qfxtransform.h
deleted file mode 100644
index fb49294..0000000
--- a/src/declarative/fx/qfxtransform.h
+++ /dev/null
@@ -1,356 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFXTRANSFORM_H
-#define QFXTRANSFORM_H
-
-#include <QtCore/QObject>
-#include <QtGui/QTransform>
-#include <QtDeclarative/qfxitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Declarative)
-
-class Q_DECLARATIVE_EXPORT QFxTransform : public QObject
-{
- Q_OBJECT
-public:
- QFxTransform(QObject *parent=0);
- ~QFxTransform();
-
- void update();
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-};
-
-class Q_DECLARATIVE_EXPORT QFxScale : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
- Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
- Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged())
- Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged())
-public:
- QFxScale(QObject *parent=0);
- ~QFxScale();
-
- qreal originX() const;
- void setOriginX(qreal);
-
- qreal originY() const;
- void setOriginY(qreal);
-
- qreal xScale() const;
- void setXScale(qreal);
-
- qreal yScale() const;
- void setYScale(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-Q_SIGNALS:
- void scaleChanged();
-
-private Q_SLOTS:
- void update();
-private:
- qreal _originX;
- qreal _originY;
- qreal _xScale;
- qreal _yScale;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxAxis : public QObject
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal startX READ startX WRITE setStartX)
- Q_PROPERTY(qreal startY READ startY WRITE setStartY)
- Q_PROPERTY(qreal endX READ endX WRITE setEndX)
- Q_PROPERTY(qreal endY READ endY WRITE setEndY)
- Q_PROPERTY(qreal endZ READ endZ WRITE setEndZ)
-public:
- QFxAxis(QObject *parent=0);
- ~QFxAxis();
-
- qreal startX() const;
- void setStartX(qreal);
-
- qreal startY() const;
- void setStartY(qreal);
-
- qreal endX() const;
- void setEndX(qreal);
-
- qreal endY() const;
- void setEndY(qreal);
-
- qreal endZ() const;
- void setEndZ(qreal);
-
-Q_SIGNALS:
- void updated();
-
-private:
- qreal _startX;
- qreal _startY;
- qreal _endX;
- qreal _endY;
- qreal _endZ;
-};
-
-class Q_DECLARATIVE_EXPORT QFxRotation : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal originX READ originX WRITE setOriginX)
- Q_PROPERTY(qreal originY READ originY WRITE setOriginY)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged())
-public:
- QFxRotation(QObject *parent=0);
- ~QFxRotation();
-
- qreal originX() const;
- void setOriginX(qreal);
-
- qreal originY() const;
- void setOriginY(qreal);
-
- qreal angle() const;
- void setAngle(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-Q_SIGNALS:
- void angleChanged();
-
-private Q_SLOTS:
- void update();
-private:
- qreal _originX;
- qreal _originY;
- qreal _angle;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxRotation3D : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(QFxAxis *axis READ axis)
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
-public:
- QFxRotation3D(QObject *parent=0);
- ~QFxRotation3D();
-
- QFxAxis *axis();
-
- qreal angle() const;
- void setAngle(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private Q_SLOTS:
- void update();
-private:
- QFxAxis _axis;
- qreal _angle;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxTranslation3D : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(QFxAxis *axis READ axis)
- Q_PROPERTY(qreal distance READ distance WRITE setDistance)
-public:
- QFxTranslation3D(QObject *parent=0);
- ~QFxTranslation3D();
-
- QFxAxis *axis();
-
- qreal distance() const;
- void setDistance(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private Q_SLOTS:
- void update();
-private:
- QFxAxis _axis;
- qreal _distance;
-
- mutable bool _dirty;
- mutable QTransform _transform;
-};
-
-class Q_DECLARATIVE_EXPORT QFxPerspective : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal angle READ angle WRITE setAngle)
- Q_PROPERTY(qreal aspect READ aspect WRITE setAspect)
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal scale READ scale WRITE setScale)
-public:
- QFxPerspective(QObject *parent=0);
- ~QFxPerspective();
-
- qreal angle() const { return _angle; }
- void setAngle(qreal v) { _angle = v; update(); }
-
- qreal aspect() const { return _aspect; }
- void setAspect(qreal v) { _aspect = v; update(); }
-
- qreal x() const { return _x; }
- void setX(qreal v) { _x = v; update(); }
-
- qreal y() const { return _y; }
- void setY(qreal v) { _y = v; update(); }
-
- qreal scale() const { return _scale; }
- void setScale(qreal v) { _scale = v; update(); }
-
-private:
- qreal _scale;
- qreal _x;
- qreal _y;
- qreal _angle;
- qreal _aspect;
-};
-
-class Q_DECLARATIVE_EXPORT QFxSquish : public QFxTransform
-{
- Q_OBJECT
-
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_PROPERTY(qreal topLeftX READ topLeft_x WRITE settopLeft_x)
- Q_PROPERTY(qreal topLeftY READ topLeft_y WRITE settopLeft_y)
- Q_PROPERTY(qreal topRightX READ topRight_x WRITE settopRight_x)
- Q_PROPERTY(qreal topRightY READ topRight_y WRITE settopRight_y)
- Q_PROPERTY(qreal bottomLeftX READ bottomLeft_x WRITE setbottomLeft_x)
- Q_PROPERTY(qreal bottomLeftY READ bottomLeft_y WRITE setbottomLeft_y)
- Q_PROPERTY(qreal bottomRightX READ bottomRight_x WRITE setbottomRight_x)
- Q_PROPERTY(qreal bottomRightY READ bottomRight_y WRITE setbottomRight_y)
-public:
- QFxSquish(QObject *parent=0);
- ~QFxSquish();
-
- qreal x() const;
- void setX(qreal);
-
- qreal y() const;
- void setY(qreal);
-
- qreal width() const;
- void setWidth(qreal);
-
- qreal height() const;
- void setHeight(qreal);
-
- qreal topLeft_x() const;
- void settopLeft_x(qreal);
-
- qreal topLeft_y() const;
- void settopLeft_y(qreal);
-
- qreal topRight_x() const;
- void settopRight_x(qreal);
-
- qreal topRight_y() const;
- void settopRight_y(qreal);
-
- qreal bottomLeft_x() const;
- void setbottomLeft_x(qreal);
-
- qreal bottomLeft_y() const;
- void setbottomLeft_y(qreal);
-
- qreal bottomRight_y() const;
- void setbottomRight_y(qreal);
-
- qreal bottomRight_x() const;
- void setbottomRight_x(qreal);
-
- virtual bool isIdentity() const;
- virtual QTransform transform() const;
-
-private:
- QPointF p;
- QSizeF s;
- QPointF p1, p2, p3, p4;
-};
-
-QT_END_NAMESPACE
-
-QML_DECLARE_TYPE(QFxTransform)
-QML_DECLARE_TYPE(QFxScale)
-QML_DECLARE_TYPE(QFxAxis)
-QML_DECLARE_TYPE(QFxRotation)
-QML_DECLARE_TYPE(QFxRotation3D)
-QML_DECLARE_TYPE(QFxTranslation3D)
-QML_DECLARE_TYPE(QFxPerspective)
-QML_DECLARE_TYPE(QFxSquish)
-
-QT_END_HEADER
-
-#endif // QFXTRANSFORM_H
diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp
index 4c6af69..83f9249 100644
--- a/src/declarative/fx/qfxwebview.cpp
+++ b/src/declarative/fx/qfxwebview.cpp
@@ -55,7 +55,6 @@
#include "qml.h"
#include "qmlengine.h"
#include "qmlstate.h"
-#include "qfxtransform.h"
#include "qfxscalegrid.h"
#include "qlistmodelinterface.h"
diff --git a/src/declarative/qml/qmlvaluetype.cpp b/src/declarative/qml/qmlvaluetype.cpp
index 571263e..e93fbc1 100644
--- a/src/declarative/qml/qmlvaluetype.cpp
+++ b/src/declarative/qml/qmlvaluetype.cpp
@@ -59,7 +59,11 @@ QmlValueTypeFactory::~QmlValueTypeFactory()
QmlValueType *QmlValueTypeFactory::valueType(int t)
{
switch (t) {
+ case QVariant::Point:
+ case QVariant::PointF:
+ return new QmlPointValueType;
case QVariant::Rect:
+ case QVariant::RectF:
return new QmlRectValueType;
case QVariant::Vector3D:
return new QmlVector3DValueType;
@@ -73,6 +77,43 @@ QmlValueType::QmlValueType(QObject *parent)
{
}
+QmlPointValueType::QmlPointValueType(QObject *parent)
+: QmlValueType(parent)
+{
+}
+
+void QmlPointValueType::read(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::ReadProperty, idx, a);
+}
+
+void QmlPointValueType::write(QObject *obj, int idx)
+{
+ void *a[] = { &point, 0 };
+ QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
+}
+
+qreal QmlPointValueType::x() const
+{
+ return point.x();
+}
+
+qreal QmlPointValueType::y() const
+{
+ return point.y();
+}
+
+void QmlPointValueType::setX(qreal x)
+{
+ point.setX(x);
+}
+
+void QmlPointValueType::setY(qreal y)
+{
+ point.setY(y);
+}
+
QmlRectValueType::QmlRectValueType(QObject *parent)
: QmlValueType(parent)
{
@@ -90,42 +131,42 @@ void QmlRectValueType::write(QObject *obj, int idx)
QMetaObject::metacall(obj, QMetaObject::WriteProperty, idx, a);
}
-int QmlRectValueType::x() const
+qreal QmlRectValueType::x() const
{
return rect.x();
}
-int QmlRectValueType::y() const
+qreal QmlRectValueType::y() const
{
return rect.y();
}
-void QmlRectValueType::setX(int x)
+void QmlRectValueType::setX(qreal x)
{
rect.moveLeft(x);
}
-void QmlRectValueType::setY(int y)
+void QmlRectValueType::setY(qreal y)
{
rect.moveTop(y);
}
-int QmlRectValueType::width() const
+qreal QmlRectValueType::width() const
{
return rect.width();
}
-int QmlRectValueType::height() const
+qreal QmlRectValueType::height() const
{
return rect.height();
}
-void QmlRectValueType::setWidth(int w)
+void QmlRectValueType::setWidth(qreal w)
{
rect.setWidth(w);
}
-void QmlRectValueType::setHeight(int h)
+void QmlRectValueType::setHeight(qreal h)
{
rect.setHeight(h);
}
diff --git a/src/declarative/qml/qmlvaluetype_p.h b/src/declarative/qml/qmlvaluetype_p.h
index b19c1ba..9195c61 100644
--- a/src/declarative/qml/qmlvaluetype_p.h
+++ b/src/declarative/qml/qmlvaluetype_p.h
@@ -80,12 +80,32 @@ public:
QmlValueType *operator[](int idx) const { return valueTypes[idx]; }
};
+class QmlPointValueType : public QmlValueType
+{
+ Q_PROPERTY(qreal x READ x WRITE setX);
+ Q_PROPERTY(qreal y READ y WRITE setY);
+ Q_OBJECT
+public:
+ QmlPointValueType(QObject *parent = 0);
+
+ virtual void read(QObject *, int);
+ virtual void write(QObject *, int);
+
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
+
+private:
+ QPointF point;
+};
+
class QmlRectValueType : public QmlValueType
{
- Q_PROPERTY(int x READ x WRITE setX);
- Q_PROPERTY(int y READ y WRITE setY);
- Q_PROPERTY(int width READ width WRITE setWidth);
- Q_PROPERTY(int height READ height WRITE setHeight);
+ Q_PROPERTY(qreal x READ x WRITE setX);
+ Q_PROPERTY(qreal y READ y WRITE setY);
+ Q_PROPERTY(qreal width READ width WRITE setWidth);
+ Q_PROPERTY(qreal height READ height WRITE setHeight);
Q_OBJECT
public:
QmlRectValueType(QObject *parent = 0);
@@ -93,18 +113,18 @@ public:
virtual void read(QObject *, int);
virtual void write(QObject *, int);
- int x() const;
- int y() const;
- void setX(int);
- void setY(int);
+ qreal x() const;
+ qreal y() const;
+ void setX(qreal);
+ void setY(qreal);
- int width() const;
- int height() const;
- void setWidth(int);
- void setHeight(int);
+ qreal width() const;
+ qreal height() const;
+ void setWidth(qreal);
+ void setHeight(qreal);
private:
- QRect rect;
+ QRectF rect;
};
class QmlVector3DValueType : public QmlValueType
diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp
index 96d9e8e..2f5cdd3 100644
--- a/src/declarative/util/qfxview.cpp
+++ b/src/declarative/util/qfxview.cpp
@@ -443,7 +443,7 @@ QFxItem* QFxView::addItem(const QString &qml, QFxItem* parent)
if (!parent)
parent = d->root;
- item->setItemParent(parent);
+ item->setParentItem(parent);
return item;
}
return 0;
diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp
index 3d03c34..7caf3ed 100644
--- a/src/declarative/util/qmlstateoperations.cpp
+++ b/src/declarative/util/qmlstateoperations.cpp
@@ -63,8 +63,8 @@ public:
void QmlParentChangePrivate::doChange(QFxItem *targetParent)
{
- if (targetParent && target && target->itemParent()) {
- QPointF me = target->itemParent()->mapToScene(QPointF(0,0));
+ if (targetParent && target && target->parentItem()) {
+ QPointF me = target->parentItem()->mapToScene(QPointF(0,0));
QPointF them = targetParent->mapToScene(QPointF(0,0));
QPointF themx = targetParent->mapToScene(QPointF(1,0));
@@ -73,7 +73,7 @@ void QmlParentChangePrivate::doChange(QFxItem *targetParent)
themx -= them;
themy -= them;
- target->setItemParent(targetParent);
+ target->setParentItem(targetParent);
// XXX - this is silly and will only work in a few cases
@@ -112,7 +112,7 @@ void QmlParentChangePrivate::doChange(QFxItem *targetParent)
target->setX(target->x() - rx);
target->setY(target->y() - ry);
} else if (target) {
- target->setItemParent(targetParent);
+ target->setParentItem(targetParent);
}
}
@@ -182,7 +182,7 @@ void QmlParentChange::execute()
{
Q_D(QmlParentChange);
if (d->target)
- d->origParent = d->target->itemParent();
+ d->origParent = d->target->parentItem();
d->doChange(d->parent);
}