Move QMargins operator| into qmargins.h, add equivalent for QMarginsF
Addresses FIXME comment in qwidget.cpp, where the operator is being used. Add documentation, make constexpr and add noexcept as for the other operators. As a drive-by, remove invalid const from return type in the documentation of the other operators. They all return a non-const QMargins object. Change-Id: I5a9ca82978d38acd02e03ec00ca202fe1b8cf6c1 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
fd894fd68e
commit
5d32552cf4
@ -157,7 +157,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator+(const QMargins &m1, const QMargins &m2)
|
||||
\fn QMargins operator+(const QMargins &m1, const QMargins &m2)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is the sum of the given margins, \a m1
|
||||
@ -169,7 +169,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator-(const QMargins &m1, const QMargins &m2)
|
||||
\fn QMargins operator-(const QMargins &m1, const QMargins &m2)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by subtracting \a m2 from
|
||||
@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator+(const QMargins &lhs, int rhs)
|
||||
\fn QMargins operator+(const QMargins &lhs, int rhs)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by adding \a rhs to
|
||||
@ -193,7 +193,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator+(int lhs, const QMargins &rhs)
|
||||
\fn QMargins operator+(int lhs, const QMargins &rhs)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by adding \a lhs to
|
||||
@ -205,7 +205,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator-(const QMargins &lhs, int rhs)
|
||||
\fn QMargins operator-(const QMargins &lhs, int rhs)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by subtracting \a rhs from
|
||||
@ -217,7 +217,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator*(const QMargins &margins, int factor)
|
||||
\fn QMargins operator*(const QMargins &margins, int factor)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by multiplying each component
|
||||
@ -229,7 +229,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator*(int factor, const QMargins &margins)
|
||||
\fn QMargins operator*(int factor, const QMargins &margins)
|
||||
\relates QMargins
|
||||
\overload
|
||||
|
||||
@ -242,7 +242,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator*(const QMargins &margins, qreal factor)
|
||||
\fn QMargins operator*(const QMargins &margins, qreal factor)
|
||||
\relates QMargins
|
||||
\overload
|
||||
|
||||
@ -255,7 +255,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator*(qreal factor, const QMargins &margins)
|
||||
\fn QMargins operator*(qreal factor, const QMargins &margins)
|
||||
\relates QMargins
|
||||
\overload
|
||||
|
||||
@ -268,7 +268,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator/(const QMargins &margins, int divisor)
|
||||
\fn QMargins operator/(const QMargins &margins, int divisor)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed by dividing the components of
|
||||
@ -280,7 +280,7 @@ QT_BEGIN_NAMESPACE
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn const QMargins operator/(const QMargins &, qreal)
|
||||
\fn QMargins operator/(const QMargins &, qreal)
|
||||
\relates QMargins
|
||||
\overload
|
||||
|
||||
@ -310,6 +310,18 @@ QT_BEGIN_NAMESPACE
|
||||
\since 5.1
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMargins operator|(const QMargins &m1, const QMargins &m2)
|
||||
\relates QMargins
|
||||
|
||||
Returns a QMargins object that is formed from the maximum of each
|
||||
component of \a m2 and a m1.
|
||||
|
||||
\sa QMargins::operator+=(), QMargins::operator-=()
|
||||
|
||||
\since 6.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMargins &QMargins::operator+=(const QMargins &margins)
|
||||
|
||||
@ -650,6 +662,19 @@ QDebug operator<<(QDebug dbg, const QMargins &m)
|
||||
\sa QMarginsF::operator*=(), QMarginsF::operator/=()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMargins operator|(const QMargins &m1, const QMargins &m2)
|
||||
\relates QMarginsF
|
||||
\overload
|
||||
|
||||
Returns a QMarginsF object that is formed from the maximum of each
|
||||
component of \a m2 and a m1.
|
||||
|
||||
\sa QMarginsF::operator+=(), QMarginsF::operator-=()
|
||||
|
||||
\since 6.0
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QMarginsF operator+(const QMarginsF &margins)
|
||||
\relates QMarginsF
|
||||
|
@ -216,6 +216,12 @@ Q_DECL_CONSTEXPR inline QMargins operator/(const QMargins &margins, qreal diviso
|
||||
qRound(margins.right() / divisor), qRound(margins.bottom() / divisor));
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QMargins operator|(const QMargins &m1, const QMargins &m2) noexcept
|
||||
{
|
||||
return QMargins(qMax(m1.left(), m2.left()), qMax(m1.top(), m2.top()),
|
||||
qMax(m1.right(), m2.right()), qMax(m1.bottom(), m2.bottom()));
|
||||
}
|
||||
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QMargins &QMargins::operator+=(const QMargins &margins) noexcept
|
||||
{
|
||||
return *this = *this + margins;
|
||||
@ -430,6 +436,12 @@ Q_DECL_CONSTEXPR inline QMarginsF operator/(const QMarginsF &lhs, qreal divisor)
|
||||
lhs.right() / divisor, lhs.bottom() / divisor);
|
||||
}
|
||||
|
||||
Q_DECL_CONSTEXPR inline QMarginsF operator|(const QMarginsF &m1, const QMarginsF &m2) noexcept
|
||||
{
|
||||
return QMarginsF(qMax(m1.left(), m2.left()), qMax(m1.top(), m2.top()),
|
||||
qMax(m1.right(), m2.right()), qMax(m1.bottom(), m2.bottom()));
|
||||
}
|
||||
|
||||
Q_DECL_RELAXED_CONSTEXPR inline QMarginsF &QMarginsF::operator+=(const QMarginsF &margins) noexcept
|
||||
{
|
||||
return *this = *this + margins;
|
||||
|
@ -7414,14 +7414,6 @@ void QWidgetPrivate::updateContentsRect()
|
||||
QCoreApplication::sendEvent(q, &e);
|
||||
}
|
||||
|
||||
|
||||
// FIXME: Move to qmargins.h for next minor Qt release
|
||||
QMargins operator|(const QMargins &m1, const QMargins &m2)
|
||||
{
|
||||
return QMargins(qMax(m1.left(), m2.left()), qMax(m1.top(), m2.top()),
|
||||
qMax(m1.right(), m2.right()), qMax(m1.bottom(), m2.bottom()));
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.6
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user