diff options
author | John Layt <jlayt@kde.org> | 2014-02-14 01:45:37 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-21 20:33:10 +0100 |
commit | db352e1e97a0eb38cb5756f264b3162efeb86c02 (patch) | |
tree | 2d8242b8103619ed777cafd1b9f9c829d85c4e08 /src/corelib/tools | |
parent | b9feb884664aa8869ebfafbd8b3a8c65f668574e (diff) |
QRect - Move QMargins operators
Move QMargins operators to QRect file, change include sequence.
Change-Id: I0e2ad91859ae65eb67c6ece50f8e4037516b463e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qmargins.cpp | 59 | ||||
-rw-r--r-- | src/corelib/tools/qmargins.h | 37 | ||||
-rw-r--r-- | src/corelib/tools/qrect.cpp | 59 | ||||
-rw-r--r-- | src/corelib/tools/qrect.h | 43 |
4 files changed, 99 insertions, 99 deletions
diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index c5bd8468bc..06f41a6737 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -158,65 +158,6 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QRect operator+(const QRect &rectangle, const QMargins &margins) - \relates QRect - - Returns the \a rectangle grown by the \a margins. - - \since 5.1 -*/ - -/*! - \fn QRect operator+(const QMargins &margins, const QRect &rectangle) - \relates QRect - \overload - - Returns the \a rectangle grown by the \a margins. - - \since 5.1 -*/ - -/*! - \fn QRect QRect::marginsAdded(const QMargins &margins) const - - Returns a rectangle grown by the \a margins. - - \sa operator+=(), marginsRemoved(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::operator+=(const QMargins &margins) const - - Adds the \a margins to the rectangle, growing it. - - \sa marginsAdded(), marginsRemoved(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::marginsRemoved(const QMargins &margins) const - - Removes the \a margins from the rectangle, shrinking it. - - \sa marginsAdded(), operator+=(), operator-=() - - \since 5.1 -*/ - -/*! - \fn QRect QRect::operator -=(const QMargins &margins) const - - Returns a rectangle shrunk by the \a margins. - - \sa marginsRemoved(), operator+=(), marginsAdded() - - \since 5.1 -*/ - -/*! \fn const QMargins operator+(const QMargins &m1, const QMargins &m2) \relates QMargins diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h index ad5e94cefe..6bffa544c1 100644 --- a/src/corelib/tools/qmargins.h +++ b/src/corelib/tools/qmargins.h @@ -42,7 +42,7 @@ #ifndef QMARGINS_H #define QMARGINS_H -#include <QtCore/qrect.h> +#include <QtCore/qnamespace.h> QT_BEGIN_NAMESPACE @@ -149,41 +149,6 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QMargins &m1, const QMargins &m2) m1.m_bottom != m2.m_bottom; } -Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) -{ - return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), - QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); -} - -Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) -{ - return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), - QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); -} - -inline QRect QRect::marginsAdded(const QMargins &margins) const -{ - return *this + margins; -} - -inline QRect QRect::marginsRemoved(const QMargins &margins) const -{ - return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), - QPoint(x2 - margins.right(), y2 - margins.bottom())); -} - -inline QRect &QRect::operator+=(const QMargins &margins) -{ - *this = marginsAdded(margins); - return *this; -} - -inline QRect &QRect::operator-=(const QMargins &margins) -{ - *this = marginsRemoved(margins); - return *this; -} - Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2) { return QMargins(m1.left() + m2.left(), m1.top() + m2.top(), diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index fcff8931e8..e67b74ea6c 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -1162,6 +1162,65 @@ bool QRect::intersects(const QRect &r) const returns \c false. */ +/*! + \fn QRect operator+(const QRect &rectangle, const QMargins &margins) + \relates QRect + + Returns the \a rectangle grown by the \a margins. + + \since 5.1 +*/ + +/*! + \fn QRect operator+(const QMargins &margins, const QRect &rectangle) + \relates QRect + \overload + + Returns the \a rectangle grown by the \a margins. + + \since 5.1 +*/ + +/*! + \fn QRect QRect::marginsAdded(const QMargins &margins) const + + Returns a rectangle grown by the \a margins. + + \sa operator+=(), marginsRemoved(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::operator+=(const QMargins &margins) const + + Adds the \a margins to the rectangle, growing it. + + \sa marginsAdded(), marginsRemoved(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::marginsRemoved(const QMargins &margins) const + + Removes the \a margins from the rectangle, shrinking it. + + \sa marginsAdded(), operator+=(), operator-=() + + \since 5.1 +*/ + +/*! + \fn QRect QRect::operator -=(const QMargins &margins) const + + Returns a rectangle shrunk by the \a margins. + + \sa marginsRemoved(), operator+=(), marginsAdded() + + \since 5.1 +*/ + /***************************************************************************** QRect stream functions diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h index 22696f9edf..52f1a79362 100644 --- a/src/corelib/tools/qrect.h +++ b/src/corelib/tools/qrect.h @@ -42,6 +42,7 @@ #ifndef QRECT_H #define QRECT_H +#include <QtCore/qmargins.h> #include <QtCore/qsize.h> #include <QtCore/qpoint.h> @@ -51,8 +52,6 @@ QT_BEGIN_NAMESPACE -class QMargins; - class Q_CORE_EXPORT QRect { public: @@ -138,8 +137,8 @@ public: inline QRect intersected(const QRect &other) const; bool intersects(const QRect &r) const; - inline QRect marginsAdded(const QMargins &margins) const; - inline QRect marginsRemoved(const QMargins &margins) const; + Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const; + Q_DECL_CONSTEXPR inline QRect marginsRemoved(const QMargins &margins) const; inline QRect &operator+=(const QMargins &margins); inline QRect &operator-=(const QMargins &margins); @@ -452,6 +451,42 @@ Q_DECL_CONSTEXPR inline bool operator!=(const QRect &r1, const QRect &r2) return r1.x1!=r2.x1 || r1.x2!=r2.x2 || r1.y1!=r2.y1 || r1.y2!=r2.y2; } +Q_DECL_CONSTEXPR inline QRect operator+(const QRect &rectangle, const QMargins &margins) +{ + return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), + QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect operator+(const QMargins &margins, const QRect &rectangle) +{ + return QRect(QPoint(rectangle.left() - margins.left(), rectangle.top() - margins.top()), + QPoint(rectangle.right() + margins.right(), rectangle.bottom() + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect QRect::marginsAdded(const QMargins &margins) const +{ + return QRect(QPoint(x1 - margins.left(), y1 - margins.top()), + QPoint(x2 + margins.right(), y2 + margins.bottom())); +} + +Q_DECL_CONSTEXPR inline QRect QRect::marginsRemoved(const QMargins &margins) const +{ + return QRect(QPoint(x1 + margins.left(), y1 + margins.top()), + QPoint(x2 - margins.right(), y2 - margins.bottom())); +} + +inline QRect &QRect::operator+=(const QMargins &margins) +{ + *this = marginsAdded(margins); + return *this; +} + +inline QRect &QRect::operator-=(const QMargins &margins) +{ + *this = marginsRemoved(margins); + return *this; +} + #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &); #endif |