diff options
55 files changed, 270 insertions, 117 deletions
diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp index 21998dc2df..86da5b138f 100644 --- a/examples/widgets/graphicsview/chip/view.cpp +++ b/examples/widgets/graphicsview/chip/view.cpp @@ -234,11 +234,11 @@ void View::setupMatrix() { qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); - QMatrix matrix; + QTransform matrix; matrix.scale(scale, scale); matrix.rotate(rotateSlider->value()); - graphicsView->setMatrix(matrix); + graphicsView->setTransform(matrix); setResetButtonEnabled(); } diff --git a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp index 3327d4d5df..04ff42e3eb 100644 --- a/examples/widgets/graphicsview/diagramscene/mainwindow.cpp +++ b/examples/widgets/graphicsview/diagramscene/mainwindow.cpp @@ -231,8 +231,8 @@ void MainWindow::fontSizeChanged(const QString &) void MainWindow::sceneScaleChanged(const QString &scale) { double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0; - QMatrix oldMatrix = view->matrix(); - view->resetMatrix(); + QTransform oldMatrix = view->transform(); + view->resetTransform(); view->translate(oldMatrix.dx(), oldMatrix.dy()); view->scale(newScale, newScale); } diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index 50acf0f814..4e7cb91ce1 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -223,7 +223,7 @@ void XFormView::setRotation(qreal r) m_rotation = r; QPointF center(pts->points().at(0)); - QMatrix m; + QTransform m; m.translate(center.x(), center.y()); m.rotate(m_rotation - old_rot); m.translate(-center.x(), -center.y()); @@ -236,7 +236,7 @@ void XFormView::timerEvent(QTimerEvent *e) { if (e->timerId() == timer.timerId()) { QPointF center(pts->points().at(0)); - QMatrix m; + QTransform m; m.translate(center.x(), center.y()); m.rotate(0.2); m.translate(-center.x(), -center.y()); diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp index d5c8746247..961d5e5e99 100644 --- a/examples/widgets/painting/deform/pathdeform.cpp +++ b/examples/widgets/painting/deform/pathdeform.cpp @@ -374,7 +374,7 @@ void PathDeformRenderer::setText(const QString &text) } for (int i=0; i<m_paths.size(); ++i) - m_paths[i] = m_paths[i] * QMatrix(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y()); + m_paths[i] = m_paths[i] * QTransform(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y()); update(); } diff --git a/examples/widgets/painting/pathstroke/pathstroke.cpp b/examples/widgets/painting/pathstroke/pathstroke.cpp index a850ce2672..7dab6f95a2 100644 --- a/examples/widgets/painting/pathstroke/pathstroke.cpp +++ b/examples/widgets/painting/pathstroke/pathstroke.cpp @@ -511,10 +511,10 @@ void PathStrokeRenderer::initializePoints() m_points.clear(); m_vectors.clear(); - QMatrix m; + QTransform m; qreal rot = 360.0 / count; QPointF center(width() / 2, height() / 2); - QMatrix vm; + QTransform vm; vm.shear(2, -1); vm.scale(3, 3); diff --git a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp index 37fae52778..d1ee6bbdea 100644 --- a/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp +++ b/src/gui/doc/snippets/code/src_gui_painting_qpainter.cpp @@ -93,9 +93,9 @@ painter2->begin(myWidget); // impossible - only one painter at a time //! [4] void QPainter::rotate(qreal angle) { - QMatrix matrix; + QTransform matrix; matrix.rotate(angle); - setWorldMatrix(matrix, true); + setWorldTransform(matrix, true); } //! [4] diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 1166eb5023..267faa7753 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2881,7 +2881,13 @@ QImage QImage::scaledToHeight(int h, Qt::TransformationMode mode) const } +#if QT_DEPRECATED_SINCE(5, 15) + /*! + \obsolete + + Use trueMatrix(const QTransform &matrix, int w, int h) instead. + \fn QMatrix QImage::trueMatrix(const QMatrix &matrix, int width, int height) Returns the actual matrix used for transforming an image with the @@ -2903,6 +2909,10 @@ QMatrix QImage::trueMatrix(const QMatrix &matrix, int w, int h) } /*! + \obsolete + + Use transformed(const QTransform &matrix, Qt::TransformationMode mode) instead. + Returns a copy of the image that is transformed using the given transformation \a matrix and transformation \a mode. @@ -2927,6 +2937,8 @@ QImage QImage::transformed(const QMatrix &matrix, Qt::TransformationMode mode) c return transformed(QTransform(matrix), mode); } +#endif // QT_DEPRECATED_SINCE(5, 15) + /*! Builds and returns a 1-bpp mask from the alpha buffer in this image. Returns a null image if the image's format is diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 115071c16e..7b2abfaf85 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -282,8 +282,12 @@ public: Qt::TransformationMode mode = Qt::FastTransformation) const; QImage scaledToWidth(int w, Qt::TransformationMode mode = Qt::FastTransformation) const; QImage scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transformed(const QTransform &matrix, Qt::TransformationMode mode)") QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const; + QT_DEPRECATED_X("trueMatrix(const QTransform &, int w, int h)") static QMatrix trueMatrix(const QMatrix &, int w, int h); +#endif // QT_DEPRECATED_SINCE(5, 15) QImage transformed(const QTransform &matrix, Qt::TransformationMode mode = Qt::FastTransformation) const; static QTransform trueMatrix(const QTransform &, int w, int h); #if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index adadba2057..269f236ecd 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -438,7 +438,7 @@ QImage QPixmap::toImage() const } /*! - \fn QMatrix QPixmap::trueMatrix(const QTransform &matrix, int width, int height) + \fn QTransform QPixmap::trueMatrix(const QTransform &matrix, int width, int height) Returns the actual matrix used for transforming a pixmap with the given \a width, \a height and \a matrix. @@ -458,8 +458,12 @@ QTransform QPixmap::trueMatrix(const QTransform &m, int w, int h) return QImage::trueMatrix(m, w, h); } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete + + Use trueMatrix(const QTransform &m, int w, int h) instead. This convenience function loads the matrix \a m into a QTransform and calls the overloaded function with the @@ -469,6 +473,7 @@ QMatrix QPixmap::trueMatrix(const QMatrix &m, int w, int h) { return trueMatrix(QTransform(m), w, h).toAffine(); } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! @@ -1233,8 +1238,12 @@ QPixmap QPixmap::transformed(const QTransform &transform, return data->transformed(transform, mode); } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete + + Use transformed(const QTransform &transform, Qt::TransformationMode mode)() instead. This convenience function loads the \a matrix into a QTransform and calls the overloaded function. @@ -1243,6 +1252,7 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) { return transformed(QTransform(matrix), mode); } +#endif // QT_DEPRECATED_SINCE(5, 15) diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 8a06ebe603..e47a9fe59e 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -129,8 +129,12 @@ public: Qt::TransformationMode mode = Qt::FastTransformation) const; QPixmap scaledToWidth(int w, Qt::TransformationMode mode = Qt::FastTransformation) const; QPixmap scaledToHeight(int h, Qt::TransformationMode mode = Qt::FastTransformation) const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transformed(const QTransform &, Qt::TransformationMode mode)") QPixmap transformed(const QMatrix &, Qt::TransformationMode mode = Qt::FastTransformation) const; + QT_DEPRECATED_X("Use trueMatrix(const QTransform &m, int w, int h)") static QMatrix trueMatrix(const QMatrix &m, int w, int h); +#endif // QT_DEPRECATED_SINCE(5, 15) QPixmap transformed(const QTransform &, Qt::TransformationMode mode = Qt::FastTransformation) const; static QTransform trueMatrix(const QTransform &m, int w, int h); diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index 215b2b1d74..c9c45ba815 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -47,7 +47,6 @@ #include "qimage.h" #include "qkeysequence.h" #include "qtransform.h" -#include "qmatrix.h" #include "qpalette.h" #include "qpen.h" #include "qpixmap.h" diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 6666eb037f..cdaed788e9 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -187,7 +187,10 @@ QMatrix4x4::QMatrix4x4(const float *values, int cols, int rows) flagBits = General; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \obsolete + Constructs a 4x4 matrix from a conventional Qt 2D affine transformation \a matrix. @@ -218,6 +221,7 @@ QMatrix4x4::QMatrix4x4(const QMatrix& matrix) m[3][3] = 1.0f; flagBits = Translation | Scale | Rotation2D; } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! Constructs a 4x4 matrix from the conventional Qt 2D @@ -1659,7 +1663,12 @@ void QMatrix4x4::copyDataTo(float *values) const values[row * 4 + col] = float(m[col][row]); } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \obsolete + + Use toTransform() instead. + Returns the conventional Qt 2D affine transformation matrix that corresponds to this matrix. It is assumed that this matrix only contains 2D affine transformation elements. @@ -1672,6 +1681,7 @@ QMatrix QMatrix4x4::toAffine() const m[1][0], m[1][1], m[3][0], m[3][1]); } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! Returns the conventional Qt 2D transformation matrix that diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 1439bfac59..6a726a197c 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -72,7 +72,9 @@ public: QMatrix4x4(const float *values, int cols, int rows); QMatrix4x4(const QTransform& transform); +#if QT_DEPRECATED_SINCE(5, 15) QMatrix4x4(const QMatrix& matrix); +#endif // QT_DEPRECATED_SINCE(5, 15) inline const float& operator()(int row, int column) const; inline float& operator()(int row, int column); @@ -156,7 +158,9 @@ public: void copyDataTo(float *values) const; - QMatrix toAffine() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use toTransform()") QMatrix toAffine() const; +#endif // QT_DEPRECATED_SINCE(5, 15) QTransform toTransform() const; QTransform toTransform(float distanceToPlane) const; diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index e84916e063..28cc20bfc5 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -893,8 +893,12 @@ bool QBrush::isOpaque() const } +#if QT_DEPRECATED_SINCE(5, 15) /*! \since 4.2 + \obsolete + + Use setTransform() instead. Sets \a matrix as an explicit transformation matrix on the current brush. The brush transformation matrix is merged with @@ -906,6 +910,7 @@ void QBrush::setMatrix(const QMatrix &matrix) { setTransform(QTransform(matrix)); } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! \since 4.3 @@ -923,14 +928,19 @@ void QBrush::setTransform(const QTransform &matrix) } +#if QT_DEPRECATED_SINCE(5, 15) /*! \fn void QBrush::matrix() const \since 4.2 + \obsolete + + Use transform() instead. Returns the current transformation matrix for the brush. \sa setMatrix() */ +#endif // QT_DEPRECATED_SINCE(5, 15) /*! \fn bool QBrush::operator!=(const QBrush &brush) const diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h index 1d7199782f..3a01248c57 100644 --- a/src/gui/painting/qbrush.h +++ b/src/gui/painting/qbrush.h @@ -89,8 +89,10 @@ public: inline Qt::BrushStyle style() const; void setStyle(Qt::BrushStyle); - inline const QMatrix &matrix() const; - void setMatrix(const QMatrix &mat); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transform()") inline const QMatrix &matrix() const; + QT_DEPRECATED_X("Use setTransform()") void setMatrix(const QMatrix &mat); +#endif // QT_DEPRECATED_SINCE(5, 15) inline QTransform transform() const; void setTransform(const QTransform &); @@ -157,7 +159,10 @@ struct QBrushData inline Qt::BrushStyle QBrush::style() const { return d->style; } inline const QColor &QBrush::color() const { return d->color; } +#if QT_DEPRECATED_SINCE(5, 15) +QT_DEPRECATED_X("Use transform()") inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); } +#endif // QT_DEPRECATED_SINCE(5, 15) inline QTransform QBrush::transform() const { return d->transform; } inline bool QBrush::isDetached() const { return d->ref.loadRelaxed() == 1; } diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp index 890b0079de..7ebd2dbd09 100644 --- a/src/gui/painting/qmatrix.cpp +++ b/src/gui/painting/qmatrix.cpp @@ -45,6 +45,7 @@ #include "qregion.h" #include "qpainterpath.h" #include "qpainterpath_p.h" +#include "qtransform.h" #include "qvariant.h" #include <qmath.h> @@ -680,7 +681,7 @@ QRegion QMatrix::map(const QRegion &r) const } QPainterPath p = map(qt_regionToPath(r)); - return p.toFillPolygon().toPolygon(); + return p.toFillPolygon(QTransform()).toPolygon(); } /*! diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp index 1785fcd12d..315bf0daf2 100644 --- a/src/gui/painting/qpaintengine.cpp +++ b/src/gui/painting/qpaintengine.cpp @@ -508,7 +508,7 @@ void QPaintEngine::drawEllipse(const QRectF &rect) if (hasFeature(PainterPaths)) { drawPath(path); } else { - QPolygonF polygon = path.toFillPolygon(); + QPolygonF polygon = path.toFillPolygon(QTransform()); drawPolygon(polygon.data(), polygon.size(), ConvexMode); } } diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 9fb67e253e..e90020dbbf 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -273,7 +273,9 @@ public: QBrush backgroundBrush() const; Qt::BGMode backgroundMode() const; QFont font() const; - QMatrix matrix() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transform()") QMatrix matrix() const; +#endif // QT_DEPRECATED_SINCE(5, 15) QTransform transform() const; Qt::ClipOperation clipOperation() const; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index b0553a1ff9..390147463d 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2555,19 +2555,19 @@ QRegion QPainter::clipRegion() const case QPainterClipInfo::PathClip: { QTransform matrix = (info.matrix * d->invMatrix); if (lastWasNothing) { - region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), + region = QRegion((info.path * matrix).toFillPolygon(QTransform()).toPolygon(), info.path.fillRule()); lastWasNothing = false; continue; } if (info.operation == Qt::IntersectClip) { - region &= QRegion((info.path * matrix).toFillPolygon().toPolygon(), + region &= QRegion((info.path * matrix).toFillPolygon(QTransform()).toPolygon(), info.path.fillRule()); } else if (info.operation == Qt::NoClip) { lastWasNothing = true; region = QRegion(); } else { - region = QRegion((info.path * matrix).toFillPolygon().toPolygon(), + region = QRegion((info.path * matrix).toFillPolygon(QTransform()).toPolygon(), info.path.fillRule()); } break; @@ -8089,6 +8089,8 @@ QFont QPaintEngineState::font() const \since 4.2 \obsolete + Use transform() instead. + Returns the matrix in the current paint engine state. diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 3394da63c7..77c6504d2e 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -72,7 +72,6 @@ class QPen; class QPolygon; class QTextItem; class QTextEngine; -class QMatrix; class QTransform; class QStaticText; class QGlyphRun; diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 285bd90502..dafd6e33be 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -59,7 +59,6 @@ #include "QtGui/qfont.h" #include "QtGui/qpen.h" #include "QtGui/qregion.h" -#include "QtGui/qmatrix.h" #include "QtGui/qpainter.h" #include "QtGui/qpainterpath.h" #include "QtGui/qpaintengine.h" diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 17d8b863ab..ab60afd9cd 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1660,13 +1660,18 @@ QList<QPolygonF> QPainterPath::toSubpathPolygons(const QTransform &matrix) const return flatCurves; } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete + + Use toSubpathPolygons(const QTransform &matrix) instead. */ QList<QPolygonF> QPainterPath::toSubpathPolygons(const QMatrix &matrix) const { return toSubpathPolygons(QTransform(matrix)); } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! Converts the path into a list of polygons using the @@ -1787,13 +1792,18 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const return polys; } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete + + Use toFillPolygons(const QTransform &matrix) instead. */ QList<QPolygonF> QPainterPath::toFillPolygons(const QMatrix &matrix) const { return toFillPolygons(QTransform(matrix)); } +#endif // QT_DEPRECATED_SINCE(5, 15) //same as qt_polygon_isect_line in qpolygon.cpp static void qt_painterpath_isect_line(const QPointF &p1, @@ -2904,14 +2914,18 @@ QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix) const return polygon; } +#if QT_DEPRECATED_SINCE(5, 15) /*! \overload + \obsolete + + Use toFillPolygon(const QTransform &matrix) instead. */ QPolygonF QPainterPath::toFillPolygon(const QMatrix &matrix) const { return toFillPolygon(QTransform(matrix)); } - +#endif // QT_DEPRECATED_SINCE(5, 15) //derivative of the equation static inline qreal slopeAt(qreal t, qreal a, qreal b, qreal c, qreal d) diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index ed5be667b7..26b92dc6fa 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -175,9 +175,15 @@ public: bool isEmpty() const; Q_REQUIRED_RESULT QPainterPath toReversed() const; + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use toSubpathPolygons(const QTransform &)") QList<QPolygonF> toSubpathPolygons(const QMatrix &matrix = QMatrix()) const; + QT_DEPRECATED_X("Use toFillPolygons(const QTransform &") QList<QPolygonF> toFillPolygons(const QMatrix &matrix = QMatrix()) const; + QT_DEPRECATED_X("Use toFillPolygon(const QTransform &)") QPolygonF toFillPolygon(const QMatrix &matrix = QMatrix()) const; +#endif // QT_DEPRECATED_SINCE(5, 15) QList<QPolygonF> toSubpathPolygons(const QTransform &matrix) const; QList<QPolygonF> toFillPolygons(const QTransform &matrix) const; QPolygonF toFillPolygon(const QTransform &matrix) const; diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 57d70db442..4ff540e67b 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -55,7 +55,6 @@ #ifndef QT_NO_PDF -#include "QtGui/qmatrix.h" #include "QtCore/qstring.h" #include "QtCore/qvector.h" #include "private/qstroker_p.h" diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp index 20337477b7..4fe819cae0 100644 --- a/src/gui/painting/qpolygon.cpp +++ b/src/gui/painting/qpolygon.cpp @@ -40,9 +40,9 @@ #include "qpolygon.h" #include "qrect.h" #include "qdatastream.h" -#include "qmatrix.h" #include "qdebug.h" #include "qpainterpath.h" +#include "qtransform.h" #include "qvariant.h" #include "qpainterpath_p.h" #include "qbezier_p.h" @@ -111,7 +111,7 @@ static void qt_polygon_isect_line(const QPointF &p1, const QPointF &p2, const QP from a specified index (resizing the polygon if necessary). QPolygon provides the boundingRect() and translate() functions for - geometry functions. Use the QMatrix::map() function for more + geometry functions. Use the QTransform::map() function for more general transformations of QPolygons. The QPolygon class is \l {Implicit Data Sharing}{implicitly @@ -495,7 +495,7 @@ QDebug operator<<(QDebug dbg, const QPolygon &a) In addition to the functions provided by QVector, QPolygonF provides the boundingRect() and translate() functions for geometry - operations. Use the QMatrix::map() function for more general + operations. Use the QTransform::map() function for more general transformations of QPolygonFs. QPolygonF also provides the isClosed() function to determine @@ -899,7 +899,7 @@ QPolygon QPolygon::united(const QPolygon &r) const QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.united(clip).toFillPolygon().toPolygon(); + return subject.united(clip).toFillPolygon(QTransform()).toPolygon(); } /*! @@ -918,7 +918,7 @@ QPolygon QPolygon::intersected(const QPolygon &r) const QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.intersected(clip).toFillPolygon().toPolygon(); + return subject.intersected(clip).toFillPolygon(QTransform()).toPolygon(); } /*! @@ -936,7 +936,7 @@ QPolygon QPolygon::subtracted(const QPolygon &r) const QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.subtracted(clip).toFillPolygon().toPolygon(); + return subject.subtracted(clip).toFillPolygon(QTransform()).toPolygon(); } /*! @@ -975,7 +975,7 @@ QPolygonF QPolygonF::united(const QPolygonF &r) const QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.united(clip).toFillPolygon(); + return subject.united(clip).toFillPolygon(QTransform()); } /*! @@ -994,7 +994,7 @@ QPolygonF QPolygonF::intersected(const QPolygonF &r) const QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.intersected(clip).toFillPolygon(); + return subject.intersected(clip).toFillPolygon(QTransform()); } /*! @@ -1011,7 +1011,7 @@ QPolygonF QPolygonF::subtracted(const QPolygonF &r) const { QPainterPath subject; subject.addPolygon(*this); QPainterPath clip; clip.addPolygon(r); - return subject.subtracted(clip).toFillPolygon(); + return subject.subtracted(clip).toFillPolygon(QTransform()); } /*! diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index 44ee038194..bac042c784 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -46,6 +46,7 @@ #include "qvarlengtharray.h" #include "qimage.h" #include "qbitmap.h" +#include "qtransform.h" #include <private/qdebug_p.h> @@ -3916,7 +3917,7 @@ QRegion::QRegion(const QRect &r, RegionType t) } else if (t == Ellipse) { QPainterPath path; path.addEllipse(r.x(), r.y(), r.width(), r.height()); - QPolygon a = path.toSubpathPolygons().at(0).toPolygon(); + QPolygon a = path.toSubpathPolygons(QTransform()).at(0).toPolygon(); d->qt_rgn = PolygonRegion(a.constData(), a.size(), EvenOddRule); } } diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 279a817ff1..9d8bb0c3e2 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -311,8 +311,10 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h21, { } +#if QT_DEPRECATED_SINCE(5, 15) /*! \fn QTransform::QTransform(const QMatrix &matrix) + \obsolete Constructs a matrix that is a copy of the given \a matrix. Note that the \c m13, \c m23, and \c m33 elements are set to 0, 0, @@ -328,6 +330,7 @@ QTransform::QTransform(const QMatrix &mtx) #endif { } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! Returns the adjoint of this matrix. @@ -2082,7 +2085,9 @@ void QTransform::map(int x, int y, int *tx, int *ty) const *ty = qRound(fy); } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \obsolete Returns the QTransform as an affine matrix. \warning If a perspective transformation has been specified, @@ -2092,6 +2097,7 @@ const QMatrix &QTransform::toAffine() const { return affine; } +#endif // QT_DEPRECATED_SINCE(5, 15) /*! Returns the transformation type of this matrix. diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h index b2a634dd2a..485caa5140 100644 --- a/src/gui/painting/qtransform.h +++ b/src/gui/painting/qtransform.h @@ -73,7 +73,9 @@ public: qreal h31, qreal h32, qreal h33 = 1.0); QTransform(qreal h11, qreal h12, qreal h21, qreal h22, qreal dx, qreal dy); +#if QT_DEPRECATED_SINCE(5, 15) explicit QTransform(const QMatrix &mtx); +#endif // QT_DEPRECATED_SINCE(5, 15) #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove; the compiler-generated ones are fine! @@ -158,7 +160,9 @@ public: void map(int x, int y, int *tx, int *ty) const; void map(qreal x, qreal y, qreal *tx, qreal *ty) const; +#if QT_DEPRECATED_SINCE(5, 15) const QMatrix &toAffine() const; +#endif // QT_DEPRECATED_SINCE(5, 15) QTransform &operator*=(qreal div); QTransform &operator/=(qreal div); diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp index 899e7f7c17..9ae8bd6c90 100644 --- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp @@ -1025,7 +1025,7 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa imgCopy = cachedPixmap.toImage(); if (themeData.rotate) { - QMatrix rotMatrix; + QTransform rotMatrix; rotMatrix.rotate(themeData.rotate); imgCopy = imgCopy.transformed(rotMatrix); } diff --git a/src/printsupport/kernel/qprintengine_pdf_p.h b/src/printsupport/kernel/qprintengine_pdf_p.h index e7ae21f260..c8d8f8e866 100644 --- a/src/printsupport/kernel/qprintengine_pdf_p.h +++ b/src/printsupport/kernel/qprintengine_pdf_p.h @@ -55,7 +55,6 @@ #ifndef QT_NO_PRINTER #include "QtCore/qmap.h" -#include "QtGui/qmatrix.h" #include "QtCore/qstring.h" #include "QtCore/qvector.h" #include "QtGui/qpaintengine.h" diff --git a/src/printsupport/widgets/qprintpreviewwidget.cpp b/src/printsupport/widgets/qprintpreviewwidget.cpp index 92370be2bd..16b84e328d 100644 --- a/src/printsupport/widgets/qprintpreviewwidget.cpp +++ b/src/printsupport/widgets/qprintpreviewwidget.cpp @@ -264,7 +264,7 @@ void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting) } else { graphicsView->fitInView(target, Qt::KeepAspectRatio); if (zoomMode == QPrintPreviewWidget::FitInView) { - int step = qRound(graphicsView->matrix().mapRect(target).height()); + const int step = qRound(graphicsView->transform().mapRect(target).height()); graphicsView->verticalScrollBar()->setSingleStep(step); graphicsView->verticalScrollBar()->setPageStep(step); } diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp index 3d1b1e0030..ca6866376b 100644 --- a/src/widgets/doc/snippets/javastyle.cpp +++ b/src/widgets/doc/snippets/javastyle.cpp @@ -380,10 +380,10 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option, QRect rect = bar->rect; if (bar->orientation == Qt::Vertical) { rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); - QMatrix m; + QTransform m; m.translate(rect.height()-1, 0); m.rotate(90.0); - painter->setMatrix(m); + painter->setTransform(m); } painter->setPen(bar->palette.color(QPalette::Mid)); diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 1cb24f74b6..bbcceb1ce6 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -231,7 +231,6 @@ #include <QtWidgets/qgraphicslayout.h> #include <QtWidgets/qgraphicsproxywidget.h> #include <QtWidgets/qgraphicswidget.h> -#include <QtGui/qmatrix.h> #include <QtGui/qpaintengine.h> #include <QtGui/qpainter.h> #include <QtGui/qpixmapcache.h> diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index d36a871533..3ba9bddc32 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -47,7 +47,6 @@ #include <QtGui/qbrush.h> #include <QtGui/qfont.h> #include <QtGui/qtransform.h> -#include <QtGui/qmatrix.h> #include <QtGui/qpen.h> QT_REQUIRE_CONFIG(graphicsview); diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 102f3e894f..686b41960a 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -1795,7 +1795,13 @@ void QGraphicsView::setSceneRect(const QRectF &rect) d->recalculateContentSize(); } +#if QT_DEPRECATED_SINCE(5, 15) + /*! + \obsolete + + Use transform() instead. + Returns the current transformation matrix for the view. If no current transformation is set, the identity matrix is returned. @@ -1808,6 +1814,10 @@ QMatrix QGraphicsView::matrix() const } /*! + \obsolete + + Use setTransform() instead. + Sets the view's current transformation matrix to \a matrix. If \a combine is true, then \a matrix is combined with the current matrix; @@ -1839,6 +1849,10 @@ void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine) } /*! + \obsolete + + Use resetTransform() instead. + Resets the view transformation matrix to the identity matrix. \sa resetTransform() @@ -1848,6 +1862,8 @@ void QGraphicsView::resetMatrix() resetTransform(); } +#endif // QT_DEPRECATED_SINCE(5, 15) + /*! Rotates the current view transformation \a angle degrees clockwise. diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h index 1389796c3f..e98ec52d8f 100644 --- a/src/widgets/graphicsview/qgraphicsview.h +++ b/src/widgets/graphicsview/qgraphicsview.h @@ -165,9 +165,11 @@ public: void setSceneRect(const QRectF &rect); inline void setSceneRect(qreal x, qreal y, qreal w, qreal h); - QMatrix matrix() const; - void setMatrix(const QMatrix &matrix, bool combine = false); - void resetMatrix(); +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use transform()") QMatrix matrix() const; + QT_DEPRECATED_X("Use setTransform()") void setMatrix(const QMatrix &matrix, bool combine = false); + QT_DEPRECATED_X("Use resetTransform()") void resetMatrix(); +#endif // QT_DEPRECATED_SINCE(5, 15) QTransform transform() const; QTransform viewportTransform() const; bool isTransformed() const; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index c241f7a936..1e5830d216 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1556,7 +1556,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, qint64 maximum = qint64(pb->maximum); qint64 progress = qint64(pb->progress); - QMatrix m; + QTransform m; if (vertical) { rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 497afd17e1..105eba370a 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1692,7 +1692,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai const bool vertical = pb->orientation == Qt::Vertical; const bool inverted = pb->invertedAppearance; - QMatrix m; + QTransform m; if (vertical) { rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); // flip width and height m.rotate(90); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index bb28db7fac..edd4885450 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -992,12 +992,12 @@ void QWidgetTextControl::selectAll() void QWidgetTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWidget *contextWidget) { - QMatrix m; - m.translate(coordinateOffset.x(), coordinateOffset.y()); - processEvent(e, m, contextWidget); + QTransform t; + t.translate(coordinateOffset.x(), coordinateOffset.y()); + processEvent(e, t, contextWidget); } -void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget) +void QWidgetTextControl::processEvent(QEvent *e, const QTransform &transform, QWidget *contextWidget) { Q_D(QWidgetTextControl); if (d->interactionFlags == Qt::NoTextInteraction) { @@ -1038,22 +1038,22 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget break; case QEvent::MouseButtonPress: { QMouseEvent *ev = static_cast<QMouseEvent *>(e); - d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), + d->mousePressEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->globalPos()); break; } case QEvent::MouseMove: { QMouseEvent *ev = static_cast<QMouseEvent *>(e); - d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), + d->mouseMoveEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->globalPos()); break; } case QEvent::MouseButtonRelease: { QMouseEvent *ev = static_cast<QMouseEvent *>(e); - d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), + d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->globalPos()); break; } case QEvent::MouseButtonDblClick: { QMouseEvent *ev = static_cast<QMouseEvent *>(e); - d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), + d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->globalPos()); break; } case QEvent::InputMethod: @@ -1062,7 +1062,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget #ifndef QT_NO_CONTEXTMENU case QEvent::ContextMenu: { QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e); - d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget); + d->contextMenuEvent(ev->globalPos(), transform.map(ev->pos()), contextWidget); break; } #endif // QT_NO_CONTEXTMENU case QEvent::FocusIn: @@ -1077,7 +1077,7 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget #ifndef QT_NO_TOOLTIP case QEvent::ToolTip: { QHelpEvent *ev = static_cast<QHelpEvent *>(e); - d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget); + d->showToolTip(ev->globalPos(), transform.map(ev->pos()), contextWidget); break; } #endif // QT_NO_TOOLTIP @@ -1094,13 +1094,13 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget break; case QEvent::DragMove: { QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e); - if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos()))) + if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->pos()))) ev->acceptProposedAction(); break; } case QEvent::Drop: { QDropEvent *ev = static_cast<QDropEvent *>(e); - if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source())) + if (d->dropEvent(ev->mimeData(), transform.map(ev->pos()), ev->dropAction(), ev->source())) ev->acceptProposedAction(); break; } @@ -1109,32 +1109,32 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget #if QT_CONFIG(graphicsview) case QEvent::GraphicsSceneMousePress: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); - d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), + d->mousePressEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->screenPos()); break; } case QEvent::GraphicsSceneMouseMove: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); - d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), + d->mouseMoveEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->screenPos()); break; } case QEvent::GraphicsSceneMouseRelease: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); - d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), + d->mouseReleaseEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->screenPos()); break; } case QEvent::GraphicsSceneMouseDoubleClick: { QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e); - d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(), + d->mouseDoubleClickEvent(ev, ev->button(), transform.map(ev->pos()), ev->modifiers(), ev->buttons(), ev->screenPos()); break; } case QEvent::GraphicsSceneContextMenu: { QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e); - d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget); + d->contextMenuEvent(ev->screenPos(), transform.map(ev->pos()), contextWidget); break; } case QEvent::GraphicsSceneHoverMove: { QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e); - d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton, + d->mouseMoveEvent(ev, Qt::NoButton, transform.map(ev->pos()), ev->modifiers(),Qt::NoButton, ev->screenPos()); break; } @@ -1148,12 +1148,12 @@ void QWidgetTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget break; case QEvent::GraphicsSceneDragMove: { QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e); - if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos()))) + if (d->dragMoveEvent(e, ev->mimeData(), transform.map(ev->pos()))) ev->acceptProposedAction(); break; } case QEvent::GraphicsSceneDrop: { QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e); - if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source())) + if (d->dropEvent(ev->mimeData(), transform.map(ev->pos()), ev->dropAction(), ev->source())) ev->accept(); break; } #endif // QT_CONFIG(graphicsview) diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h index 1f06aa0b97..c445ecaf80 100644 --- a/src/widgets/widgets/qwidgettextcontrol_p.h +++ b/src/widgets/widgets/qwidgettextcontrol_p.h @@ -252,7 +252,7 @@ public: QPalette palette() const; void setPalette(const QPalette &pal); - virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = nullptr); + virtual void processEvent(QEvent *e, const QTransform &transform, QWidget *contextWidget = nullptr); void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = nullptr); // control methods diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 8197c386c5..7873c94b6d 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -3296,7 +3296,10 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(col, color); stream >> rGrad; QCOMPARE(rGrad.style(), radialBrush.style()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(rGrad.matrix(), radialBrush.matrix()); +QT_WARNING_POP QCOMPARE(rGrad.gradient()->type(), radialBrush.gradient()->type()); QCOMPARE(rGrad.gradient()->stops(), radialBrush.gradient()->stops()); QCOMPARE(rGrad.gradient()->spread(), radialBrush.gradient()->spread()); @@ -3305,7 +3308,10 @@ void tst_QDataStream::streamRealDataTypes() QCOMPARE(((QRadialGradient *)rGrad.gradient())->radius(), ((QRadialGradient *)radialBrush.gradient())->radius()); stream >> cGrad; QCOMPARE(cGrad.style(), conicalBrush.style()); +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(cGrad.matrix(), conicalBrush.matrix()); +QT_WARNING_POP QCOMPARE(cGrad.gradient()->type(), conicalBrush.gradient()->type()); QCOMPARE(cGrad.gradient()->stops(), conicalBrush.gradient()->stops()); QCOMPARE(cGrad.gradient()->spread(), conicalBrush.gradient()->spread()); diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index bc964e0d5c..71aaa23da4 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -32,7 +32,7 @@ #include <qimage.h> #include <qimagereader.h> #include <qlist.h> -#include <qmatrix.h> +#include <qtransform.h> #include <qrandom.h> #include <stdio.h> @@ -1204,7 +1204,7 @@ void tst_QImage::rotate() // original.save("rotated90_original.png", "png"); // Initialize the matrix manually (do not use rotate) to avoid rounding errors - QMatrix matRotate90; + QTransform matRotate90; matRotate90.rotate(degrees); QImage dest = original; // And rotate it 4 times, then the image should be identical to the original @@ -1218,7 +1218,7 @@ void tst_QImage::rotate() // dest.save("rotated90_result.png","png"); QCOMPARE(original, dest); - // Test with QMatrix::rotate 90 also, since we trust that now + // Test with QTransform::rotate 90 also, since we trust that now matRotate90.rotate(degrees); dest = original; // And rotate it 4 times, then the image should be identical to the original diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index ba5df809f2..1d77f70919 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -32,7 +32,6 @@ #include <qbitmap.h> #include <qimage.h> #include <qimagereader.h> -#include <qmatrix.h> #ifndef QT_NO_WIDGETS #include <qdesktopwidget.h> #include <qsplashscreen.h> diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index 3ce65a6785..81f0183728 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -193,9 +193,14 @@ template<> struct TestValueFactory<QMetaType::QTextLength> { template<> struct TestValueFactory<QMetaType::QTextFormat> { static QTextFormat *create() { return new QTextFormat(QTextFormat::FrameFormat); } }; +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED template<> struct TestValueFactory<QMetaType::QMatrix> { static QMatrix *create() { return new QMatrix(10, 20, 30, 40, 50, 60); } }; +QT_WARNING_POP +#endif template<> struct TestValueFactory<QMetaType::QTransform> { static QTransform *create() { return new QTransform(10, 20, 30, 40, 50, 60); } }; diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 0b9fc3c9ae..8b301c145a 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -402,6 +402,9 @@ void tst_QGuiVariant::toString() QCOMPARE( str, result ); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_QGuiVariant::matrix() { QVariant variant; @@ -414,6 +417,8 @@ void tst_QGuiVariant::matrix() QVERIFY(mmatrix); QMetaType::destroy(QVariant::Matrix, mmatrix); } +QT_WARNING_POP +#endif void tst_QGuiVariant::matrix4x4() { diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index e19f76d830..3c4f2f2e75 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -3061,6 +3061,9 @@ void tst_QMatrixNxN::columnsAndRows() QVERIFY(m1.row(3) == QVector4D(4, 8, 12, 16)); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // Test converting QMatrix objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. @@ -3107,6 +3110,8 @@ void tst_QMatrixNxN::convertQMatrix() QVERIFY(qFuzzyCompare(float(m5.dx()), float(m7.dx()))); QVERIFY(qFuzzyCompare(float(m5.dy()), float(m7.dy()))); } +QT_WARNING_POP +#endif // Test converting QTransform objects into QMatrix4x4 and then // checking that transformations in the original perform the diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index e05de64be5..9eb62ceab2 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -1704,8 +1704,11 @@ void tst_QPainter::combinedMatrix() QTransform ct = p.combinedTransform(); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QMatrix cm = p.combinedMatrix(); QCOMPARE(cm, ct.toAffine()); +QT_WARNING_POP #endif QPointF pt = QPointF(0, 0) * ct.toAffine(); @@ -2245,7 +2248,7 @@ void tst_QPainter::clippedPolygon() { QFETCH(QSize, imageSize); QFETCH(QPainterPath, path); - QPolygonF polygon = path.toFillPolygon(); + QPolygonF polygon = path.toFillPolygon(QTransform()); QFETCH(QRect, clipRect); QPainterPath clipPath; clipPath.addRect(clipRect); @@ -3066,7 +3069,7 @@ void tst_QPainter::fpe_steepSlopes_data() const qreal dsin = 0.000014946676875461832484392500630665523431162000633776187896728515625; const qreal dcos = 0.9999999998882984630910186751862056553363800048828125; - const QTransform transform = QTransform(QMatrix(dcos, dsin, -dsin, dcos, 64, 64)); + const QTransform transform = QTransform(dcos, dsin, -dsin, dcos, 64, 64); const QLineF line(2, 2, 2, 6); QTest::newRow("task 207147 aa") << transform << line << true; @@ -4064,7 +4067,7 @@ void tst_QPainter::drawPolygon() path.moveTo(2, 34); path.lineTo(34, 2); - QPolygonF poly = stroker.createStroke(path).toFillPolygon(); + QPolygonF poly = stroker.createStroke(path).toFillPolygon(QTransform()); img.fill(0xffffffff); QPainter p(&img); @@ -4133,7 +4136,10 @@ void tst_QPainter::inactivePainter() p.setClipping(true); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.combinedMatrix(); +QT_WARNING_POP #endif p.combinedTransform(); @@ -4142,7 +4148,10 @@ void tst_QPainter::inactivePainter() p.device(); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.deviceMatrix(); +QT_WARNING_POP #endif p.deviceTransform(); @@ -4168,7 +4177,10 @@ void tst_QPainter::inactivePainter() p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, false); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.resetMatrix(); +QT_WARNING_POP #endif p.resetTransform(); p.rotate(1); @@ -4186,8 +4198,11 @@ void tst_QPainter::inactivePainter() p.setWindow(QRect(10, 10, 620, 460)); #if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED p.worldMatrix(); p.setWorldMatrix(QMatrix().translate(43, 21), true); +QT_WARNING_POP #endif p.setWorldMatrixEnabled(true); diff --git a/tests/auto/gui/painting/qpathclipper/paths.cpp b/tests/auto/gui/painting/qpathclipper/paths.cpp index 1328befd1b..a814958394 100644 --- a/tests/auto/gui/painting/qpathclipper/paths.cpp +++ b/tests/auto/gui/painting/qpathclipper/paths.cpp @@ -713,9 +713,5 @@ QPainterPath Paths::bezierQuadrant() path.closeSubpath(); } - QMatrix m(2, 0, - 0, 2, - 0, 0); - return path; } diff --git a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp index 93035af7d3..01853d841a 100644 --- a/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp +++ b/tests/auto/gui/painting/qpathclipper/tst_qpathclipper.cpp @@ -152,9 +152,9 @@ void tst_QPathClipper::initTestCase() for (int i = 0; i < paths.size(); ++i) { QRectF bounds = paths[i].boundingRect(); - QMatrix m(1, 0, - 0, 1, - -bounds.center().x(), -bounds.center().y()); + QTransform m(1, 0, + 0, 1, + -bounds.center().x(), -bounds.center().y()); paths[i] = m.map(paths[i]); } diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index f9366c9227..78638a7518 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -331,17 +331,13 @@ void tst_QTransform::mapToPolygon() void tst_QTransform::qhash() { - QMatrix m1; - m1.shear(3.0, 2.0); - m1.rotate(44); + QTransform t1; + t1.shear(3.0, 2.0); + t1.rotate(44); - QMatrix m2 = m1; - - QTransform t1(m1); - QTransform t2(m2); + QTransform t2 = t1; // not really much to test here, so just the bare minimum: - QCOMPARE(qHash(m1), qHash(m2)); QCOMPARE(qHash(t1), qHash(t2)); } @@ -376,6 +372,9 @@ void tst_QTransform::scale() QVERIFY( QTransform::fromScale( 1, 1 ) == QTransform()); } +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED void tst_QTransform::matrix() { QMatrix mat1; @@ -414,7 +413,7 @@ void tst_QTransform::matrix() QRect rect(43, 70, 200, 200); QPoint pt(43, 66); - QCOMPARE(tranInv.map(pt), matInv.map(pt)); + QCOMPARE(tranInv.mapRect(rect), matInv.mapRect(rect)); QCOMPARE(tranInv.map(pt), matInv.map(pt)); QPainterPath path; @@ -431,6 +430,8 @@ void tst_QTransform::testOffset() const QMatrix &aff = trans.toAffine(); QCOMPARE((void*)(&aff), (void*)(&trans)); } +QT_WARNING_POP +#endif void tst_QTransform::types() { diff --git a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp index da88a868f3..281639c27a 100644 --- a/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp +++ b/tests/auto/gui/painting/qwmatrix/tst_qwmatrix.cpp @@ -32,6 +32,9 @@ #include <qmath.h> #include <qpolygon.h> +#if QT_DEPRECATED_SINCE(5, 15) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED class tst_QWMatrix : public QObject { @@ -324,5 +327,8 @@ void tst_QWMatrix::mapPolygon() } } +QT_WARNING_POP +#endif + QTEST_APPLESS_MAIN(tst_QWMatrix) #include "tst_qwmatrix.moc" diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 262e1772a0..5b11cd5d11 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -8014,11 +8014,21 @@ public: //Doesn't use the extended style option so the exposed rect is the boundingRect if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) { QCOMPARE(option->exposedRect, boundingRect()); +#if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(option->matrix, QMatrix()); +QT_WARNING_POP +#endif } else { QVERIFY(option->exposedRect != QRect()); QVERIFY(option->exposedRect != boundingRect()); +#if QT_DEPRECATED_SINCE(5, 13) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED QCOMPARE(option->matrix, sceneTransform().toAffine()); +QT_WARNING_POP +#endif } } QGraphicsRectItem::paint(painter, option, widget); diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp index ed79904ed8..0d8e5b4d54 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp @@ -31,7 +31,6 @@ #include <qgraphicsitemanimation.h> #include <QtCore/qtimeline.h> -#include <QtGui/qmatrix.h> class tst_QGraphicsItemAnimation : public QObject { diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index ea89e2422b..acf6ce1c68 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -67,7 +67,7 @@ using namespace QTestPrivate; Q_DECLARE_METATYPE(ExpectedValueDescription) Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QRectF>) -Q_DECLARE_METATYPE(QMatrix) +Q_DECLARE_METATYPE(QTransform) Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) Q_DECLARE_METATYPE(ScrollBarCount) @@ -291,7 +291,7 @@ void tst_QGraphicsView::construction() QCOMPARE(view.sceneRect(), QRectF()); QVERIFY(view.viewport()); QCOMPARE(view.viewport()->metaObject()->className(), "QWidget"); - QCOMPARE(view.matrix(), QMatrix()); + QCOMPARE(view.transform(), QTransform()); QVERIFY(view.items().isEmpty()); QVERIFY(view.items(QPoint()).isEmpty()); QVERIFY(view.items(QRect()).isEmpty()); @@ -1208,37 +1208,37 @@ void tst_QGraphicsView::matrix() void tst_QGraphicsView::matrix_convenience() { QGraphicsView view; - QCOMPARE(view.matrix(), QMatrix()); + QCOMPARE(view.transform(), QTransform()); // Check the convenience functions view.rotate(90); - QCOMPARE(view.matrix(), QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().rotate(90)); view.scale(2, 2); - QCOMPARE(view.matrix(), QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().scale(2, 2) * QTransform().rotate(90)); view.shear(1.2, 1.2); - QCOMPARE(view.matrix(), QMatrix().shear(1.2, 1.2) * QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().shear(1.2, 1.2) * QTransform().scale(2, 2) * QTransform().rotate(90)); view.translate(1, 1); - QCOMPARE(view.matrix(), QMatrix().translate(1, 1) * QMatrix().shear(1.2, 1.2) * QMatrix().scale(2, 2) * QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform().translate(1, 1) * QTransform().shear(1.2, 1.2) * QTransform().scale(2, 2) * QTransform().rotate(90)); } void tst_QGraphicsView::matrix_combine() { // Check matrix combining QGraphicsView view; - QCOMPARE(view.matrix(), QMatrix()); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - view.setMatrix(QMatrix().rotate(90), true); - QCOMPARE(view.matrix(), QMatrix()); - - view.resetMatrix(); - QCOMPARE(view.matrix(), QMatrix()); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - view.setMatrix(QMatrix().rotate(90), false); - QCOMPARE(view.matrix(), QMatrix().rotate(90)); + QCOMPARE(view.transform(), QTransform()); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + view.setTransform(QTransform().rotate(90), true); + QCOMPARE(view.transform(), QTransform()); + + view.resetTransform(); + QCOMPARE(view.transform(), QTransform()); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + view.setTransform(QTransform().rotate(90), false); + QCOMPARE(view.transform(), QTransform().rotate(90)); } void tst_QGraphicsView::centerOnPoint() @@ -2125,8 +2125,8 @@ void tst_QGraphicsView::mapFromScenePath() QPainterPath path2; path2.addPolygon(polygon2); - QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(); - QPolygonF path2Poly = path2.toFillPolygon(); + QPolygonF pathPoly = view.mapFromScene(path).toFillPolygon(QTransform()); + QPolygonF path2Poly = path2.toFillPolygon(QTransform()); for (int i = 0; i < pathPoly.size(); ++i) { QVERIFY(qAbs(pathPoly[i].x() - path2Poly[i].x()) < 3); diff --git a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp index 6e0ac445a6..60e8dd0032 100644 --- a/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp +++ b/tests/benchmarks/widgets/graphicsview/qgraphicsview/benchapps/chipTest/view.cpp @@ -187,7 +187,7 @@ void View::setupMatrix() { qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); - QMatrix matrix; + QTransform matrix; matrix.scale(scale, scale); matrix.rotate(rotateSlider->value()); |