summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-07-29 06:41:41 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-07-29 06:41:41 (GMT)
commitbccbd58365b1a4dfce32701254145ba124270665 (patch)
tree7f03169fe44a0ff8a1687d84d8f61c3c934561f0
parentc50124a15be1e564190f4bb115e2fc67a4c82036 (diff)
parenta45fe18569be1fc91e26f6e58d2f16bc8c6958de (diff)
downloadQt-bccbd58365b1a4dfce32701254145ba124270665.zip
Qt-bccbd58365b1a4dfce32701254145ba124270665.tar.gz
Qt-bccbd58365b1a4dfce32701254145ba124270665.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
-rw-r--r--demos/sub-attaq/submarine.cpp11
-rw-r--r--demos/sub-attaq/submarine.h4
-rw-r--r--demos/sub-attaq/submarine_p.h4
-rw-r--r--src/gui/graphicsview/graphicsview.pri4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp346
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h49
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h39
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp11
-rw-r--r--src/gui/graphicsview/qgraphicstransform.cpp479
-rw-r--r--src/gui/graphicsview/qgraphicstransform.h168
-rw-r--r--src/gui/graphicsview/qgraphicstransform_p.h73
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp34
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h8
-rw-r--r--src/gui/image/qimage.cpp15
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm9
-rw-r--r--src/gui/painting/qtransform.cpp36
-rw-r--r--src/gui/styles/qstyle.cpp2
-rw-r--r--src/gui/styles/qstyleoption.cpp25
-rw-r--r--src/gui/text/qtextformat.cpp101
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp4
-rw-r--r--src/qt3support/sql/q3sqlcursor.cpp2
-rw-r--r--src/sql/drivers/db2/qsql_db2.cpp4
-rw-r--r--src/testlib/qtest.h25
-rw-r--r--src/xml/sax/qxml.cpp18
-rw-r--r--src/xml/sax/qxml.h1
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp158
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp69
-rw-r--r--tests/auto/qgraphicstransform/qgraphicstransform.pro2
-rw-r--r--tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp162
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp11
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h10
-rw-r--r--tests/auto/qxml/tst_qxml.cpp26
-rw-r--r--tests/auto/selftests/cmptest/tst_cmptest.cpp46
-rw-r--r--tests/auto/selftests/expected_cmptest.txt20
34 files changed, 1448 insertions, 528 deletions
diff --git a/demos/sub-attaq/submarine.cpp b/demos/sub-attaq/submarine.cpp
index 78a9539..029e04b 100644
--- a/demos/sub-attaq/submarine.cpp
+++ b/demos/sub-attaq/submarine.cpp
@@ -109,7 +109,14 @@ SubMarine::SubMarine(int type, const QString &name, int points, QGraphicsItem *
setZValue(5);
setFlags(QGraphicsItem::ItemIsMovable);
resize(pixmapItem->boundingRect().width(),pixmapItem->boundingRect().height());
- setTransformOrigin(boundingRect().center());
+ setTransformOriginPoint(boundingRect().center());
+
+ graphicsRotation = new QGraphicsRotation3D(this);
+ graphicsRotation->setAxis(QVector3D(0, 1, 0));
+ graphicsRotation->setOrigin(QPointF(size().width()/2, size().height()/2));
+ QList<QGraphicsTransform *> r;
+ r.append(graphicsRotation);
+ setTransformations(r);
//We setup the state machine of the submarine
QStateMachine *machine = new QStateMachine(this);
@@ -166,7 +173,7 @@ void SubMarine::setCurrentDirection(SubMarine::Movement direction)
if (this->direction == direction)
return;
if (direction == SubMarine::Right && this->direction == SubMarine::None) {
- setYRotation(180);
+ graphicsRotation->setAngle(180);
}
this->direction = direction;
}
diff --git a/demos/sub-attaq/submarine.h b/demos/sub-attaq/submarine.h
index 481e816..564e9c6 100644
--- a/demos/sub-attaq/submarine.h
+++ b/demos/sub-attaq/submarine.h
@@ -45,6 +45,7 @@
//Qt
#include <QtCore/QVariantAnimation>
#include <QtGui/QGraphicsWidget>
+#include <QtGui/QGraphicsTransform>
class PixmapItem;
@@ -75,6 +76,8 @@ public:
virtual int type() const;
+ QGraphicsRotation3D *rotation3d() const { return graphicsRotation; }
+
signals:
void subMarineDestroyed();
void subMarineExecutionFinished();
@@ -87,6 +90,7 @@ private:
int speed;
Movement direction;
PixmapItem *pixmapItem;
+ QGraphicsRotation3D *graphicsRotation;
};
#endif //__SUBMARINE__H__
diff --git a/demos/sub-attaq/submarine_p.h b/demos/sub-attaq/submarine_p.h
index e8df877..c04b25b 100644
--- a/demos/sub-attaq/submarine_p.h
+++ b/demos/sub-attaq/submarine_p.h
@@ -109,7 +109,7 @@ class ReturnState : public QAnimationState
public:
ReturnState(SubMarine *submarine, QState *parent = 0) : QAnimationState(parent)
{
- returnAnimation = new QPropertyAnimation(submarine, "yRotation");
+ returnAnimation = new QPropertyAnimation(submarine->rotation3d(), "angle");
AnimationManager::self()->registerAnimation(returnAnimation);
setAnimation(returnAnimation);
this->submarine = submarine;
@@ -119,7 +119,7 @@ protected:
void onEntry(QEvent *e)
{
returnAnimation->stop();
- returnAnimation->setStartValue(submarine->yRotation());
+ returnAnimation->setStartValue(submarine->rotation3d()->angle());
returnAnimation->setEndValue(submarine->currentDirection() == SubMarine::Right ? 360. : 180.);
returnAnimation->setDuration(500);
QAnimationState::onEntry(e);
diff --git a/src/gui/graphicsview/graphicsview.pri b/src/gui/graphicsview/graphicsview.pri
index 0c0747e..9d232e4 100644
--- a/src/gui/graphicsview/graphicsview.pri
+++ b/src/gui/graphicsview/graphicsview.pri
@@ -16,12 +16,13 @@ HEADERS += graphicsview/qgraphicsgridlayout.h \
graphicsview/qgraphicssceneevent.h \
graphicsview/qgraphicssceneindex_p.h \
graphicsview/qgraphicsscenelinearindex_p.h \
+ graphicsview/qgraphicstransform.h \
+ graphicsview/qgraphicstransform_p.h \
graphicsview/qgraphicsview.h \
graphicsview/qgraphicsview_p.h \
graphicsview/qgraphicswidget.h \
graphicsview/qgraphicswidget_p.h \
graphicsview/qgridlayoutengine_p.h
-
SOURCES += graphicsview/qgraphicsgridlayout.cpp \
graphicsview/qgraphicsitem.cpp \
graphicsview/qgraphicsitemanimation.cpp \
@@ -36,6 +37,7 @@ SOURCES += graphicsview/qgraphicsgridlayout.cpp \
graphicsview/qgraphicssceneevent.cpp \
graphicsview/qgraphicssceneindex.cpp \
graphicsview/qgraphicsscenelinearindex.cpp \
+ graphicsview/qgraphicstransform.cpp \
graphicsview/qgraphicsview.cpp \
graphicsview/qgraphicswidget.cpp \
graphicsview/qgraphicswidget_p.cpp \
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index c8e55e3..6770206 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -303,11 +303,12 @@
drop shadow effects and for decoration objects that follow the parent
item's geometry without drawing on top of it.
- \value ItemUsesExtendedStyleOption The item makes use of either
- QStyleOptionGraphicsItem::exposedRect or QStyleOptionGraphicsItem::matrix.
+ \value ItemUsesExtendedStyleOption The item makes use of either the
+ exposedRect or matrix member of the QStyleOptionGraphicsItem. Implementers
+ of QGraphicsItem subclasses should set that flag if this data is required.
By default, the exposedRect is initialized to the item's boundingRect and
the matrix is untransformed. Enable this flag for more fine-grained values.
- Use QStyleOptionGraphicsItem::levelOfDetailFromTransform for a more
+ Use QStyleOptionGraphicsItem::levelOfDetailFromTransform() for a more
fine-grained value.
\value ItemHasNoContents The item does not paint anything (i.e., calling
@@ -1196,6 +1197,13 @@ QGraphicsItem::~QGraphicsItem()
else
d_ptr->setParentItemHelper(0);
+ if (d_ptr->transformData) {
+ for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
+ QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
+ static_cast<QGraphicsTransformPrivate *>(t->d_ptr)->item = 0;
+ delete t;
+ }
+ }
delete d_ptr->transformData;
delete d_ptr;
@@ -2979,94 +2987,19 @@ QTransform QGraphicsItem::transform() const
/*!
\since 4.6
- Returns the rotation around the X axis.
-
- The default is 0
-
- \warning The value doesn't take in account any rotation set with
- the setTransform() method.
-
- \sa setXRotation(), {Transformations}
-*/
-qreal QGraphicsItem::xRotation() const
-{
- if (!d_ptr->transformData)
- return 0;
- return d_ptr->transformData->xRotation;
-}
-
-/*!
- \since 4.6
-
- Sets the rotation around the X axis to \a angle degrees.
-
- \warning The value doesn't take in account any rotation set with the setTransform() method.
-
- \sa xRotation(), setTransformOrigin(), {Transformations}
-*/
-void QGraphicsItem::setXRotation(qreal angle)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->xRotation = angle;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-}
-
-/*!
- \since 4.6
-
- Returns the rotation around the Y axis.
-
- The default is 0
-
- \warning The value doesn't take in account any rotation set with the setTransform() method.
-
- \sa setYRotation(), {Transformations}
-*/
-qreal QGraphicsItem::yRotation() const
-{
- if (!d_ptr->transformData)
- return 0;
- return d_ptr->transformData->yRotation;
-}
-
-/*!
- \since 4.6
-
- Sets the rotation around the Y axis to \a angle degrees.
-
- \warning The value doesn't take in account any rotation set with the setTransform() method.
-
- \sa yRotation(), setTransformOrigin() {Transformations}
-*/
-void QGraphicsItem::setYRotation(qreal angle)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->yRotation = angle;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-}
-
-/*!
- \since 4.6
-
Returns the rotation around the Z axis.
The default is 0
\warning The value doesn't take in account any rotation set with the setTransform() method.
- \sa setZRotation(), {Transformations}
+ \sa setRotation(), {Transformations}
*/
-qreal QGraphicsItem::zRotation() const
+qreal QGraphicsItem::rotation() const
{
if (!d_ptr->transformData)
return 0;
- return d_ptr->transformData->zRotation;
+ return d_ptr->transformData->rotation;
}
/*!
@@ -3076,224 +3009,107 @@ qreal QGraphicsItem::zRotation() const
\warning The value doesn't take in account any rotation set with the setTransform() method.
- \sa zRotation(), setTransformOrigin(), {Transformations}
+ \sa rotation(), setTransformOriginPoint(), {Transformations}
*/
-void QGraphicsItem::setZRotation(qreal angle)
+void QGraphicsItem::setRotation(qreal angle)
{
prepareGeometryChange();
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->zRotation = angle;
+ d_ptr->transformData->rotation = angle;
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
-}
-
-/*!
- \since 4.6
- This convenience function set the rotation angles around the 3 axes
- to \a x, \a y and \a z.
-
- \sa setXRotation(), setYRotation(), setZRotation(), {Transformations}
-*/
-void QGraphicsItem::setRotation(qreal x, qreal y, qreal z)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->xRotation = x;
- d_ptr->transformData->yRotation = y;
- d_ptr->transformData->zRotation = z;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->rotationChanged();
}
/*!
\since 4.6
- Returns the scale factor on the X axis.
+ Returns the scale factor of the item.
The default is 1
\warning The value doesn't take in account any scaling set with the setTransform() method.
- \sa setXScale(), {Transformations}
+ \sa setScale(), {Transformations}
*/
-qreal QGraphicsItem::xScale() const
+qreal QGraphicsItem::scale() const
{
if (!d_ptr->transformData)
- return 1;
- return d_ptr->transformData->xScale;
+ return 1.;
+ return d_ptr->transformData->scale;
}
/*!
\since 4.6
- Sets the scale factor on the X axis to \a factor.
+ Sets the scale factor of the item to \a factor.
\warning The value doesn't take in account any scaling set with the setTransform() method.
- \sa xScale(), setTransformOrigin(), {Transformations}
+ \sa scale(), setTransformOriginPoint(), {Transformations}
*/
-void QGraphicsItem::setXScale(qreal factor)
+void QGraphicsItem::setScale(qreal factor)
{
prepareGeometryChange();
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->xScale = factor;
+ d_ptr->transformData->scale = factor;
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
-}
-
-/*!
- \since 4.6
-
- Returns the scale factor on the Y axis.
-
- The default is 1
-
- \warning The value doesn't take in account any scaling set with the setTransform() method.
-
- \sa setYScale(), {Transformations}
-*/
-qreal QGraphicsItem::yScale() const
-{
- if (!d_ptr->transformData)
- return 1;
- return d_ptr->transformData->yScale;
-}
-
-/*!
- \since 4.6
-
- Sets the scale factor on the Y axis to \a factor.
- \warning The value doesn't take in account any scaling set with the setTransform() method.
-
- \sa yScale(), setTransformOrigin(), {Transformations}
-*/
-void QGraphicsItem::setYScale(qreal factor)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->yScale = factor;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->scaleChanged();
}
-/*!
- \since 4.6
-
- This convenience function set the scaling factors on X and Y axis to \a sx and \a sy.
-
- \warning The value doesn't take in account any scaling set with the setTransform() method.
-
- \sa setXScale(), setYScale(), {Transformations}
-*/
-void QGraphicsItem::setScale(qreal sx, qreal sy)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->xScale = sx;
- d_ptr->transformData->yScale = sy;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-}
/*!
\since 4.6
- Returns the horizontal shear.
-
- The default is 0
-
- \warning The value doesn't take in account any shearing set with the setTransform() method.
+ returns list of graphics transformations on the item.
- \sa setHorizontalShear(), {Transformations}
+ \sa scale(), setTransformOriginPoint(), {Transformations}
*/
-qreal QGraphicsItem::horizontalShear() const
+QList<QGraphicsTransform *> QGraphicsItem::transformations() const
{
if (!d_ptr->transformData)
- return 0;
- return d_ptr->transformData->horizontalShear;
+ return QList<QGraphicsTransform *>();
+ return d_ptr->transformData->graphicsTransforms;
}
/*!
\since 4.6
- Sets the horizontal shear to \a shear.
-
- \warning The value doesn't take in account any shearing set with the setTransform() method.
+ Sets a list of graphics transformations on the item to \a transformations.
- \sa horizontalShear(), {Transformations}
+ \sa scale(), setTransformOriginPoint(), {Transformations}
*/
-void QGraphicsItem::setHorizontalShear(qreal shear)
+void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations)
{
prepareGeometryChange();
if (!d_ptr->transformData)
d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->horizontalShear = shear;
+ d_ptr->transformData->graphicsTransforms = transformations;
+ for (int i = 0; i < transformations.size(); ++i)
+ transformations.at(i)->d_func()->setItem(this);
d_ptr->transformData->onlyTransform = false;
d_ptr->dirtySceneTransform = 1;
}
-/*!
- \since 4.6
-
- Returns the vertical shear.
-
- The default is 0
-
- \warning The value doesn't take in account any shearing set with the setTransform() method.
- \sa setHorizontalShear(), {Transformations}
-*/
-qreal QGraphicsItem::verticalShear() const
+void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)
{
- if (!d_ptr->transformData)
- return 0;
- return d_ptr->transformData->verticalShear;
-}
+ if (!transformData)
+ transformData = new QGraphicsItemPrivate::TransformData;
+ if (!transformData->graphicsTransforms.contains(t))
+ transformData->graphicsTransforms.append(t);
-/*!
- \since 4.6
-
- Sets the vertical shear to \a shear.
-
- \warning The value doesn't take in account any shearing set with the setTransform() method.
-
- \sa verticalShear(), {Transformations}
-*/
-void QGraphicsItem::setVerticalShear(qreal shear)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->verticalShear = shear;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-}
-
-/*!
- \since 4.6
-
- This convenience function sets the horizontal shear to \a sh and the vertical shear to \a sv.
-
- \warning The value doesn't take in account any shearing set with the setTransform() method.
-
- \sa setHorizontalShear(), setVerticalShear()
-*/
-void QGraphicsItem::setShear(qreal sh, qreal sv)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->horizontalShear = sh;
- d_ptr->transformData->verticalShear = sv;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
+ Q_Q(QGraphicsItem);
+ t->d_func()->setItem(q);
+ transformData->onlyTransform = false;
+ dirtySceneTransform = 1;
}
/*!
@@ -3303,9 +3119,9 @@ void QGraphicsItem::setShear(qreal sh, qreal sv)
The default is QPointF(0,0).
- \sa setTransformOrigin(), {Transformations}
+ \sa setTransformOriginPoint(), {Transformations}
*/
-QPointF QGraphicsItem::transformOrigin() const
+QPointF QGraphicsItem::transformOriginPoint() const
{
if (!d_ptr->transformData)
return QPointF(0,0);
@@ -3317,9 +3133,9 @@ QPointF QGraphicsItem::transformOrigin() const
Sets the \a origin point for the transformation in item coordinates.
- \sa transformOrigin(), {Transformations}
+ \sa transformOriginPoint(), {Transformations}
*/
-void QGraphicsItem::setTransformOrigin(const QPointF &origin)
+void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
{
prepareGeometryChange();
if (!d_ptr->transformData)
@@ -3331,15 +3147,15 @@ void QGraphicsItem::setTransformOrigin(const QPointF &origin)
}
/*!
- \fn void QGraphicsItem::setTransformOrigin(qreal x, qreal y)
+ \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)
\since 4.6
\overload
Sets the origin point for the transformation in item coordinates.
- This is equivalent to calling setTransformOrigin(QPointF(\a x, \a y)).
+ This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)).
- \sa setTransformOrigin(), {Transformations}
+ \sa setTransformOriginPoint(), {Transformations}
*/
@@ -3618,7 +3434,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
\warning using this function doesnt affect the value of the transformation properties
- \sa transform(), setRotation(), setScale(), setShear(), setTransformOrigin(), {The Graphics View Coordinate System}, {Transformations}
+ \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}
*/
void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
{
@@ -3732,7 +3548,7 @@ void QGraphicsItem::shear(qreal sh, qreal sv)
/*!
\obsolete
- Use setPos() or setTransformOrigin() instead.
+ Use setPos() or setTransformOriginPoint() instead.
Translates the current item transformation by (\a dx, \a dy).
@@ -6856,6 +6672,41 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
\sa pos()
*/
+/*!
+ \property QGraphicsObject::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).
+*/
+
+/*!
+ \fn QGraphicsObject::rotationChanged()
+
+ This signal gets emitted whenever the roation of the item changes.
+*/
+
+/*!
+ \property QGraphicsObject::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.
+*/
+
+/*!
+ \fn void QGraphicsObject::scaleChanged()
+
+ This signal is emitted when the scale of the item changes.
+*/
+
/*!
\property QGraphicsObject::enabled
@@ -6895,6 +6746,15 @@ QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent
\sa visible
*/
+/*!
+ \property QGraphicsObject::transformOriginPoint
+ \brief the transformation origin
+
+ This property sets a specific point in the items coordiante system as the
+ origin for scale and rotation.
+
+ \sa scale, rotation, QGraphicsItem::transformOriginPoint()
+*/
/*!
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index 0e21a47..b94fb97 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -71,6 +71,7 @@ class QGraphicsSceneHoverEvent;
class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
class QGraphicsScene;
+class QGraphicsTransform;
class QGraphicsWidget;
class QInputMethodEvent;
class QKeyEvent;
@@ -268,34 +269,19 @@ public:
void shear(qreal sh, qreal sv); // ### obsolete
void translate(qreal dx, qreal dy); // ### obsolete
- qreal xRotation() const;
- void setXRotation(qreal angle);
+ void setRotation(qreal angle);
+ qreal rotation() const;
- qreal yRotation() const;
- void setYRotation(qreal angle);
+ void setScale(qreal scale);
+ qreal scale() const;
- qreal zRotation() const;
- void setZRotation(qreal angle);
- void setRotation(qreal x, qreal y, qreal z);
+ QList<QGraphicsTransform *> transformations() const;
+ void setTransformations(const QList<QGraphicsTransform *> &transformations);
- qreal xScale() const;
- void setXScale(qreal factor);
-
- qreal yScale() const;
- void setYScale(qreal factor);
- void setScale(qreal sx, qreal sy);
-
- qreal horizontalShear() const;
- void setHorizontalShear(qreal shear);
-
- qreal verticalShear() const;
- void setVerticalShear(qreal shear);
- void setShear(qreal sh, qreal sv);
-
- QPointF transformOrigin() const;
- void setTransformOrigin(const QPointF &origin);
- inline void setTransformOrigin(qreal x, qreal y)
- { setTransformOrigin(QPointF(x,y)); }
+ QPointF transformOriginPoint() const;
+ void setTransformOriginPoint(const QPointF &origin);
+ inline void setTransformOriginPoint(qreal x, qreal y)
+ { setTransformOriginPoint(QPointF(x,y)); }
virtual void advance(int phase);
@@ -456,6 +442,7 @@ private:
friend class QGraphicsSceneIndexPrivate;
friend class QGraphicsSceneBspTreeIndex;
friend class QGraphicsSceneBspTreeIndexPrivate;
+ friend class QGraphicsTransformPrivate;
friend class ::tst_QGraphicsItem;
friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *);
@@ -521,9 +508,19 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged)
Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged)
Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged)
+ Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
+ Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
+ Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
public:
QGraphicsObject(QGraphicsItem *parent = 0);
+ // ### Qt 5: Disambiguate
+#ifdef Q_NO_USING_KEYWORD
+ const QObjectList &children() const { return QObject::children(); }
+#else
+ using QObject::children;
+#endif
+
Q_SIGNALS:
void parentChanged();
void opacityChanged();
@@ -532,6 +529,8 @@ Q_SIGNALS:
void xChanged();
void yChanged();
void zChanged();
+ void rotationChanged();
+ void scaleChanged();
protected:
QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene);
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index c208b99..b8d98c1 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -57,6 +57,8 @@
#include "qset.h"
#include "qpixmapcache.h"
#include "qgraphicsview_p.h"
+#include "qgraphicstransform.h"
+#include "qgraphicstransform_p.h"
#include <QtCore/qpoint.h>
@@ -192,7 +194,7 @@ public:
void combineTransformToParent(QTransform *x, const QTransform *viewTransform = 0) const;
void combineTransformFromParent(QTransform *x, const QTransform *viewTransform = 0) const;
- void updateSceneTransformFromParent();
+ virtual void updateSceneTransformFromParent();
// ### Qt 5: Remove. Workaround for reimplementation added after Qt 4.4.
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const;
@@ -200,6 +202,7 @@ public:
void setPosHelper(const QPointF &pos);
void setTransformHelper(const QTransform &transform);
+ void appendGraphicsTransform(QGraphicsTransform *t);
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true);
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
bool discardUpdateRequest(bool ignoreClipping = false, bool ignoreVisibleBit = false,
@@ -467,45 +470,35 @@ public:
struct QGraphicsItemPrivate::TransformData {
QTransform transform;
- qreal xScale;
- qreal yScale;
- qreal xRotation;
- qreal yRotation;
- qreal zRotation;
- qreal horizontalShear;
- qreal verticalShear;
+ qreal scale;
+ qreal rotation;
qreal xOrigin;
qreal yOrigin;
+ QList<QGraphicsTransform *> graphicsTransforms;
bool onlyTransform;
TransformData() :
- xScale(1.0), yScale(1.0), xRotation(0.0), yRotation(0.0), zRotation(0.0),
- horizontalShear(0.0), verticalShear(0.0), xOrigin(0.0), yOrigin(0.0),
+ scale(1.0), rotation(0.0),
+ xOrigin(0.0), yOrigin(0.0),
onlyTransform(true)
{}
QTransform computedFullTransform(QTransform *postmultiplyTransform = 0) const
{
if (onlyTransform) {
- if (!postmultiplyTransform)
- return transform;
- if (postmultiplyTransform->isIdentity())
+ if (!postmultiplyTransform || postmultiplyTransform->isIdentity())
return transform;
if (transform.isIdentity())
return *postmultiplyTransform;
- QTransform x(transform);
- x *= *postmultiplyTransform;
- return x;
+ return transform * *postmultiplyTransform;
}
QTransform x(transform);
- if (xOrigin != 0 || yOrigin != 0)
- x *= QTransform::fromTranslate(xOrigin, yOrigin);
- x.rotate(xRotation, Qt::XAxis);
- x.rotate(yRotation, Qt::YAxis);
- x.rotate(zRotation, Qt::ZAxis);
- x.shear(horizontalShear, verticalShear);
- x.scale(xScale, yScale);
+ for (int i = 0; i < graphicsTransforms.size(); ++i)
+ graphicsTransforms.at(i)->applyTo(&x);
+ x.translate(xOrigin, yOrigin);
+ x.rotate(rotation, Qt::ZAxis);
+ x.scale(scale, scale);
x.translate(-xOrigin, -yOrigin);
if (postmultiplyTransform)
x *= *postmultiplyTransform;
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index f223cbe..a846cf6 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -2356,6 +2356,10 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Deliver post-change notification
item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
+ // Auto-activate the first inactive window if the scene is active.
+ if (d->activationRefCount > 0 && !d->activeWindow && item->isWindow())
+ setActiveWindow(static_cast<QGraphicsWidget *>(item));
+
// Ensure that newly added items that have subfocus set, gain
// focus automatically if there isn't a focus item already.
if (!d->focusItem && item->focusItem())
@@ -3678,6 +3682,13 @@ void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
Q_D(QGraphicsScene);
+ if (d->mouseGrabberItems.isEmpty()) {
+ // Dispatch hover events
+ QGraphicsSceneHoverEvent hover;
+ _q_hoverFromMouseEvent(&hover, mouseEvent);
+ d->dispatchHoverEvent(&hover);
+ }
+
d->mousePressEventHandler(mouseEvent);
}
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp
new file mode 100644
index 0000000..b55d78e
--- /dev/null
+++ b/src/gui/graphicsview/qgraphicstransform.cpp
@@ -0,0 +1,479 @@
+/****************************************************************************
+**
+** 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 "qgraphicstransform.h"
+#include "qgraphicsitem_p.h"
+#include "qgraphicstransform_p.h"
+#include <QDebug>
+
+#include <math.h>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+QT_BEGIN_NAMESPACE
+
+
+void QGraphicsTransformPrivate::setItem(QGraphicsItem *i)
+{
+ if (item == i)
+ return;
+
+ if (item) {
+ Q_Q(QGraphicsTransform);
+ QGraphicsItemPrivate *d_ptr = item->d_ptr;
+
+ item->prepareGeometryChange();
+ Q_ASSERT(d_ptr->transformData);
+ d_ptr->transformData->graphicsTransforms.removeAll(q);
+ d_ptr->dirtySceneTransform = 1;
+ item = 0;
+ }
+
+ item = i;
+}
+
+void QGraphicsTransformPrivate::updateItem(QGraphicsItem *item)
+{
+ item->prepareGeometryChange();
+ item->d_ptr->dirtySceneTransform = 1;
+}
+
+void QGraphicsTransform::update()
+{
+ Q_D(QGraphicsTransform);
+ if (d->item)
+ d->updateItem(d->item);
+}
+
+/*!
+ returns this object as a QTransform.
+*/
+QTransform QGraphicsTransform::transform() const
+{
+ QTransform t;
+ applyTo(&t);
+ return t;
+}
+
+/*!
+ \class QGraphicsTransform
+ \brief The QGraphicsTransform class is an abstract base class for tranformations on QGraphicsItems.
+ \since 4.6
+
+ The classes that inherit QGraphicsTransform express different types of transformations
+ that can be applied to graphics items.
+
+ A list of these transformations can be applied to any graphics item. These
+ transformations are then easily modifyable and usable from e.g. within animations.
+
+ QGraphicsTransform is an abstract base class that is implemented by QGraphicsScale,
+ QGraphicsRotation and QGraphicsRotation3D. Subclasses have to implement the applyTo method.
+
+ \sa QGraphicsItem::transform(), QGraphicsScale, QGraphicsRotation, QGraphicsRotation3D
+*/
+
+/*!
+ Constructs a new QGraphicsTransform with \a parent.
+*/
+QGraphicsTransform::QGraphicsTransform(QObject *parent) :
+ QObject(*new QGraphicsTransformPrivate, parent)
+{
+}
+
+/*!
+ Destructs the graphics transform.
+*/
+QGraphicsTransform::~QGraphicsTransform()
+{
+ Q_D(QGraphicsTransform);
+ d->setItem(0);
+}
+
+/*!
+ \internal
+*/
+QGraphicsTransform::QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent)
+ : QObject(p, parent)
+{
+}
+
+/*! \fn void QGraphicsTransform::applyTo(QTransform *transform) const
+
+ This pure virtual method has to be reimplemented in derived classes.
+
+ It applies this transformation to \a transform.
+*/
+
+
+/*!
+ \class QGraphicsScale
+ \brief The QGraphicsScale class provides a way to scale a graphics item in 2 dimensions.
+ \since 4.6
+
+ QGraphicsScale contains an \a origin around which the scaling happens, and two
+ scale factors, xScale and yScale, the x and one for the y axis.
+*/
+
+class QGraphicsScalePrivate : public QGraphicsTransformPrivate
+{
+public:
+ QGraphicsScalePrivate()
+ : xScale(1), yScale(1) {}
+ QPointF origin;
+ qreal xScale;
+ qreal yScale;
+};
+
+/*!
+ Constructs a new graphics scale object with \a parent.
+*/
+QGraphicsScale::QGraphicsScale(QObject *parent)
+ : QGraphicsTransform(*new QGraphicsScalePrivate, parent)
+{
+}
+
+/*!
+ Destroys the object
+*/
+QGraphicsScale::~QGraphicsScale()
+{
+}
+
+/*!
+ \property QGraphicsScale::origin
+ The origin of the scale. All scaling will be done relative to this point.
+
+ The \a origin is in other words the fixed point for the transformation.
+*/
+QPointF QGraphicsScale::origin() const
+{
+ Q_D(const QGraphicsScale);
+ return d->origin;
+}
+
+void QGraphicsScale::setOrigin(const QPointF &point)
+{
+ Q_D(QGraphicsScale);
+ d->origin = point;
+ update();
+ emit originChanged();
+}
+
+/*!
+ \fn QGraphicsScale::originChanged()
+
+ This signal is emitted whenever the origin of the object
+ changes.
+*/
+
+/*!
+ \property QGraphicsScale::xScale
+
+ The scale factor in x direction. The x direction is
+ in the graphics items logical coordinates.
+
+ \sa yScale
+*/
+qreal QGraphicsScale::xScale() const
+{
+ Q_D(const QGraphicsScale);
+ return d->xScale;
+}
+
+void QGraphicsScale::setXScale(qreal scale)
+{
+ Q_D(QGraphicsScale);
+ if (d->xScale == scale)
+ return;
+ d->xScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+/*!
+ \property QGraphicsScale::yScale
+
+ The scale factor in y direction. The y direction is
+ in the graphics items logical coordinates.
+
+ \sa xScale
+*/
+qreal QGraphicsScale::yScale() const
+{
+ Q_D(const QGraphicsScale);
+ return d->yScale;
+}
+
+void QGraphicsScale::setYScale(qreal scale)
+{
+ Q_D(QGraphicsScale);
+ if (d->yScale == scale)
+ return;
+ d->yScale = scale;
+ update();
+ emit scaleChanged();
+}
+
+/*!
+ \fn QGraphicsScale::scaleChanged()
+
+ This signal is emitted whenever the xScale or yScale of the object
+ changes.
+*/
+
+/*!
+ \reimp
+*/
+void QGraphicsScale::applyTo(QTransform *transform) const
+{
+ Q_D(const QGraphicsScale);
+ transform->translate(d->origin.x(), d->origin.y());
+ transform->scale(d->xScale, d->yScale);
+ transform->translate(-d->origin.x(), -d->origin.y());
+}
+
+/*!
+ \class QGraphicsRotation
+ \brief The QGraphicsRotation class provides a way to rotate a graphics item in 2 dimensions.
+ \since 4.6
+
+ QGraphicsRotation contains an \a origin around which the rotation happens, and one
+ angle in degrees describing the amount of the rotation.
+*/
+
+class QGraphicsRotationPrivate : public QGraphicsTransformPrivate
+{
+public:
+ QGraphicsRotationPrivate()
+ : angle(0) {}
+ QPointF origin;
+ qreal originY;
+ qreal angle;
+};
+
+/*!
+ Constructs a new graphics rotation with \a parent.
+*/
+QGraphicsRotation::QGraphicsRotation(QObject *parent)
+ : QGraphicsTransform(*new QGraphicsRotationPrivate, parent)
+{
+}
+
+/*!
+ \internal
+*/
+QGraphicsRotation::QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *parent)
+ : QGraphicsTransform(p, parent)
+{
+}
+
+/*!
+ Destructs the object
+*/
+QGraphicsRotation::~QGraphicsRotation()
+{
+}
+
+/*!
+ \property QGraphicsRotation::origin
+ The origin around which this object will rotate the graphics item.
+
+ The \a origin is in other words the fixed point for the transformation.
+*/
+QPointF QGraphicsRotation::origin() const
+{
+ Q_D(const QGraphicsRotation);
+ return d->origin;
+}
+
+void QGraphicsRotation::setOrigin(const QPointF &point)
+{
+ Q_D(QGraphicsRotation);
+ d->origin = point;
+ update();
+ emit originChanged();
+}
+
+/*!
+ \fn QGraphicsRotation::originChanged()
+
+ This signal is emitted whenever the origin of the object
+ changes.
+*/
+
+/*!
+ \property QGraphicsRotation::angle
+ The angle, in degrees, of the rotation.
+*/
+qreal QGraphicsRotation::angle() const
+{
+ Q_D(const QGraphicsRotation);
+ return d->angle;
+}
+
+void QGraphicsRotation::setAngle(qreal angle)
+{
+ Q_D(QGraphicsRotation);
+ if (d->angle == angle)
+ return;
+ d->angle = angle;
+ update();
+ emit angleChanged();
+}
+
+/*!
+ \fn void QGraphicsRotation::angleChanged()
+
+ This signal is emitted whenever the angle of the object
+ changes.
+*/
+
+/*!
+ \reimp
+*/
+void QGraphicsRotation::applyTo(QTransform *t) const
+{
+ Q_D(const QGraphicsRotation);
+ if(d->angle) {
+ t->translate(d->origin.x(), d->origin.y());
+ t->rotate(d->angle);
+ t->translate(-d->origin.x(), -d->origin.y());
+ }
+}
+
+
+/*!
+ \class QGraphicsRotation3D
+ \brief The QGraphicsRotation3D class provides a way to rotate a graphics item in 3 dimensions.
+ \since 4.6
+
+ In addition to the origin and angle of a simple QGraphicsRotation, QGraphicsRotation3D contains
+ also an axis that describes around which axis in space the rotation is supposed to happen.
+*/
+
+class QGraphicsRotation3DPrivate : public QGraphicsRotationPrivate
+{
+public:
+ QGraphicsRotation3DPrivate() {}
+
+ QVector3D axis;
+};
+
+/*!
+ Constructs a new 3D rotation with \a parent.
+*/
+QGraphicsRotation3D::QGraphicsRotation3D(QObject *parent)
+ : QGraphicsRotation(*new QGraphicsRotation3DPrivate, parent)
+{
+}
+
+/*!
+ Destroys the object
+*/
+QGraphicsRotation3D::~QGraphicsRotation3D()
+{
+}
+
+/*!
+ \property QGraphicsRotation3D::axis
+
+ A rotation axis is specified by a vector in 3D space.
+*/
+QVector3D QGraphicsRotation3D::axis()
+{
+ Q_D(QGraphicsRotation3D);
+ return d->axis;
+}
+
+void QGraphicsRotation3D::setAxis(const QVector3D &axis)
+{
+ Q_D(QGraphicsRotation3D);
+ d->axis = axis;
+ update();
+}
+
+/*!
+ \fn void QGraphicsRotation3D::axisChanged()
+
+ This signal is emitted whenever the axis of the object
+ changes.
+*/
+
+const qreal inv_dist_to_plane = 1. / 1024.;
+
+/*!
+ \reimp
+*/
+void QGraphicsRotation3D::applyTo(QTransform *t) const
+{
+ Q_D(const QGraphicsRotation3D);
+
+ if (d->angle == 0. ||
+ (d->axis.z() == 0. && d->axis.y() == 0 && d->axis.x() == 0))
+ return;
+
+ qreal rad = d->angle * 2. * M_PI / 360.;
+ qreal c = ::cos(rad);
+ qreal s = ::sin(rad);
+
+ qreal x = d->axis.x();
+ qreal y = d->axis.y();
+ qreal z = d->axis.z();
+
+ qreal len = x * x + y * y + z * z;
+ if (len != 1.) {
+ len = 1./::sqrt(len);
+ x *= len;
+ y *= len;
+ z *= len;
+ }
+
+ t->translate(d->origin.x(), d->origin.y());
+ *t = QTransform(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) * *t;
+ t->translate(-d->origin.x(), -d->origin.y());
+}
+
+#include "moc_qgraphicstransform.cpp"
+
+QT_END_NAMESPACE
diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/gui/graphicsview/qgraphicstransform.h
new file mode 100644
index 0000000..adf9438
--- /dev/null
+++ b/src/gui/graphicsview/qgraphicstransform.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 QGRAPHICSTRANSFORM_H
+#define QGRAPHICSTRANSFORM_H
+
+#include <QtCore/QObject>
+#include <QtGui/QTransform>
+#include <QtGui/QVector3D>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGraphicsItem;
+class QGraphicsTransformPrivate;
+
+class Q_GUI_EXPORT QGraphicsTransform : public QObject
+{
+ Q_OBJECT
+public:
+ QGraphicsTransform(QObject *parent = 0);
+ ~QGraphicsTransform();
+
+ QTransform transform() const;
+ virtual void applyTo(QTransform *transform) const = 0;
+
+protected slots:
+ void update();
+
+protected:
+ QGraphicsTransform(QGraphicsTransformPrivate &p, QObject *parent);
+private:
+ friend class QGraphicsItem;
+ friend class QGraphicsItemPrivate;
+ Q_DECLARE_PRIVATE(QGraphicsTransform)
+};
+
+class QGraphicsScalePrivate;
+
+class Q_GUI_EXPORT QGraphicsScale : public QGraphicsTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPointF origin READ origin WRITE setOrigin NOTIFY originChanged)
+ Q_PROPERTY(qreal xScale READ xScale WRITE setXScale NOTIFY scaleChanged)
+ Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY scaleChanged)
+public:
+ QGraphicsScale(QObject *parent = 0);
+ ~QGraphicsScale();
+
+ QPointF origin() const;
+ void setOrigin(const QPointF &point);
+
+ qreal xScale() const;
+ void setXScale(qreal);
+
+ qreal yScale() const;
+ void setYScale(qreal);
+
+ void applyTo(QTransform *transform) const;
+
+Q_SIGNALS:
+ void originChanged();
+ void scaleChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QGraphicsScale)
+};
+
+class QGraphicsRotationPrivate;
+
+class Q_GUI_EXPORT QGraphicsRotation : public QGraphicsTransform
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QPointF origin READ origin WRITE setOrigin NOTIFY originChanged)
+ Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
+public:
+ QGraphicsRotation(QObject *parent = 0);
+ ~QGraphicsRotation();
+
+ QPointF origin() const;
+ void setOrigin(const QPointF &point);
+
+ qreal angle() const;
+ void setAngle(qreal);
+
+ void applyTo(QTransform *transform) const;
+
+Q_SIGNALS:
+ void originChanged();
+ void angleChanged();
+
+protected:
+ QGraphicsRotation(QGraphicsRotationPrivate &p, QObject *parent);
+private:
+ Q_DECLARE_PRIVATE(QGraphicsRotation)
+};
+
+class QGraphicsRotation3DPrivate;
+
+class Q_GUI_EXPORT QGraphicsRotation3D : public QGraphicsRotation
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
+public:
+ QGraphicsRotation3D(QObject *parent = 0);
+ ~QGraphicsRotation3D();
+
+ QVector3D axis();
+ void setAxis(const QVector3D &axis);
+
+ void applyTo(QTransform *transform) const;
+
+Q_SIGNALS:
+ void axisChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QGraphicsRotation3D)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFXTRANSFORM_H
diff --git a/src/gui/graphicsview/qgraphicstransform_p.h b/src/gui/graphicsview/qgraphicstransform_p.h
new file mode 100644
index 0000000..2d36eda
--- /dev/null
+++ b/src/gui/graphicsview/qgraphicstransform_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSTRANSFORM_P_H
+#define QGRAPHICSTRANSFORM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qobject_p.h"
+
+class QGraphicsItem;
+
+class QGraphicsTransformPrivate : public QObjectPrivate {
+public:
+ Q_DECLARE_PUBLIC(QGraphicsTransform)
+
+ QGraphicsTransformPrivate()
+ : QObjectPrivate(), item(0) {}
+
+ QGraphicsItem *item;
+
+ void setItem(QGraphicsItem *item);
+ static void updateItem(QGraphicsItem *item);
+};
+
+#endif // QGRAPHICSTRANSFORM_P_H
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 6937584..3ea80ce 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -1728,39 +1728,6 @@ QGraphicsWidget *QGraphicsWidget::focusWidget() const
return 0;
}
-/*! \property QGraphicsWidget::horizontalShear
- \brief This property holds the horizontal shear value for the item.
- */
-
-/*! \property QGraphicsWidget::transformOrigin
- \brief This property holds the origin point used for transformations
- in item coordinates.
- */
-
-/*! \property QGraphicsWidget::verticalShear
- \brief This property holds the vertical shear value for the item.
- */
-
-/*! \property QGraphicsWidget::xRotation
- \brief This property holds the value for rotation around the x axis.
- */
-
-/*! \property QGraphicsWidget::xScale
- \brief This property holds the scale factor for the x axis.
- */
-
-/*! \property QGraphicsWidget::yRotation
- \brief This property holds the value for rotation around the y axis.
- */
-
-/*! \property QGraphicsWidget::yScale
- \brief This property holds the scale factor for the y axis.
- */
-
-/*! \property QGraphicsWidget::zRotation
- \brief This property holds the value for rotation around the z axis.
- */
-
#ifndef QT_NO_SHORTCUT
/*!
\since 4.5
@@ -2286,6 +2253,7 @@ bool QGraphicsWidget::close()
#ifdef Q_NO_USING_KEYWORD
/*!
\fn const QObjectList &QGraphicsWidget::children() const
+ \internal
This function returns the same value as QObject::children(). It's
provided to differentiate between the obsolete member
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index b72ec9f..d03a637 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -77,14 +77,6 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay
Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
- Q_PROPERTY(QPointF transformOrigin READ transformOrigin WRITE setTransformOrigin)
- Q_PROPERTY(qreal xRotation READ xRotation WRITE setXRotation)
- Q_PROPERTY(qreal yRotation READ yRotation WRITE setYRotation)
- Q_PROPERTY(qreal zRotation READ zRotation WRITE setZRotation)
- Q_PROPERTY(qreal xScale READ xScale WRITE setXScale)
- Q_PROPERTY(qreal yScale READ yScale WRITE setYScale)
- Q_PROPERTY(qreal horizontalShear READ horizontalShear WRITE setHorizontalShear)
- Q_PROPERTY(qreal verticalShear READ verticalShear WRITE setVerticalShear)
public:
QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
~QGraphicsWidget();
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index dd56765..e8ca7a9 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -4628,12 +4628,19 @@ bool QImage::loadFromData(const uchar *data, int len, const char *format)
binary \a data. The loader attempts to read the image using the
specified \a format. If \a format is not specified (which is the default),
the loader probes the file for a header to guess the file format.
+ binary \a data. The loader attempts to read the image, either using the
+ optional image \a format specified or by determining the image format from
+ the data.
- If the loading of the image failed, this object is a null image.
+ If \a format is not specified (which is the default), the loader probes the
+ file for a header to determine the file format. If \a format is specified,
+ it must be one of the values returned by QImageReader::supportedImageFormats().
+
+ If the loading of the image fails, the image returned will be a null image.
+
+ \sa load(), save(), {QImage#Reading and Writing Image Files}{Reading and Writing Image Files}
+ */
- \sa load(), save(), {QImage#Reading and Writing Image
- Files}{Reading and Writing Image Files}
-*/
QImage QImage::fromData(const uchar *data, int size, const char *format)
{
QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(data), size);
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 1c4177e..3104083 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -1211,7 +1211,10 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse)
if (collapse) {
bool previousIsSeparator = true; // setting to true kills all the separators placed at the top.
NSMenuItem *previousItem = nil;
- for (NSMenuItem *item in [menu itemArray]) {
+
+ NSArray *itemArray = [menu itemArray];
+ for (unsigned int i = 0; i < [itemArray count]; ++i) {
+ NSMenuItem *item = reinterpret_cast<NSMenuItem *>([itemArray objectAtIndex:i]);
if ([item isSeparatorItem]) {
[item setHidden:previousIsSeparator];
}
@@ -1226,7 +1229,9 @@ void qt_mac_menu_collapseSeparators(void */*NSMenu **/ theMenu, bool collapse)
if (previousItem && previousIsSeparator)
[previousItem setHidden:YES];
} else {
- for (NSMenuItem *item in [menu itemArray]) {
+ NSArray *itemArray = [menu itemArray];
+ for (unsigned int i = 0; i < [itemArray count]; ++i) {
+ NSMenuItem *item = reinterpret_cast<NSMenuItem *>([itemArray objectAtIndex:i]);
if (QAction *action = reinterpret_cast<QAction *>([item tag]))
[item setHidden:!action->isVisible()];
}
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 45939c1..a322fe4 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -101,7 +101,7 @@ QT_BEGIN_NAMESPACE
allowing perspective transformations. QTransform's toAffine()
method allows casting QTransform to QMatrix. If a perspective
transformation has been specified on the matrix, then the
- conversion to an affine QMatrix will cause loss of data.
+ conversion will cause loss of data.
QTransform is the recommended transformation class in Qt.
@@ -125,11 +125,13 @@ QT_BEGIN_NAMESPACE
which returns true if the matrix is non-singular (i.e. AB = BA =
I). The inverted() function returns an inverted copy of \e this
matrix if it is invertible (otherwise it returns the identity
- matrix). In addition, QTransform provides the det() function
- returning the matrix's determinant.
+ matrix), and adjoint() returns the matrix's classical adjoint.
+ In addition, QTransform provides the determinant() function which
+ returns the matrix's determinant.
- Finally, the QTransform class supports matrix multiplication, and
- objects of the class can be streamed as well as compared.
+ Finally, the QTransform class supports matrix multiplication, addition
+ and subtraction, and objects of the class can be streamed as well
+ as compared.
\tableofcontents
@@ -191,7 +193,7 @@ QT_BEGIN_NAMESPACE
The various matrix elements can be set when constructing the
matrix, or by using the setMatrix() function later on. They can also
be manipulated using the translate(), rotate(), scale() and
- shear() convenience functions, The currently set values can be
+ shear() convenience functions. The currently set values can be
retrieved using the m11(), m12(), m13(), m21(), m22(), m23(),
m31(), m32(), m33(), dx() and dy() functions.
@@ -204,9 +206,9 @@ QT_BEGIN_NAMESPACE
to 0) mapping a point to itself. Shearing is controlled by \c m12
and \c m21. Setting these elements to values different from zero
will twist the coordinate system. Rotation is achieved by
- carefully setting both the shearing factors and the scaling
- factors. Perspective transformation is achieved by carefully setting
- both the projection factors and the scaling factors.
+ setting both the shearing factors and the scaling factors. Perspective
+ transformation is achieved by setting both the projection factors and
+ the scaling factors.
Here's the combined transformations example using basic matrix
operations:
@@ -958,8 +960,8 @@ QTransform & QTransform::operator=(const QTransform &matrix)
/*!
Resets the matrix to an identity matrix, i.e. all elements are set
- to zero, except \c m11 and \c m22 (specifying the scale) which are
- set to 1.
+ to zero, except \c m11 and \c m22 (specifying the scale) and \c m33
+ which are set to 1.
\sa QTransform(), isIdentity(), {QTransform#Basic Matrix
Operations}{Basic Matrix Operations}
@@ -1773,7 +1775,7 @@ bool QTransform::quadToQuad(const QPolygonF &one,
Sets the matrix elements to the specified values, \a m11,
\a m12, \a m13 \a m21, \a m22, \a m23 \a m31, \a m32 and
\a m33. Note that this function replaces the previous values.
- QMatrix provides the translate(), rotate(), scale() and shear()
+ QTransform provides the translate(), rotate(), scale() and shear()
convenience functions to manipulate the various matrix elements
based on the currently defined coordinate system.
@@ -1951,8 +1953,11 @@ void QTransform::map(int x, int y, int *tx, int *ty) const
}
/*!
- Returns the QTransform cast to a QMatrix.
- */
+ Returns the QTransform as an affine matrix.
+
+ \warning If a perspective transformation has been specified,
+ then the conversion will cause loss of data.
+*/
const QMatrix &QTransform::toAffine() const
{
return affine;
@@ -2030,8 +2035,9 @@ QTransform::operator QVariant() const
/*!
\fn qreal QTransform::det() const
+ \obsolete
- Returns the matrix's determinant.
+ Returns the matrix's determinant. Use determinant() instead.
*/
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp
index c869976..598fe6b 100644
--- a/src/gui/styles/qstyle.cpp
+++ b/src/gui/styles/qstyle.cpp
@@ -564,7 +564,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
/*!
\enum QStyle::PrimitiveElement
- This enum describes that various primitive elements. A
+ This enum describes the various primitive elements. A
primitive element is a common GUI element, such as a checkbox
indicator or button bevel.
diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp
index 7547dda..0ff7995 100644
--- a/src/gui/styles/qstyleoption.cpp
+++ b/src/gui/styles/qstyleoption.cpp
@@ -5007,11 +5007,6 @@ QStyleOptionGraphicsItem::QStyleOptionGraphicsItem(int version)
of the painter used to draw the item. By default, if no
transformations are applied, its value is 1. If zoomed out 1:2, the level
of detail will be 0.5, and if zoomed in 2:1, its value is 2.
-
- For more advanced level-of-detail metrics, use
- QStyleOptionGraphicsItem::matrix directly.
-
- \sa QStyleOptionGraphicsItem::matrix
*/
qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &worldTransform)
{
@@ -5038,20 +5033,32 @@ qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &wor
Make use of this rectangle to speed up item drawing when only parts of the
item are exposed. If the whole item is exposed, this rectangle will be the
same as QGraphicsItem::boundingRect().
+
+ This member is only initialized for items that have the
+ QGraphicsItem::ItemUsesExtendedStyleOption flag set.
*/
/*!
\variable QStyleOptionGraphicsItem::matrix
\brief the complete transformation matrix for the item
+ \obsolete
- This matrix is the sum of the item's scene matrix and the matrix of the
- painter used for drawing the item. It is provided for convenience,
+ The QMatrix provided through this member does include information about
+ any perspective transformations applied to the view or item. To get the
+ correct transformation matrix, use QPainter::transform() on the painter
+ passed into the QGraphicsItem::paint() implementation.
+
+ This matrix is the combination of the item's scene matrix and the matrix
+ of the painter used for drawing the item. It is provided for convenience,
allowing anvanced level-of-detail metrics that can be used to speed up
item drawing.
- To find the dimentions of an item in screen coordinates (i.e., pixels),
+ To find the dimensions of an item in screen coordinates (i.e., pixels),
you can use the mapping functions of QMatrix, such as QMatrix::map().
+ This member is only initialized for items that have the
+ QGraphicsItem::ItemUsesExtendedStyleOption flag set.
+
\sa QStyleOptionGraphicsItem::levelOfDetailFromTransform()
*/
@@ -5059,7 +5066,7 @@ qreal QStyleOptionGraphicsItem::levelOfDetailFromTransform(const QTransform &wor
\variable QStyleOptionGraphicsItem::levelOfDetail
\obsolete
- Use QStyleOptionGraphicsItem::levelOfDetailFromTransform
+ Use QStyleOptionGraphicsItem::levelOfDetailFromTransform()
together with QPainter::worldTransform() instead.
*/
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 4e43418..a3dd83e 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn Type QTextLength::type() const
- Returns the type of length.
+ Returns the type of this length object.
\sa QTextLength::Type
*/
@@ -129,9 +129,15 @@ QT_BEGIN_NAMESPACE
/*!
\enum QTextLength::Type
- \value VariableLength
- \value FixedLength
- \value PercentageLength
+ This enum describes the different types a length object can
+ have.
+
+ \value VariableLength The width of the object is variable
+ \value FixedLength The width of the object is fixed
+ \value PercentageLength The width of the object is in
+ percentage of the maximum width
+
+ \sa type()
*/
/*!
@@ -417,7 +423,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
more useful, and describe the formatting that is applied to
specific parts of the document.
- A format has a \c FormatType which specifies the kinds of thing it
+ A format has a \c FormatType which specifies the kinds of text item it
can format; e.g. a block of text, a list, a table, etc. A format
also has various properties (some specific to particular format
types), as described by the Property enum. Every property has a
@@ -447,24 +453,32 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
/*!
\enum QTextFormat::FormatType
- \value InvalidFormat
- \value BlockFormat
- \value CharFormat
- \value ListFormat
- \value TableFormat
- \value FrameFormat
+ This enum describes the text item a QTextFormat object is formatting.
+
+ \value InvalidFormat An invalid format as created by the default
+ constructor
+ \value BlockFormat The object formats a text block
+ \value CharFormat The object formats a single character
+ \value ListFormat The object formats a list
+ \value TableFormat The object formats a table
+ \value FrameFormat The object formats a frame
\value UserFormat
+
+ \sa QTextCharFormat, QTextBlockFormat, QTextListFormat,
+ QTextTableFormat, type()
*/
/*!
\enum QTextFormat::Property
- \value ObjectIndex
+ This enum describes the different properties a format can have.
+
+ \value ObjectIndex The index of the formatted object. See objectIndex().
Paragraph and character properties
- \value CssFloat
+ \value CssFloat How a frame is located relative to the surrounding text
\value LayoutDirection The layout direction of the text in the document
(Qt::LayoutDirection).
@@ -482,25 +496,25 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\value BlockRightMargin
\value TextIndent
\value TabPositions Specifies the tab positions. The tab positions are structs of QTextOption::Tab which are stored in
- a QList (internally, in a QList<QVariant>).
+ a QList (internally, in a QList<QVariant>).
\value BlockIndent
\value BlockNonBreakableLines
- \value BlockTrailingHorizontalRulerWidth
+ \value BlockTrailingHorizontalRulerWidth The width of a horizontal ruler element.
Character properties
\value FontFamily
\value FontPointSize
+ \value FontPixelSize
\value FontSizeAdjustment Specifies the change in size given to the fontsize already set using
FontPointSize or FontPixelSize.
+ \value FontFixedPitch
\omitvalue FontSizeIncrement
\value FontWeight
\value FontItalic
\value FontUnderline \e{This property has been deprecated.} Use QTextFormat::TextUnderlineStyle instead.
\value FontOverline
\value FontStrikeOut
- \value FontFixedPitch
- \value FontPixelSize
\value FontCapitalization Specifies the capitalization type that is to be applied to the text.
\value FontLetterSpacing Changes the default spacing between individual letters in the font. The value is
specified in percentage, with 100 as the default value.
@@ -512,7 +526,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\omitvalue FirstFontProperty
\omitvalue LastFontProperty
-
+
\value TextUnderlineColor
\value TextVerticalAlignment
\value TextOutline
@@ -533,7 +547,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\value FrameBorder
\value FrameBorderBrush
- \value FrameBorderStyle
+ \value FrameBorderStyle See the \l{QTextFrameFormat::BorderStyle}{BorderStyle} enum.
\value FrameBottomMargin
\value FrameHeight
\value FrameLeftMargin
@@ -565,33 +579,46 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
Selection properties
- \value FullWidthSelection When set on the characterFormat of a selection, the whole width of the text will be shown selected
+ \value FullWidthSelection When set on the characterFormat of a selection,
+ the whole width of the text will be shown selected.
Page break properties
- \value PageBreakPolicy
+ \value PageBreakPolicy Specifies how pages are broken. See the PageBreakFlag enum.
\value UserProperty
+
+ \sa property(), setProperty()
*/
/*!
\enum QTextFormat::ObjectTypes
+ This enum describes what kind of QTextObject this format is associated with.
+
\value NoObject
\value ImageObject
\value TableObject
\value TableCellObject
\value UserObject The first object that can be used for application-specific purposes.
+
+ \sa QTextObject, QTextTable, QTextObject::format()
*/
/*!
\enum QTextFormat::PageBreakFlag
\since 4.2
+ This enum describes how page breaking is performed when printing. It maps to the
+ corresponding css properties.
+
\value PageBreak_Auto The page break is determined automatically depending on the
available space on the current page
\value PageBreak_AlwaysBefore The page is always broken before the paragraph/table
\value PageBreak_AlwaysAfter A new page is always started after the paragraph/table
+
+ \sa QTextBlockFormat::pageBreakPolicy(), QTextFrameFormat::pageBreakPolicy(),
+ PageBreakPolicy
*/
/*!
@@ -971,6 +998,8 @@ QVector<QTextLength> QTextFormat::lengthVectorProperty(int propertyId) const
/*!
Returns the property specified by the given \a propertyId.
+
+ \sa Property
*/
QVariant QTextFormat::property(int propertyId) const
{
@@ -979,6 +1008,8 @@ QVariant QTextFormat::property(int propertyId) const
/*!
Sets the property specified by the \a propertyId to the given \a value.
+
+ \sa Property
*/
void QTextFormat::setProperty(int propertyId, const QVariant &value)
{
@@ -1006,8 +1037,10 @@ void QTextFormat::setProperty(int propertyId, const QVector<QTextLength> &value)
}
/*!
- Clears the value of the property given by \a propertyId
- */
+ Clears the value of the property given by \a propertyId
+
+ \sa Property
+*/
void QTextFormat::clearProperty(int propertyId)
{
if (!d)
@@ -1019,14 +1052,18 @@ void QTextFormat::clearProperty(int propertyId)
/*!
\fn void QTextFormat::setObjectType(int type)
- Sets the text format's object \a type. See \c{ObjectTypes}.
+ Sets the text format's object type to \a type.
+
+ \sa ObjectTypes, objectType()
*/
/*!
\fn int QTextFormat::objectType() const
- Returns the text format's object type. See \c{ObjectTypes}.
+ Returns the text format's object type.
+
+ \sa ObjectTypes, setObjectType()
*/
@@ -2116,17 +2153,17 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt)
/*!
\fn void QTextListFormat::setStyle(Style style)
- Sets the list format's \a style. See \c{Style} for the available styles.
+ Sets the list format's \a style.
- \sa style()
+ \sa style() Style
*/
/*!
\fn Style QTextListFormat::style() const
- Returns the list format's style. See \c{Style}.
+ Returns the list format's style.
- \sa setStyle()
+ \sa setStyle() Style
*/
@@ -2188,16 +2225,21 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt)
/*!
\enum QTextFrameFormat::Position
+ This enum describes how a frame is located relative to the surrounding text.
+
\value InFlow
\value FloatLeft
\value FloatRight
+ \sa position() CssFloat
*/
/*!
\enum QTextFrameFormat::BorderStyle
\since 4.3
+ This enum describes different border styles for the text frame.
+
\value BorderStyle_None
\value BorderStyle_Dotted
\value BorderStyle_Dashed
@@ -2210,6 +2252,7 @@ QTextListFormat::QTextListFormat(const QTextFormat &fmt)
\value BorderStyle_Inset
\value BorderStyle_Outset
+ \sa borderStyle() FrameBorderStyle
*/
/*!
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
index 4b76ef6..030e51f 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
@@ -745,6 +745,7 @@ QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType typ
return new QDirectFBPixmapData(type);
}
+#if (Q_DIRECTFB_VERSION >= 0x000923)
#ifdef QT_NO_DEBUG
struct FlagDescription;
static const FlagDescription *accelerationDescriptions = 0;
@@ -802,9 +803,6 @@ static const FlagDescription drawDescriptions[] = {
};
#endif
-
-
-#if (Q_DIRECTFB_VERSION >= 0x000923)
static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags)
{
#ifdef QT_NO_DEBUG
diff --git a/src/qt3support/sql/q3sqlcursor.cpp b/src/qt3support/sql/q3sqlcursor.cpp
index 6b0c69f..aa6aae2 100644
--- a/src/qt3support/sql/q3sqlcursor.cpp
+++ b/src/qt3support/sql/q3sqlcursor.cpp
@@ -879,7 +879,7 @@ QString Q3SqlCursor::toString(const QString& prefix, QSqlField* field, const QSt
{
QString f;
if (field && driver()) {
- f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + field->name();
+ f = (prefix.length() > 0 ? prefix + QLatin1Char('.') : QString()) + driver()->escapeIdentifier(field->name(), QSqlDriver::FieldName);
f += QLatin1Char(' ') + fieldSep + QLatin1Char(' ');
if (field->isNull()) {
f += QLatin1String("NULL");
diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/sql/drivers/db2/qsql_db2.cpp
index 474c53d..a32b3aa 100644
--- a/src/sql/drivers/db2/qsql_db2.cpp
+++ b/src/sql/drivers/db2/qsql_db2.cpp
@@ -868,11 +868,13 @@ bool QDB2Result::fetch(int i)
SQL_FETCH_ABSOLUTE,
actualIdx);
}
- if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
+ if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) {
setLastError(qMakeError(QCoreApplication::translate("QDB2Result",
"Unable to fetch record %1").arg(i), QSqlError::StatementError, d));
return false;
}
+ else if (r == SQL_NO_DATA)
+ return false;
setAt(i);
return true;
}
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 9d6f68d..8cdfab0 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -53,6 +53,7 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qobject.h>
+#include <QtCore/qvariant.h>
#include <QtCore/qurl.h>
#include <QtCore/qpoint.h>
@@ -146,6 +147,30 @@ template<> inline char *toString(const QUrl &uri)
return qstrdup(uri.toEncoded().constData());
}
+template<> inline char *toString(const QVariant &v)
+{
+ QByteArray vstring("QVariant(");
+ if (v.isValid()) {
+ QByteArray type(v.typeName());
+ if (type.isEmpty()) {
+ type = QByteArray::number(v.userType());
+ }
+ vstring.append(type);
+ if (!v.isNull()) {
+ vstring.append(',');
+ if (v.canConvert(QVariant::String)) {
+ vstring.append(qVariantValue<QString>(v).toLatin1());
+ }
+ else {
+ vstring.append("<value not representable as string>");
+ }
+ }
+ }
+ vstring.append(')');
+
+ return qstrdup(vstring.constData());
+}
+
#ifndef QTEST_NO_SPECIALIZATIONS
template<>
#endif
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index fe1e740..3b1726b 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -244,6 +244,16 @@ public:
class QXmlParseExceptionPrivate
{
public:
+ QXmlParseExceptionPrivate()
+ : column(-1), line(-1)
+ {
+ }
+ QXmlParseExceptionPrivate(const QXmlParseExceptionPrivate &other)
+ : msg(other.msg), column(other.column), line(other.line),
+ pub(other.pub), sys(other.sys)
+ {
+ }
+
QString msg;
int column;
int line;
@@ -553,6 +563,14 @@ QXmlParseException::QXmlParseException(const QString& name, int c, int l,
}
/*!
+ Creates a copy of \a other.
+*/
+QXmlParseException::QXmlParseException(const QXmlParseException& other)
+{
+ d = new QXmlParseExceptionPrivate(*other.d);
+}
+
+/*!
Destroys the QXmlParseException.
*/
QXmlParseException::~QXmlParseException()
diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h
index 8aa7e63..6ccd44e 100644
--- a/src/xml/sax/qxml.h
+++ b/src/xml/sax/qxml.h
@@ -193,6 +193,7 @@ class Q_XML_EXPORT QXmlParseException
public:
explicit QXmlParseException(const QString &name = QString(), int c = -1, int l = -1,
const QString &p = QString(), const QString &s = QString());
+ QXmlParseException(const QXmlParseException &other);
~QXmlParseException();
int columnNumber() const;
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 9f1693d..7f6f322 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -44,6 +44,7 @@
#include <private/qtextcontrol_p.h>
#include <private/qgraphicsitem_p.h>
+#include <private/qgraphicsview_p.h>
#include <QStyleOptionGraphicsItem>
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
@@ -6884,44 +6885,21 @@ void tst_QGraphicsItem::update()
void tst_QGraphicsItem::setTransformProperties_data()
{
QTest::addColumn<QPointF>("origin");
- QTest::addColumn<qreal>("rotationX");
- QTest::addColumn<qreal>("rotationY");
- QTest::addColumn<qreal>("rotationZ");
- QTest::addColumn<qreal>("scaleX");
- QTest::addColumn<qreal>("scaleY");
- QTest::addColumn<qreal>("shearX");
- QTest::addColumn<qreal>("shearY");
+ QTest::addColumn<qreal>("rotation");
+ QTest::addColumn<qreal>("scale");
- QTest::newRow("nothing") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0);
+ QTest::newRow("nothing") << QPointF() << qreal(0.0) << qreal(1.0);
- QTest::newRow("rotationZ") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(42.2)
- << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0);
+ QTest::newRow("rotation") << QPointF() << qreal(42.2) << qreal(1.0);
- QTest::newRow("rotationXY") << QPointF() << qreal(12.5) << qreal(53.6) << qreal(0.0)
- << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0);
+ QTest::newRow("rotation dicentred") << QPointF(qreal(22.3), qreal(-56.2))
+ << qreal(-2578.2)
+ << qreal(1.0);
- QTest::newRow("rotationXYZ") << QPointF() << qreal(-25) << qreal(12) << qreal(556)
- << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0);
+ QTest::newRow("Scale") << QPointF() << qreal(0.0)
+ << qreal(6);
- QTest::newRow("rotationXYZ dicentred") << QPointF(-53, 25.2)
- << qreal(-2578.2) << qreal(4565.2) << qreal(56)
- << qreal(1.0) << qreal(1.0) << qreal(0.0) << qreal(0.0);
-
- QTest::newRow("Scale") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(6) << qreal(0.5) << qreal(0.0) << qreal(0.0);
-
- QTest::newRow("Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(1.0) << qreal(1.0) << qreal(2.2) << qreal(0.5);
-
- QTest::newRow("Scale and Shear") << QPointF() << qreal(0.0) << qreal(0.0) << qreal(0.0)
- << qreal(5.2) << qreal(2.1) << qreal(5.2) << qreal(5.5);
-
- QTest::newRow("Everything") << QPointF() << qreal(41) << qreal(-23) << qreal(0.56)
- << qreal(8.2) << qreal(-0.2) << qreal(-12) << qreal(-0.8);
-
- QTest::newRow("Everything dicentred") << QPointF(qreal(22.3), qreal(-56.2)) << qreal(-175) << qreal(196) << qreal(-1260)
- << qreal(4) << qreal(2) << qreal(2.56) << qreal(0.8);
+ QTest::newRow("Everything dicentred") << QPointF(qreal(22.3), qreal(-56.2)) << qreal(-175) << qreal(196);
}
/**
@@ -6932,92 +6910,61 @@ void tst_QGraphicsItem::setTransformProperties_data()
void tst_QGraphicsItem::setTransformProperties()
{
QFETCH(QPointF,origin);
- QFETCH(qreal,rotationX);
- QFETCH(qreal,rotationY);
- QFETCH(qreal,rotationZ);
- QFETCH(qreal,scaleX);
- QFETCH(qreal,scaleY);
- QFETCH(qreal,shearX);
- QFETCH(qreal,shearY);
+ QFETCH(qreal,rotation);
+ QFETCH(qreal,scale);
QTransform result;
result.translate(origin.x(), origin.y());
- result.rotate(rotationX, Qt::XAxis);
- result.rotate(rotationY, Qt::YAxis);
- result.rotate(rotationZ, Qt::ZAxis);
- result.shear(shearX, shearY);
- result.scale(scaleX, scaleY);
+ result.rotate(rotation, Qt::ZAxis);
+ result.scale(scale, scale);
result.translate(-origin.x(), -origin.y());
QGraphicsScene scene;
QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100));
scene.addItem(item);
- item->setRotation(rotationX, rotationY, rotationZ);
- item->setScale(scaleX, scaleY);
- item->setShear(shearX, shearY);
- item->setTransformOrigin(origin);
+ item->setRotation(rotation);
+ item->setScale(scale);
+ item->setTransformOriginPoint(origin);
- QCOMPARE(item->xRotation(), rotationX);
- QCOMPARE(item->yRotation(), rotationY);
- QCOMPARE(item->zRotation(), rotationZ);
- QCOMPARE(item->xScale(), scaleX);
- QCOMPARE(item->yScale(), scaleY);
- QCOMPARE(item->horizontalShear(), shearX);
- QCOMPARE(item->verticalShear(), shearY);
- QCOMPARE(item->transformOrigin(), origin);
+ QCOMPARE(item->rotation(), rotation);
+ QCOMPARE(item->scale(), scale);
+ QCOMPARE(item->transformOriginPoint(), origin);
QCOMPARE(QTransform(), item->transform());
QCOMPARE(result, item->sceneTransform());
//-----------------------------------------------------------------
//Change the rotation Z
- item->setZRotation(45);
+ item->setRotation(45);
QTransform result2;
result2.translate(origin.x(), origin.y());
- result2.rotate(rotationX, Qt::XAxis);
- result2.rotate(rotationY, Qt::YAxis);
- result2.rotate(45, Qt::ZAxis);
- result2.shear(shearX, shearY);
- result2.scale(scaleX, scaleY);
+ result2.rotate(45);
+ result2.scale(scale, scale);
result2.translate(-origin.x(), -origin.y());
- QCOMPARE(item->xRotation(), rotationX);
- QCOMPARE(item->yRotation(), rotationY);
- QCOMPARE(item->zRotation(), 45.0);
- QCOMPARE(item->xScale(), scaleX);
- QCOMPARE(item->yScale(), scaleY);
- QCOMPARE(item->horizontalShear(), shearX);
- QCOMPARE(item->verticalShear(), shearY);
- QCOMPARE(item->transformOrigin(), origin);
+ QCOMPARE(item->rotation(), 45.);
+ QCOMPARE(item->scale(), scale);
+ QCOMPARE(item->transformOriginPoint(), origin);
QCOMPARE(QTransform(), item->transform());
QCOMPARE(result2, item->sceneTransform());
//-----------------------------------------------------------------
- // calling setTransform() and setPos shoukld change the sceneTransform
+ // calling setTransform() and setPos should change the sceneTransform
item->setTransform(result);
item->setPos(100, -150.5);
- QCOMPARE(item->xRotation(), rotationX);
- QCOMPARE(item->yRotation(), rotationY);
- QCOMPARE(item->zRotation(), 45.0);
- QCOMPARE(item->xScale(), scaleX);
- QCOMPARE(item->yScale(), scaleY);
- QCOMPARE(item->horizontalShear(), shearX);
- QCOMPARE(item->verticalShear(), shearY);
- QCOMPARE(item->transformOrigin(), origin);
+ QCOMPARE(item->rotation(), 45.);
+ QCOMPARE(item->scale(), scale);
+ QCOMPARE(item->transformOriginPoint(), origin);
QCOMPARE(result, item->transform());
- QTransform result3;
+ QTransform result3(result);
result3.translate(origin.x(), origin.y());
- result3 = result * result3;
- result3.rotate(rotationX, Qt::XAxis);
- result3.rotate(rotationY, Qt::YAxis);
- result3.rotate(45, Qt::ZAxis);
- result3.shear(shearX, shearY);
- result3.scale(scaleX, scaleY);
+ result3.rotate(45);
+ result3.scale(scale, scale);
result3.translate(-origin.x(), -origin.y());
result3 *= QTransform::fromTranslate(100, -150.5); //the pos;
@@ -7034,10 +6981,9 @@ void tst_QGraphicsItem::setTransformProperties()
item1->setPos(12.3, -5);
item2->setPos(12.3, -5);
- item1->setRotation(rotationX, rotationY, rotationZ);
- item1->setScale(scaleX, scaleY);
- item1->setShear(shearX, shearY);
- item1->setTransformOrigin(origin);
+ item1->setRotation(rotation);
+ item1->setScale(scale);
+ item1->setTransformOriginPoint(origin);
item2->setTransform(result);
@@ -7046,36 +6992,6 @@ void tst_QGraphicsItem::setTransformProperties()
QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform());
QCOMPARE_TRANSFORM(item2->itemTransform(item1), QTransform());
}
-
- {//with center origin on the item
- QGraphicsRectItem *item1 = new QGraphicsRectItem(QRectF(50.2, -150, 230.5, 119));
- scene.addItem(item1);
- QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(50.2, -150, 230.5, 119));
- scene.addItem(item2);
-
- item1->setPos(12.3, -5);
- item2->setPos(12.3, -5);
- item1->setTransformOrigin(origin);
- item2->setTransformOrigin(origin);
-
- item1->setRotation(rotationX, rotationY, rotationZ);
- item1->setScale(scaleX, scaleY);
- item1->setShear(shearX, shearY);
-
- QTransform tr;
- tr.rotate(rotationX, Qt::XAxis);
- tr.rotate(rotationY, Qt::YAxis);
- tr.rotate(rotationZ, Qt::ZAxis);
- tr.shear(shearX, shearY);
- tr.scale(scaleX, scaleY);
-
- item2->setTransform(tr);
-
- QCOMPARE_TRANSFORM(item1->sceneTransform(), item2->sceneTransform());
-
- QCOMPARE_TRANSFORM(item1->itemTransform(item2), QTransform());
- QCOMPARE_TRANSFORM(item2->itemTransform(item1), QTransform());
- }
}
class MyStyleOptionTester : public QGraphicsRectItem
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index f7ea4ce..4ef1cdd 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -255,6 +255,7 @@ private slots:
void sendEvent();
void inputMethod_data();
void inputMethod();
+ void dispatchHoverOnPress();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -3719,5 +3720,73 @@ void tst_QGraphicsScene::inputMethod()
QCOMPARE(item->queryCalls, 0);
}
+void tst_QGraphicsScene::dispatchHoverOnPress()
+{
+ QGraphicsScene scene;
+ EventTester *tester1 = new EventTester;
+ tester1->setAcceptHoverEvents(true);
+ EventTester *tester2 = new EventTester;
+ tester2->setAcceptHoverEvents(true);
+ tester2->setPos(30, 30);
+ scene.addItem(tester1);
+ scene.addItem(tester2);
+
+ tester1->eventTypes.clear();
+ tester2->eventTypes.clear();
+
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
+ me.setButton(Qt::LeftButton);
+ me.setButtons(Qt::LeftButton);
+ QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease);
+ me2.setButton(Qt::LeftButton);
+ qApp->sendEvent(&scene, &me);
+ qApp->sendEvent(&scene, &me2);
+ QCOMPARE(tester1->eventTypes, QList<QEvent::Type>()
+ << QEvent::GraphicsSceneHoverEnter
+ << QEvent::GraphicsSceneHoverMove
+ << QEvent::GrabMouse
+ << QEvent::GraphicsSceneMousePress
+ << QEvent::UngrabMouse);
+ tester1->eventTypes.clear();
+ qApp->sendEvent(&scene, &me);
+ qApp->sendEvent(&scene, &me2);
+ QCOMPARE(tester1->eventTypes, QList<QEvent::Type>()
+ << QEvent::GraphicsSceneHoverMove
+ << QEvent::GrabMouse
+ << QEvent::GraphicsSceneMousePress
+ << QEvent::UngrabMouse);
+ }
+ {
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMousePress);
+ me.setScenePos(QPointF(30, 30));
+ me.setButton(Qt::LeftButton);
+ me.setButtons(Qt::LeftButton);
+ QGraphicsSceneMouseEvent me2(QEvent::GraphicsSceneMouseRelease);
+ me2.setScenePos(QPointF(30, 30));
+ me2.setButton(Qt::LeftButton);
+ tester1->eventTypes.clear();
+ qApp->sendEvent(&scene, &me);
+ qApp->sendEvent(&scene, &me2);
+ qDebug() << tester1->eventTypes;
+ QCOMPARE(tester1->eventTypes, QList<QEvent::Type>()
+ << QEvent::GraphicsSceneHoverLeave);
+ QCOMPARE(tester2->eventTypes, QList<QEvent::Type>()
+ << QEvent::GraphicsSceneHoverEnter
+ << QEvent::GraphicsSceneHoverMove
+ << QEvent::GrabMouse
+ << QEvent::GraphicsSceneMousePress
+ << QEvent::UngrabMouse);
+ tester2->eventTypes.clear();
+ qApp->sendEvent(&scene, &me);
+ qApp->sendEvent(&scene, &me2);
+ QCOMPARE(tester2->eventTypes, QList<QEvent::Type>()
+ << QEvent::GraphicsSceneHoverMove
+ << QEvent::GrabMouse
+ << QEvent::GraphicsSceneMousePress
+ << QEvent::UngrabMouse);
+ }
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"
diff --git a/tests/auto/qgraphicstransform/qgraphicstransform.pro b/tests/auto/qgraphicstransform/qgraphicstransform.pro
new file mode 100644
index 0000000..709cff6
--- /dev/null
+++ b/tests/auto/qgraphicstransform/qgraphicstransform.pro
@@ -0,0 +1,2 @@
+load(qttest_p4)
+SOURCES += tst_qgraphicstransform.cpp
diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
new file mode 100644
index 0000000..672b1f1
--- /dev/null
+++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite 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 http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <qgraphicsitem.h>
+#include <qgraphicstransform.h>
+#include "../../shared/util.h"
+
+class tst_QGraphicsTransform : public QObject {
+ Q_OBJECT
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+
+private slots:
+ void scale();
+ void rotation();
+ void rotation3d();
+};
+
+
+// This will be called before the first test function is executed.
+// It is only called once.
+void tst_QGraphicsTransform::initTestCase()
+{
+}
+
+// This will be called after the last test function is executed.
+// It is only called once.
+void tst_QGraphicsTransform::cleanupTestCase()
+{
+}
+
+// This will be called before each test function is executed.
+void tst_QGraphicsTransform::init()
+{
+}
+
+// This will be called after every test function.
+void tst_QGraphicsTransform::cleanup()
+{
+}
+
+
+void tst_QGraphicsTransform::scale()
+{
+ QGraphicsScale scale;
+ scale.setOrigin(QPointF(10, 10));
+
+ QTransform t;
+ scale.applyTo(&t);
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(scale.transform(), QTransform());
+
+ scale.setXScale(10);
+ scale.setOrigin(QPointF(0, 0));
+
+ QTransform res;
+ res.scale(10, 1);
+
+ QCOMPARE(scale.transform(), res);
+ QCOMPARE(scale.transform().map(QPointF(10, 10)), QPointF(100, 10));
+
+ scale.setOrigin(QPointF(10, 10));
+ QCOMPARE(scale.transform().map(QPointF(10, 10)), QPointF(10, 10));
+ QCOMPARE(scale.transform().map(QPointF(11, 10)), QPointF(20, 10));
+}
+
+void tst_QGraphicsTransform::rotation()
+{
+ QGraphicsRotation rotation;
+ rotation.setOrigin(QPointF(10, 10));
+
+ QTransform t;
+ rotation.applyTo(&t);
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(rotation.transform(), QTransform());
+
+ rotation.setAngle(40);
+ rotation.setOrigin(QPointF(0, 0));
+
+ QTransform res;
+ res.rotate(40);
+
+ QCOMPARE(rotation.transform(), res);
+
+ rotation.setOrigin(QPointF(10, 10));
+ rotation.setAngle(90);
+ QCOMPARE(rotation.transform().map(QPointF(10, 10)), QPointF(10, 10));
+ QCOMPARE(rotation.transform().map(QPointF(20, 10)), QPointF(10, 20));
+}
+
+void tst_QGraphicsTransform::rotation3d()
+{
+ QGraphicsRotation3D rotation;
+ rotation.setOrigin(QPointF(10, 10));
+
+ QTransform t;
+ rotation.applyTo(&t);
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(rotation.transform(), QTransform());
+
+ rotation.setAngle(180);
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(rotation.transform(), QTransform());
+
+ rotation.setOrigin(QPointF(0, 0));
+
+ QCOMPARE(t, QTransform());
+ QCOMPARE(rotation.transform(), QTransform());
+}
+
+
+QTEST_MAIN(tst_QGraphicsTransform)
+#include "tst_qgraphicstransform.moc"
+
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 78d13d3..2cfedb1 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -1315,6 +1315,12 @@ void tst_QGraphicsWidget::focusNextPrevChild()
void tst_QGraphicsWidget::verifyFocusChain()
{
QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
{
// parent/child focus
SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window);
@@ -1448,6 +1454,11 @@ void tst_QGraphicsWidget::updateFocusChainWhenChildDie()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
+
// delete item in focus chain with no focus and verify chain
SubQGraphicsWidget *parent = new SubQGraphicsWidget(0, Qt::Window);
SubQGraphicsWidget *w = new SubQGraphicsWidget(0, Qt::Window);
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index 9c8c313..8253541 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -335,7 +335,7 @@ public:
if(table2.compare(table.section('.', -1, -1), Qt::CaseInsensitive) == 0) {
table=db.driver()->escapeIdentifier(table2, QSqlDriver::TableName);
wasDropped = q.exec( "drop table " + table);
- dbtables.removeAll(table);
+ dbtables.removeAll(table2);
}
}
}
@@ -430,8 +430,8 @@ public:
return "IDENTITY";
/* if ( db.driverName().startsWith( "QPSQL" ) )
return "SERIAL";*/
- if ( db.driverName().startsWith( "QDB2" ) )
- return "GENERATED BY DEFAULT AS IDENTITY";
+// if ( db.driverName().startsWith( "QDB2" ) )
+// return "GENERATED BY DEFAULT AS IDENTITY";
return QString();
}
@@ -483,6 +483,10 @@ public:
{
return db.driverName().startsWith("QMYSQL") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("MySQL") );
}
+ static bool isDB2( QSqlDatabase db )
+ {
+ return db.driverName().startsWith("QDB2") || (db.driverName().startsWith("QODBC") && db.databaseName().contains("db2") );
+ }
// -1 on fail, else Oracle version
static int getOraVersion( QSqlDatabase db )
diff --git a/tests/auto/qxml/tst_qxml.cpp b/tests/auto/qxml/tst_qxml.cpp
index 13de82f..1bc5ef5 100644
--- a/tests/auto/qxml/tst_qxml.cpp
+++ b/tests/auto/qxml/tst_qxml.cpp
@@ -57,6 +57,7 @@ Q_OBJECT
private slots:
void getSetCheck();
void interpretedAs0D() const;
+ void exception();
};
class MyXmlEntityResolver : public QXmlEntityResolver
@@ -213,5 +214,30 @@ void tst_QXml::interpretedAs0D() const
QCOMPARE(myHandler.attrName, QChar(0x010D) + QString::fromLatin1("reated-by"));
}
+void tst_QXml::exception()
+{
+#ifndef QT_NO_EXCEPTIONS
+ QString message = QString::fromLatin1("message");
+ int column = 3;
+ int line = 2;
+ QString publicId = QString::fromLatin1("publicId");
+ QString systemId = QString::fromLatin1("systemId");
+
+ try {
+ QXmlParseException e(message, column, line, publicId, systemId);
+ throw e;
+ }
+ catch (QXmlParseException e) {
+ QCOMPARE(e.message(), message);
+ QCOMPARE(e.columnNumber(), column);
+ QCOMPARE(e.lineNumber(), line);
+ QCOMPARE(e.publicId(), publicId);
+ QCOMPARE(e.systemId(), systemId);
+ }
+#else
+ QSKIP("Exceptions not available", SkipAll);
+#endif
+}
+
QTEST_MAIN(tst_QXml)
#include "tst_qxml.moc"
diff --git a/tests/auto/selftests/cmptest/tst_cmptest.cpp b/tests/auto/selftests/cmptest/tst_cmptest.cpp
index 59dd678..7395210 100644
--- a/tests/auto/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/selftests/cmptest/tst_cmptest.cpp
@@ -50,6 +50,8 @@ class tst_Cmptest: public QObject
private slots:
void compare_boolfuncs();
void compare_pointerfuncs();
+ void compare_tostring();
+ void compare_tostring_data();
};
static bool boolfunc() { return true; }
@@ -76,6 +78,50 @@ void tst_Cmptest::compare_pointerfuncs()
QCOMPARE(&i, intptr());
}
+Q_DECLARE_METATYPE(QVariant)
+
+class PhonyClass
+{};
+
+void tst_Cmptest::compare_tostring_data()
+{
+ QTest::addColumn<QVariant>("actual");
+ QTest::addColumn<QVariant>("expected");
+
+ QTest::newRow("int, string")
+ << QVariant::fromValue(123)
+ << QVariant::fromValue(QString("hi"))
+ ;
+
+ QTest::newRow("both invalid")
+ << QVariant()
+ << QVariant()
+ ;
+
+ QTest::newRow("null hash, invalid")
+ << QVariant(QVariant::Hash)
+ << QVariant()
+ ;
+
+ QTest::newRow("string, null user type")
+ << QVariant::fromValue(QString::fromLatin1("A simple string"))
+ << QVariant(QVariant::Type(qRegisterMetaType<PhonyClass>("PhonyClass")))
+ ;
+
+ QTest::newRow("both non-null user type")
+ << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0)
+ << QVariant(qRegisterMetaType<PhonyClass>("PhonyClass"), (const void*)0)
+ ;
+}
+
+void tst_Cmptest::compare_tostring()
+{
+ QFETCH(QVariant, actual);
+ QFETCH(QVariant, expected);
+
+ QCOMPARE(actual, expected);
+}
+
QTEST_MAIN(tst_Cmptest)
#include "tst_cmptest.moc"
diff --git a/tests/auto/selftests/expected_cmptest.txt b/tests/auto/selftests/expected_cmptest.txt
index dc89d9d..f70eba5 100644
--- a/tests/auto/selftests/expected_cmptest.txt
+++ b/tests/auto/selftests/expected_cmptest.txt
@@ -1,8 +1,24 @@
********* Start testing of tst_Cmptest *********
-Config: Using QTest library 4.1.0, Qt 4.1.0
+Config: Using QTest library 4.6.0, Qt 4.6.0
PASS : tst_Cmptest::initTestCase()
PASS : tst_Cmptest::compare_boolfuncs()
PASS : tst_Cmptest::compare_pointerfuncs()
+FAIL! : tst_Cmptest::compare_tostring(int, string) Compared values are not the same
+ Actual (actual): QVariant(int,123)
+ Expected (expected): QVariant(QString,hi)
+ Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)]
+FAIL! : tst_Cmptest::compare_tostring(null hash, invalid) Compared values are not the same
+ Actual (actual): QVariant(QVariantHash)
+ Expected (expected): QVariant()
+ Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)]
+FAIL! : tst_Cmptest::compare_tostring(string, null user type) Compared values are not the same
+ Actual (actual): QVariant(QString,A simple string)
+ Expected (expected): QVariant(PhonyClass)
+ Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)]
+FAIL! : tst_Cmptest::compare_tostring(both non-null user type) Compared values are not the same
+ Actual (actual): QVariant(PhonyClass,<value not representable as string>)
+ Expected (expected): QVariant(PhonyClass,<value not representable as string>)
+ Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/cmptest/tst_cmptest.cpp(122)]
PASS : tst_Cmptest::cleanupTestCase()
-Totals: 4 passed, 0 failed, 0 skipped
+Totals: 4 passed, 4 failed, 0 skipped
********* Finished testing of tst_Cmptest *********