summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qmargins.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-16 15:49:14 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-24 17:40:09 +0200
commit5d32552cf40d8ec15ed313f71559444c8765efd2 (patch)
tree023d5ec3cbb4d135dd6c2a2002c460e2e7437c51 /src/corelib/tools/qmargins.h
parentfd894fd68edf3d67975cda8eb9dda43646887b0d (diff)
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>
Diffstat (limited to 'src/corelib/tools/qmargins.h')
-rw-r--r--src/corelib/tools/qmargins.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h
index 447037daaa..bc1fa3cb61 100644
--- a/src/corelib/tools/qmargins.h
+++ b/src/corelib/tools/qmargins.h
@@ -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;