From 73d1476fb1397948a4d806bd921fce372bd8d63b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Dec 2019 17:54:48 +0100 Subject: Replace most use of QVariant::type and occurrences of QVariant::Type I made a clazy automated check that replaced the use of QVariant::Type by the equivalent in QMetaType. This has been deprecated since Qt 5.0, but many uses were not yet removed. In addition, there was some manual changes to fix the compilation errors. Adapted the Private API of QDateTimeParser and QMimeDataPrivate and adjust QDateTimeEdit and QSpinBox. QVariant(QVariant::Invalid) in qstylesheet made no sense. But note that in QVariant::save, we actually wanted to use the non-user type. In the SQL module, many changes were actually reverted because the API still expects QVarient::Type. Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicsitem.cpp | 8 ++++---- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 10 +++++----- src/widgets/graphicsview/qgraphicsscene.cpp | 8 ++++---- src/widgets/graphicsview/qgraphicsview.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/widgets/graphicsview') diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 6f1eb4b346..a2120e53fe 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -10511,13 +10511,13 @@ QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const v = int(inputMethodHints()); else if (dd->control) v = dd->control->inputMethodQuery(query, QVariant()); - if (v.type() == QVariant::RectF) + if (v.userType() == QMetaType::QRectF) v = v.toRectF().translated(-dd->controlOffset()); - else if (v.type() == QVariant::PointF) + else if (v.userType() == QMetaType::QPointF) v = v.toPointF() - dd->controlOffset(); - else if (v.type() == QVariant::Rect) + else if (v.userType() == QMetaType::QRect) v = v.toRect().translated(-dd->controlOffset().toPoint()); - else if (v.type() == QVariant::Point) + else if (v.userType() == QMetaType::QPoint) v = v.toPoint() - dd->controlOffset().toPoint(); return v; } diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index 4d4958c674..eb8acf1f27 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -1441,17 +1441,17 @@ QVariant QGraphicsProxyWidget::inputMethodQuery(Qt::InputMethodQuery query) cons focusWidget = d->widget; QVariant v = focusWidget->inputMethodQuery(query); QPointF focusWidgetPos = subWidgetRect(focusWidget).topLeft(); - switch (v.type()) { - case QVariant::RectF: + switch (v.userType()) { + case QMetaType::QRectF: v = v.toRectF().translated(focusWidgetPos); break; - case QVariant::PointF: + case QMetaType::QPointF: v = v.toPointF() + focusWidgetPos; break; - case QVariant::Rect: + case QMetaType::QRect: v = v.toRect().translated(focusWidgetPos.toPoint()); break; - case QVariant::Point: + case QMetaType::QPoint: v = v.toPoint() + focusWidgetPos.toPoint(); break; default: diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 1c6e68def1..1cb24f74b6 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -3190,13 +3190,13 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const return QVariant(); const QTransform matrix = d->focusItem->sceneTransform(); QVariant value = d->focusItem->inputMethodQuery(query); - if (value.type() == QVariant::RectF) + if (value.userType() == QMetaType::QRectF) value = matrix.mapRect(value.toRectF()); - else if (value.type() == QVariant::PointF) + else if (value.userType() == QMetaType::QPointF) value = matrix.map(value.toPointF()); - else if (value.type() == QVariant::Rect) + else if (value.userType() == QMetaType::QRect) value = matrix.mapRect(value.toRect()); - else if (value.type() == QVariant::Point) + else if (value.userType() == QMetaType::QPoint) value = matrix.map(value.toPoint()); return value; } diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index 7589a1ebbd..e1a829f779 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -2589,13 +2589,13 @@ QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const return QVariant(); QVariant value = d->scene->inputMethodQuery(query); - if (value.type() == QVariant::RectF) + if (value.userType() == QMetaType::QRectF) value = d->mapRectFromScene(value.toRectF()); - else if (value.type() == QVariant::PointF) + else if (value.userType() == QMetaType::QPointF) value = mapFromScene(value.toPointF()); - else if (value.type() == QVariant::Rect) + else if (value.userType() == QMetaType::QRect) value = d->mapRectFromScene(value.toRect()).toRect(); - else if (value.type() == QVariant::Point) + else if (value.userType() == QMetaType::QPoint) value = mapFromScene(value.toPoint()); return value; } -- cgit v1.2.3 From aec4e05e9e8ad9109d7db15dd0fea477e4574c20 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 25 Jan 2020 20:12:12 +0100 Subject: Doc/QtWidgets: replace some 0 with \nullptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace some 'is 0' or 'are 0' where 0 referes to a nullptr with 'is \nullptr' and 'are \nullptr' Change-Id: I5ff46185b570bdfc7d20d18a47fd9174771ad8e5 Reviewed-by: André Hartmann Reviewed-by: Sze Howe Koh --- src/widgets/graphicsview/qgraphicsproxywidget.cpp | 4 ++-- src/widgets/graphicsview/qgraphicsview.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/widgets/graphicsview') diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp index eb8acf1f27..a9a57c57fa 100644 --- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp +++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp @@ -570,8 +570,8 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget() After this function returns, QGraphicsProxyWidget will keep its state synchronized with that of \a widget whenever possible. - If a widget is already embedded by this proxy when this function is - called, that widget will first be automatically unembedded. Passing 0 for + If a widget is already embedded by this proxy when this function is called, + that widget will first be automatically unembedded. Passing \nullptr for the \a widget argument will only unembed the widget, and the ownership of the currently embedded widget will be passed on to the caller. Every child widget that are embedded will also be embedded and their proxy diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp index e1a829f779..102f3e894f 100644 --- a/src/widgets/graphicsview/qgraphicsview.cpp +++ b/src/widgets/graphicsview/qgraphicsview.cpp @@ -963,7 +963,7 @@ static inline void QRect_unite(QRect *rect, const QRect &other) /* Calling this function results in update rects being clipped to the item's bounding rect. Note that updates prior to this function call is not clipped. - The clip is removed by passing 0. + The clip is removed by passing \nullptr. */ void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item) { -- cgit v1.2.3 From 4bb897a3841f0f79150787e29fe122e1410bc119 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 10 Jan 2020 10:08:37 +0100 Subject: Deprecate all methods that use QMatrix Don't use QMatrix in implementation classes anymore. Task-number: QTBUG-46653 Fixes: QTBUG-81627 Change-Id: I4806c1302e42645dc6a608062c8d9c336ae8629b Reviewed-by: Leena Miettinen Reviewed-by: Laszlo Agocs Reviewed-by: Lars Knoll --- src/widgets/graphicsview/qgraphicsscene.cpp | 1 - src/widgets/graphicsview/qgraphicsscene.h | 1 - src/widgets/graphicsview/qgraphicsview.cpp | 16 ++++++++++++++++ src/widgets/graphicsview/qgraphicsview.h | 8 +++++--- 4 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src/widgets/graphicsview') 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 #include #include -#include #include #include #include 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 #include #include -#include #include 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; -- cgit v1.2.3