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>
This commit is contained in:
parent
b9feb88466
commit
db352e1e97
@ -157,65 +157,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
Returns \c true if \a m1 and \a m2 are different; otherwise returns \c false.
|
Returns \c true if \a m1 and \a m2 are different; otherwise 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn const QMargins operator+(const QMargins &m1, const QMargins &m2)
|
\fn const QMargins operator+(const QMargins &m1, const QMargins &m2)
|
||||||
\relates QMargins
|
\relates QMargins
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#ifndef QMARGINS_H
|
#ifndef QMARGINS_H
|
||||||
#define QMARGINS_H
|
#define QMARGINS_H
|
||||||
|
|
||||||
#include <QtCore/qrect.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
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;
|
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)
|
Q_DECL_CONSTEXPR inline QMargins operator+(const QMargins &m1, const QMargins &m2)
|
||||||
{
|
{
|
||||||
return QMargins(m1.left() + m2.left(), m1.top() + m2.top(),
|
return QMargins(m1.left() + m2.left(), m1.top() + m2.top(),
|
||||||
|
@ -1162,6 +1162,65 @@ bool QRect::intersects(const QRect &r) const
|
|||||||
returns \c false.
|
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
|
QRect stream functions
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#ifndef QRECT_H
|
#ifndef QRECT_H
|
||||||
#define QRECT_H
|
#define QRECT_H
|
||||||
|
|
||||||
|
#include <QtCore/qmargins.h>
|
||||||
#include <QtCore/qsize.h>
|
#include <QtCore/qsize.h>
|
||||||
#include <QtCore/qpoint.h>
|
#include <QtCore/qpoint.h>
|
||||||
|
|
||||||
@ -51,8 +52,6 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QMargins;
|
|
||||||
|
|
||||||
class Q_CORE_EXPORT QRect
|
class Q_CORE_EXPORT QRect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -138,8 +137,8 @@ public:
|
|||||||
inline QRect intersected(const QRect &other) const;
|
inline QRect intersected(const QRect &other) const;
|
||||||
bool intersects(const QRect &r) const;
|
bool intersects(const QRect &r) const;
|
||||||
|
|
||||||
inline QRect marginsAdded(const QMargins &margins) const;
|
Q_DECL_CONSTEXPR inline QRect marginsAdded(const QMargins &margins) const;
|
||||||
inline QRect marginsRemoved(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);
|
||||||
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;
|
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
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &);
|
Q_CORE_EXPORT QDebug operator<<(QDebug, const QRect &);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user