diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-12-24 13:56:13 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-12-24 13:56:13 (GMT) |
commit | e475d3e7fc023109478726555b676203cf8c4c5c (patch) | |
tree | c9603895b22279d0aa2876cac6e174d7d0aad57e /src/corelib | |
parent | 0f35089dec33ff0b2d424601b031dcd4446d3438 (diff) | |
parent | 9d26b5ad31a946ef631ca29da7379571267efddf (diff) | |
download | Qt-e475d3e7fc023109478726555b676203cf8c4c5c.zip Qt-e475d3e7fc023109478726555b676203cf8c4c5c.tar.gz Qt-e475d3e7fc023109478726555b676203cf8c4c5c.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Prevented infinite loop in QMoviePrivate::next().
Added int overloads to QPoint operator* and operator*=.
tst_qmessagebox: add debug to know why it fails
QMessageBox wrong Show/Hide Details button label
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qpoint.cpp | 63 | ||||
-rw-r--r-- | src/corelib/tools/qpoint.h | 38 |
2 files changed, 92 insertions, 9 deletions
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index c297709..592a83d 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -187,7 +187,19 @@ QT_BEGIN_NAMESPACE */ /*! - \fn QPoint &QPoint::operator*=(qreal factor) + \fn QPoint &QPoint::operator*=(float factor) + + Multiplies this point's coordinates by the given \a factor, and + returns a reference to this point. + + Note that the result is rounded to the nearest integer as points are held as + integers. Use QPointF for floating point accuracy. + + \sa operator/=() +*/ + +/*! + \fn QPoint &QPoint::operator*=(double factor) Multiplies this point's coordinates by the given \a factor, and returns a reference to this point. For example: @@ -200,6 +212,14 @@ QT_BEGIN_NAMESPACE \sa operator/=() */ +/*! + \fn QPoint &QPoint::operator*=(int factor) + + Multiplies this point's coordinates by the given \a factor, and + returns a reference to this point. + + \sa operator/=() +*/ /*! \fn bool operator==(const QPoint &p1, const QPoint &p2) @@ -237,7 +257,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn const QPoint operator*(const QPoint &point, qreal factor) + \fn const QPoint operator*(const QPoint &point, float factor) \relates QPoint Returns a copy of the given \a point multiplied by the given \a factor. @@ -249,7 +269,44 @@ QT_BEGIN_NAMESPACE */ /*! - \fn const QPoint operator*(qreal factor, const QPoint &point) + \fn const QPoint operator*(const QPoint &point, double factor) + \relates QPoint + + Returns a copy of the given \a point multiplied by the given \a factor. + + Note that the result is rounded to the nearest integer as points + are held as integers. Use QPointF for floating point accuracy. + + \sa QPoint::operator*=() +*/ + +/*! + \fn const QPoint operator*(const QPoint &point, int factor) + \relates QPoint + + Returns a copy of the given \a point multiplied by the given \a factor. + + \sa QPoint::operator*=() +*/ + +/*! + \fn const QPoint operator*(float factor, const QPoint &point) + \overload + \relates QPoint + + Returns a copy of the given \a point multiplied by the given \a factor. +*/ + +/*! + \fn const QPoint operator*(double factor, const QPoint &point) + \overload + \relates QPoint + + Returns a copy of the given \a point multiplied by the given \a factor. +*/ + +/*! + \fn const QPoint operator*(int factor, const QPoint &point) \overload \relates QPoint diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h index 79a7dd8..e57b0ed 100644 --- a/src/corelib/tools/qpoint.h +++ b/src/corelib/tools/qpoint.h @@ -70,15 +70,23 @@ public: QPoint &operator+=(const QPoint &p); QPoint &operator-=(const QPoint &p); - QPoint &operator*=(qreal c); + + QPoint &operator*=(float c); + QPoint &operator*=(double c); + QPoint &operator*=(int c); + QPoint &operator/=(qreal c); friend inline bool operator==(const QPoint &, const QPoint &); friend inline bool operator!=(const QPoint &, const QPoint &); friend inline const QPoint operator+(const QPoint &, const QPoint &); friend inline const QPoint operator-(const QPoint &, const QPoint &); - friend inline const QPoint operator*(const QPoint &, qreal); - friend inline const QPoint operator*(qreal, const QPoint &); + friend inline const QPoint operator*(const QPoint &, float); + friend inline const QPoint operator*(float, const QPoint &); + friend inline const QPoint operator*(const QPoint &, double); + friend inline const QPoint operator*(double, const QPoint &); + friend inline const QPoint operator*(const QPoint &, int); + friend inline const QPoint operator*(int, const QPoint &); friend inline const QPoint operator-(const QPoint &); friend inline const QPoint operator/(const QPoint &, qreal); @@ -141,9 +149,15 @@ inline QPoint &QPoint::operator+=(const QPoint &p) inline QPoint &QPoint::operator-=(const QPoint &p) { xp-=p.xp; yp-=p.yp; return *this; } -inline QPoint &QPoint::operator*=(qreal c) +inline QPoint &QPoint::operator*=(float c) +{ xp = qRound(xp*c); yp = qRound(yp*c); return *this; } + +inline QPoint &QPoint::operator*=(double c) { xp = qRound(xp*c); yp = qRound(yp*c); return *this; } +inline QPoint &QPoint::operator*=(int c) +{ xp = xp*c; yp = yp*c; return *this; } + inline bool operator==(const QPoint &p1, const QPoint &p2) { return p1.xp == p2.xp && p1.yp == p2.yp; } @@ -156,12 +170,24 @@ inline const QPoint operator+(const QPoint &p1, const QPoint &p2) inline const QPoint operator-(const QPoint &p1, const QPoint &p2) { return QPoint(p1.xp-p2.xp, p1.yp-p2.yp); } -inline const QPoint operator*(const QPoint &p, qreal c) +inline const QPoint operator*(const QPoint &p, float c) { return QPoint(qRound(p.xp*c), qRound(p.yp*c)); } -inline const QPoint operator*(qreal c, const QPoint &p) +inline const QPoint operator*(const QPoint &p, double c) { return QPoint(qRound(p.xp*c), qRound(p.yp*c)); } +inline const QPoint operator*(const QPoint &p, int c) +{ return QPoint(p.xp*c, p.yp*c); } + +inline const QPoint operator*(float c, const QPoint &p) +{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); } + +inline const QPoint operator*(double c, const QPoint &p) +{ return QPoint(qRound(p.xp*c), qRound(p.yp*c)); } + +inline const QPoint operator*(int c, const QPoint &p) +{ return QPoint(p.xp*c, p.yp*c); } + inline const QPoint operator-(const QPoint &p) { return QPoint(-p.xp, -p.yp); } |