From 93cebb3837e341718dfc0cc44cb74d963e8e2c6c Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 26 Jan 2019 20:06:14 +0100 Subject: [PATCH] QtWidgets/Graphics-/ItemViews: mark obsolete functions as deprecated Mark some long obsolete functions as deprecated so the can be removed with Qt6: - QGraphicsItem::matrix()/setMatrix()/resetMatrix()/sceneMatrix() - QGraphicsItemAnimation::reset() - QGraphicsScene::isSortCacheEnabled()/setSortCacheEnabled() - QAbstractItemDelegate::elidedText() - QAbstractItemView::setHorizontalStepsPerItem()/horizontalStepsPerItem() - QAbstractItemView::setVerticalStepsPerItem()/verticalStepsPerItem() Change-Id: I7244078552ebeac9dfbcf3291b3ae0c44cc2c1d9 Reviewed-by: Friedemann Kleint Reviewed-by: Richard Moe Gustavsen --- src/widgets/graphicsview/qgraphicsitem.cpp | 9 ++++++++- src/widgets/graphicsview/qgraphicsitem.h | 6 ++++++ src/widgets/graphicsview/qgraphicsitemanimation.cpp | 2 ++ src/widgets/graphicsview/qgraphicsitemanimation.h | 3 +++ src/widgets/graphicsview/qgraphicsscene.cpp | 2 ++ src/widgets/graphicsview/qgraphicsscene.h | 6 ++++-- src/widgets/itemviews/qabstractitemdelegate.cpp | 2 ++ src/widgets/itemviews/qabstractitemdelegate.h | 3 +++ src/widgets/itemviews/qabstractitemview.cpp | 2 ++ src/widgets/itemviews/qabstractitemview.h | 10 ++++++---- 10 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 4476ecded3..6e53ea94f3 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -3997,6 +3997,7 @@ void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin). */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -4012,6 +4013,7 @@ QMatrix QGraphicsItem::matrix() const { return transform().toAffine(); } +#endif /*! \since 4.3 @@ -4322,6 +4324,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -4334,7 +4337,7 @@ QMatrix QGraphicsItem::sceneMatrix() const d_ptr->ensureSceneTransform(); return d_ptr->sceneTransform.toAffine(); } - +#endif /*! \since 4.3 @@ -4546,6 +4549,7 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co return x; } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -4584,6 +4588,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) // Send post-notification. itemChange(ItemTransformHasChanged, QVariant::fromValue(newTransform)); } +#endif /*! \since 4.3 @@ -4638,6 +4643,7 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) d_ptr->sendScenePosChange(); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -4647,6 +4653,7 @@ void QGraphicsItem::resetMatrix() { resetTransform(); } +#endif /*! \since 4.3 diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 729176530d..7dd4441ae9 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -283,10 +283,16 @@ public: inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50); // Local transformation +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use transform() instead") QMatrix matrix() const; + QT_DEPRECATED_X("Use sceneTransform() instead") QMatrix sceneMatrix() const; + QT_DEPRECATED_X("Use setTransform() instead") void setMatrix(const QMatrix &matrix, bool combine = false); + QT_DEPRECATED_X("Use resetTransform() instead") void resetMatrix(); +#endif QTransform transform() const; QTransform sceneTransform() const; QTransform deviceTransform(const QTransform &viewportTransform) const; diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp index 572ec141bc..78b91d5c39 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp +++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp @@ -549,6 +549,7 @@ void QGraphicsItemAnimation::setStep(qreal step) afterAnimationStep(step); } +#if QT_DEPRECATED_SINCE(5, 13) /*! Resets the item to its starting position and transformation. @@ -563,6 +564,7 @@ void QGraphicsItemAnimation::reset() d->startPos = d->item->pos(); d->startMatrix = d->item->matrix(); } +#endif /*! \fn void QGraphicsItemAnimation::beforeAnimationStep(qreal step) diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h index 7417d7729c..f983bd8026 100644 --- a/src/widgets/graphicsview/qgraphicsitemanimation.h +++ b/src/widgets/graphicsview/qgraphicsitemanimation.h @@ -96,7 +96,10 @@ public: public Q_SLOTS: void setStep(qreal x); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use setStep(0) instead") void reset(); +#endif protected: virtual void beforeAnimationStep(qreal step); diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index db7ce5251a..a60c2872ae 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1929,6 +1929,7 @@ void QGraphicsScene::setBspTreeDepth(int depth) bspTree->setBspTreeDepth(depth); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \property QGraphicsScene::sortCacheEnabled \brief whether sort caching is enabled @@ -1949,6 +1950,7 @@ void QGraphicsScene::setSortCacheEnabled(bool enabled) return; d->sortCacheEnabled = enabled; } +#endif /*! Calculates and returns the bounding rect of all items on the scene. This diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h index 287e551db7..71b8fc3013 100644 --- a/src/widgets/graphicsview/qgraphicsscene.h +++ b/src/widgets/graphicsview/qgraphicsscene.h @@ -141,8 +141,10 @@ public: ItemIndexMethod itemIndexMethod() const; void setItemIndexMethod(ItemIndexMethod method); - bool isSortCacheEnabled() const; - void setSortCacheEnabled(bool enabled); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED bool isSortCacheEnabled() const; + QT_DEPRECATED void setSortCacheEnabled(bool enabled); +#endif int bspTreeDepth() const; void setBspTreeDepth(int depth); diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 4bdc318566..448e775a71 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -345,6 +345,7 @@ bool QAbstractItemDelegate::editorEvent(QEvent *, return false; } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -364,6 +365,7 @@ QString QAbstractItemDelegate::elidedText(const QFontMetrics &fontMetrics, int w { return fontMetrics.elidedText(text, mode, width); } +#endif /*! \since 4.3 diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h index 575728e806..5696e55691 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.h +++ b/src/widgets/itemviews/qabstractitemdelegate.h @@ -103,8 +103,11 @@ public: const QStyleOptionViewItem &option, const QModelIndex &index); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QFontMetrics::elidedText() instead") static QString elidedText(const QFontMetrics &fontMetrics, int width, Qt::TextElideMode mode, const QString &text); +#endif virtual bool helpEvent(QHelpEvent *event, QAbstractItemView *view, diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 7441161e13..63803767c8 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -2921,6 +2921,7 @@ void QAbstractItemView::editorDestroyed(QObject *editor) setState(NoState); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete Sets the horizontal scroll bar's steps per item to \a steps. @@ -2978,6 +2979,7 @@ int QAbstractItemView::verticalStepsPerItem() const { return 1; } +#endif /*! Moves to and selects the item best matching the string \a search. diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h index 981582c166..be8fa07c94 100644 --- a/src/widgets/itemviews/qabstractitemview.h +++ b/src/widgets/itemviews/qabstractitemview.h @@ -272,10 +272,12 @@ Q_SIGNALS: protected: QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = nullptr); - void setHorizontalStepsPerItem(int steps); - int horizontalStepsPerItem() const; - void setVerticalStepsPerItem(int steps); - int verticalStepsPerItem() const; +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED void setHorizontalStepsPerItem(int steps); + QT_DEPRECATED int horizontalStepsPerItem() const; + QT_DEPRECATED void setVerticalStepsPerItem(int steps); + QT_DEPRECATED int verticalStepsPerItem() const; +#endif enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight, MoveHome, MoveEnd, MovePageUp, MovePageDown,