QEasingCurve: add member-swap
authorMarc Mutz <marc.mutz@kdab.com>
Sat, 18 Feb 2012 07:52:13 +0000 (08:52 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 21 Feb 2012 14:28:40 +0000 (15:28 +0100)
Implementated as in QPen etc.

Change-Id: Ia08551bf7902b60e115d1b1d2353030597e34841
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qeasingcurve.cpp
src/corelib/tools/qeasingcurve.h
tests/auto/corelib/tools/qeasingcurve/tst_qeasingcurve.cpp

index 5731faa..6f8572c 100644 (file)
@@ -1116,6 +1116,13 @@ QEasingCurve &QEasingCurve::operator=(const QEasingCurve &other)
 }
 
 /*!
+    \fn void QEasingCurve::swap(QEasingCurve &other)
+    \since 5.0
+
+    Swaps curve \a other with this curve. This operation is very
+    fast and never fails.
+
+/*!
     Compare this easing curve with \a other and returns true if they are
     equal. It will also compare the properties of a curve.
  */
index a5a7071..8b2e783 100644 (file)
@@ -83,6 +83,9 @@ public:
     ~QEasingCurve();
 
     QEasingCurve &operator=(const QEasingCurve &other);
+
+    inline void swap(QEasingCurve &other) { qSwap(d_ptr, other.d_ptr); }
+
     bool operator==(const QEasingCurve &other) const;
     inline bool operator!=(const QEasingCurve &other) const
     { return !(this->operator==(other)); }
index 0a006ab..d5d7dde 100644 (file)
@@ -445,6 +445,13 @@ void tst_QEasingCurve::setCustomType()
 
 void tst_QEasingCurve::operators()
 {
+    { // member-swap()
+        QEasingCurve ec1, ec2;
+        ec2.setCustomType(&discreteEase);
+        ec1.swap(ec2);
+        QCOMPARE(ec1.type(), QEasingCurve::Custom);
+    }
+
     // operator=
     QEasingCurve curve;
     QEasingCurve curve2;