From e6a7b61d273c2985dee63df34e5941ee90754e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sun, 9 Jul 2017 19:27:35 +0200 Subject: Add clear, reserve and capacity methods to QPainterPath This allows anticipating and reusing internal allocations of QPainterPathElements instead of using the common `m_myPath = QPainterPath{}` pattern. [ChangeLog][QtGui][QPainterPath] Added clear(), reserve(), capacity(). clear() removes allocated QPainterPath elements but preserves allocated memory, which can be useful for application with complex paths that are often recreated. reserve() and capacity() follow QVector semantics. Change-Id: I763461e2a421feda9053d3eb512af2fcf07ade2b Reviewed-by: Allan Sandfeld Jensen --- src/gui/painting/qpainterpath.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/painting/qpainterpath.h') diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index db39c1c5a0..770b8f48d0 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -97,8 +97,13 @@ public: { qSwap(d_ptr, other.d_ptr); return *this; } #endif ~QPainterPath(); + inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); } + void clear(); + void reserve(int size); + int capacity() const; + void closeSubpath(); void moveTo(const QPointF &p); -- cgit v1.2.3 From 860bfc69e44c6b8d3cd0263c5afc729292aa639d Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 26 Jan 2019 13:11:41 +0100 Subject: QtGui/QPainterPath: mark obsolete functions as deprecated Mark some long obsolete functions as deprecated so the can be removed with Qt6: - addRoundRect() - subtractedInverted() Change-Id: I4707c07e983a4ac65ec3706d25b09ec01a9de62c Reviewed-by: Eirik Aavitsland --- src/gui/painting/qpainterpath.h | 43 ++++++++++++++--------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) (limited to 'src/gui/painting/qpainterpath.h') diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index 770b8f48d0..a69a192767 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -143,12 +143,18 @@ public: qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") void addRoundRect(const QRectF &rect, int xRnd, int yRnd); - inline void addRoundRect(qreal x, qreal y, qreal w, qreal h, - int xRnd, int yRnd); - inline void addRoundRect(const QRectF &rect, int roundness); - inline void addRoundRect(qreal x, qreal y, qreal w, qreal h, - int roundness); + QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") + void addRoundRect(qreal x, qreal y, qreal w, qreal h, + int xRnd, int yRnd); + QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") + void addRoundRect(const QRectF &rect, int roundness); + QT_DEPRECATED_X("Use addRoundedRect(..., Qt::RelativeSize) instead") + void addRoundRect(qreal x, qreal y, qreal w, qreal h, + int roundness); +#endif void connectPath(const QPainterPath &path); @@ -193,7 +199,10 @@ public: Q_REQUIRED_RESULT QPainterPath united(const QPainterPath &r) const; Q_REQUIRED_RESULT QPainterPath intersected(const QPainterPath &r) const; Q_REQUIRED_RESULT QPainterPath subtracted(const QPainterPath &r) const; +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use r.subtracted() instead") Q_REQUIRED_RESULT QPainterPath subtractedInverted(const QPainterPath &r) const; +#endif Q_REQUIRED_RESULT QPainterPath simplified() const; @@ -338,30 +347,6 @@ inline void QPainterPath::addRoundedRect(qreal x, qreal y, qreal w, qreal h, addRoundedRect(QRectF(x, y, w, h), xRadius, yRadius, mode); } -inline void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h, - int xRnd, int yRnd) -{ - addRoundRect(QRectF(x, y, w, h), xRnd, yRnd); -} - -inline void QPainterPath::addRoundRect(const QRectF &rect, - int roundness) -{ - int xRnd = roundness; - int yRnd = roundness; - if (rect.width() > rect.height()) - xRnd = int(roundness * rect.height()/rect.width()); - else - yRnd = int(roundness * rect.width()/rect.height()); - addRoundRect(rect, xRnd, yRnd); -} - -inline void QPainterPath::addRoundRect(qreal x, qreal y, qreal w, qreal h, - int roundness) -{ - addRoundRect(QRectF(x, y, w, h), roundness); -} - inline void QPainterPath::addText(qreal x, qreal y, const QFont &f, const QString &text) { addText(QPointF(x, y), f, text); -- cgit v1.2.3 From dbf7706413bb8d624ac17b24398eaf4ef542ed6b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 10:59:52 +0200 Subject: Replace Q_DECL_NOEXCEPT with noexcept in QtGui Change-Id: I43803b88fea8083782d73ce157c466b022208740 Reviewed-by: Thiago Macieira --- src/gui/painting/qpainterpath.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/painting/qpainterpath.h') diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h index a69a192767..2785669260 100644 --- a/src/gui/painting/qpainterpath.h +++ b/src/gui/painting/qpainterpath.h @@ -88,17 +88,17 @@ public: inline bool operator!=(const Element &e) const { return !operator==(e); } }; - QPainterPath() Q_DECL_NOEXCEPT; + QPainterPath() noexcept; explicit QPainterPath(const QPointF &startPoint); QPainterPath(const QPainterPath &other); QPainterPath &operator=(const QPainterPath &other); #ifdef Q_COMPILER_RVALUE_REFS - inline QPainterPath &operator=(QPainterPath &&other) Q_DECL_NOEXCEPT + inline QPainterPath &operator=(QPainterPath &&other) noexcept { qSwap(d_ptr, other.d_ptr); return *this; } #endif ~QPainterPath(); - inline void swap(QPainterPath &other) Q_DECL_NOEXCEPT { d_ptr.swap(other.d_ptr); } + inline void swap(QPainterPath &other) noexcept { d_ptr.swap(other.d_ptr); } void clear(); void reserve(int size); -- cgit v1.2.3