summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2010-11-02 14:20:38 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-11-03 10:50:48 (GMT)
commit86ea8521c6f145be24c40c799b6b4e8f6e854e2b (patch)
treebbceb07abeb3f8b974287ea648fd995b4ba8345c /src
parentd12681a4cf1227d0e92fc7cf12aa3977e6ffe3fe (diff)
downloadQt-86ea8521c6f145be24c40c799b6b4e8f6e854e2b.zip
Qt-86ea8521c6f145be24c40c799b6b4e8f6e854e2b.tar.gz
Qt-86ea8521c6f145be24c40c799b6b4e8f6e854e2b.tar.bz2
Add member-swap to shared datatypes that don't have it.
For consistency. Merge-request: 871 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qurl.cpp8
-rw-r--r--src/corelib/io/qurl.h2
-rw-r--r--src/corelib/kernel/qvariant.cpp8
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/tools/qhash.cpp1
-rw-r--r--src/corelib/tools/qmap.cpp1
-rw-r--r--src/corelib/tools/qregexp.cpp8
-rw-r--r--src/corelib/tools/qregexp.h1
-rw-r--r--src/gui/image/qbitmap.cpp8
-rw-r--r--src/gui/image/qbitmap.h1
-rw-r--r--src/gui/image/qicon.cpp8
-rw-r--r--src/gui/image/qicon.h2
-rw-r--r--src/gui/image/qimage.cpp8
-rw-r--r--src/gui/image/qimage.h1
-rw-r--r--src/gui/image/qpicture.cpp8
-rw-r--r--src/gui/image/qpicture.h1
-rw-r--r--src/gui/image/qpixmap.cpp8
-rw-r--r--src/gui/image/qpixmap.h2
-rw-r--r--src/gui/kernel/qkeysequence.cpp8
-rw-r--r--src/gui/kernel/qkeysequence.h1
-rw-r--r--src/gui/painting/qbrush.cpp9
-rw-r--r--src/gui/painting/qbrush.h2
-rw-r--r--src/gui/painting/qpainterpath.cpp8
-rw-r--r--src/gui/painting/qpainterpath.h1
-rw-r--r--src/gui/painting/qpen.cpp8
-rw-r--r--src/gui/painting/qpen.h1
-rw-r--r--src/gui/painting/qpolygon.cpp2
-rw-r--r--src/gui/painting/qregion.cpp8
-rw-r--r--src/gui/painting/qregion.h1
29 files changed, 127 insertions, 0 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 6452c0f..6ec5562 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -6048,6 +6048,14 @@ QUrl &QUrl::operator =(const QString &url)
return *this;
}
+/*!
+ \fn void QUrl::swap(QUrl &other)
+ \since 4.8
+
+ Swaps URL \a other with this URL. This operation is very
+ fast and never fails.
+*/
+
/*! \internal
Forces a detach.
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 563be5f..63fe98d 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -100,6 +100,8 @@ public:
#endif
~QUrl();
+ inline void swap(QUrl &other) { qSwap(d, other.d); }
+
void setUrl(const QString &url);
void setUrl(const QString &url, ParsingMode mode);
// ### Qt 5: merge the two setUrl() functions, with mode = TolerantMode
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index feb85ce..aa070f1 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1808,6 +1808,14 @@ QVariant& QVariant::operator=(const QVariant &variant)
}
/*!
+ \fn void QVariant::swap(QVariant &other)
+ \since 4.8
+
+ Swaps variant \a other with this variant. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn void QVariant::detach()
\internal
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index b267954..611db8b 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -224,6 +224,8 @@ class Q_CORE_EXPORT QVariant
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QVariant &other) { qSwap(d, other.d); }
+
Type type() const;
int userType() const;
const char *typeName() const;
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 5a8057d..3dc9c92 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -738,6 +738,7 @@ void QHashData::checkSanity()
*/
/*! \fn void QMultiHash::swap(QMultiHash<Key, T> &other)
+ \since 4.8
Swaps hash \a other with this hash. This operation is very
fast and never fails.
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 7b814b3..5a5fffd 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -412,6 +412,7 @@ void QMapData::dump()
*/
/*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other)
+ \since 4.8
Swaps map \a other with this map. This operation is very
fast and never fails.
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 7a26c4f..5d2a0e3 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -3858,6 +3858,14 @@ QRegExp &QRegExp::operator=(const QRegExp &rx)
}
/*!
+ \fn void QRegExp::swap(QRegExp &other)
+ \since 4.8
+
+ Swaps regular expression \a other with this regular
+ expression. This operation is very fast and never fails.
+*/
+
+/*!
Returns true if this regular expression is equal to \a rx;
otherwise returns false.
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 0b4a702..4a74f90 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -80,6 +80,7 @@ public:
inline QRegExp &operator=(QRegExp &&other)
{ qSwap(priv,other.priv); return *this; }
#endif
+ inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
bool operator==(const QRegExp &rx) const;
inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 91622f3..9d90b3f 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -227,6 +227,14 @@ QBitmap::~QBitmap()
}
/*!
+ \fn void QBitmap::swap(QBitmap &other)
+ \since 4.8
+
+ Swaps bitmap \a other with this bitmap. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the bitmap as a QVariant.
*/
QBitmap::operator QVariant() const
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index 1bbe1cf..93be951 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -63,6 +63,7 @@ public:
~QBitmap();
QBitmap &operator=(const QPixmap &);
+ inline void swap(QBitmap &other) { QPixmap::swap(other); } // prevent QBitmap<->QPixmap swaps
operator QVariant() const;
inline void clear() { fill(Qt::color0); }
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index a2f429a..e54bb5f 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -613,6 +613,14 @@ QIcon &QIcon::operator=(const QIcon &other)
}
/*!
+ \fn void QIcon::swap(QIcon &other)
+ \since 4.8
+
+ Swaps icon \a other with this icon. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the icon as a QVariant.
*/
QIcon::operator QVariant() const
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index fd591e6..5091d03 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -75,6 +75,8 @@ public:
inline QIcon &operator=(QIcon &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QIcon &other) { qSwap(d, other.d); }
+
operator QVariant() const;
QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 5829fe8..d86021cb9 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -1329,6 +1329,14 @@ QImage &QImage::operator=(const QImage &image)
}
/*!
+ \fn void QImage::swap(QImage &other)
+ \since 4.8
+
+ Swaps image \a other with this image. This operation is very
+ fast and never fails.
+*/
+
+/*!
\internal
*/
int QImage::devType() const
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 003daea..c6a947e 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -144,6 +144,7 @@ public:
inline QImage &operator=(QImage &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QImage &other) { qSwap(d, other.d); }
bool isNull() const;
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 48d2de3..fc81d23 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -1030,6 +1030,14 @@ QPicture& QPicture::operator=(const QPicture &p)
}
/*!
+ \fn void QPicture::swap(QPicture &other)
+ \since 4.8
+
+ Swaps picture \a other with this picture. This operation is very
+ fast and never fails.
+*/
+
+/*!
\internal
Constructs a QPicturePrivate
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index 49b0fd6..d24f23a 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -85,6 +85,7 @@ public:
inline QPicture &operator=(QPicture &&other)
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
+ inline void swap(QPicture &other) { d_ptr.swap(other.d_ptr); }
void detach();
bool isDetached() const;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 5383b7c..1b370c0 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -440,6 +440,14 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap)
}
/*!
+ \fn void QPixmap::swap(QPixmap &other)
+ \since 4.8
+
+ Swaps pixmap \a other with this pixmap. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the pixmap as a QVariant.
*/
QPixmap::operator QVariant() const
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index e9f9365..15fe5fa 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -87,6 +87,8 @@ public:
inline QPixmap &operator=(QPixmap &&other)
{ qSwap(data, other.data); return *this; }
#endif
+ inline void swap(QPixmap &other) { qSwap(data, other.data); }
+
operator QVariant() const;
bool isNull() const; // ### Qt 5: make inline
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index e14a9198..b4a360a 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1521,6 +1521,14 @@ QKeySequence &QKeySequence::operator=(const QKeySequence &other)
}
/*!
+ \fn void QKeySequence::swap(QKeySequence &other)
+ \since 4.8
+
+ Swaps key sequence \a other with this key sequence. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn bool QKeySequence::operator!=(const QKeySequence &other) const
Returns true if this key sequence is not equal to the \a other
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index b47873d..a2352eb 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -183,6 +183,7 @@ public:
inline QKeySequence &operator=(QKeySequence &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QKeySequence &other) { qSwap(d, other.d); }
bool operator==(const QKeySequence &other) const;
inline bool operator!= (const QKeySequence &other) const
{ return !(*this == other); }
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index d0788c7..5b35fc5 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -635,6 +635,15 @@ QBrush &QBrush::operator=(const QBrush &b)
return *this;
}
+
+/*!
+ \fn void QBrush::swap(QBrush &other)
+ \since 4.8
+
+ Swaps brush \a other with this brush. This operation is very
+ fast and never fails.
+*/
+
/*!
Returns the brush as a QVariant
*/
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index efc720b..f9acded 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -96,6 +96,8 @@ public:
inline QBrush &operator=(QBrush &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QBrush &other) { qSwap(d, other.d); }
+
operator QVariant() const;
inline Qt::BrushStyle style() const;
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index ffd0d5c..7d6ea12 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -576,6 +576,14 @@ QPainterPath &QPainterPath::operator=(const QPainterPath &other)
}
/*!
+ \fn void QPainterPath::swap(QPainterPath &other)
+ \since 4.8
+
+ Swaps painter path \a other with this painter path. This operation is very
+ fast and never fails.
+*/
+
+/*!
Destroys this QPainterPath object.
*/
QPainterPath::~QPainterPath()
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 9a7b60a..82facf8 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -100,6 +100,7 @@ public:
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
~QPainterPath();
+ inline void swap(QPainterPath &other) { d_ptr.swap(other.d_ptr); }
void closeSubpath();
diff --git a/src/gui/painting/qpen.cpp b/src/gui/painting/qpen.cpp
index 2e43984..0137763 100644
--- a/src/gui/painting/qpen.cpp
+++ b/src/gui/painting/qpen.cpp
@@ -383,6 +383,14 @@ QPen &QPen::operator=(const QPen &p)
}
/*!
+ \fn void QPen::swap(QPen &other)
+ \since 4.8
+
+ Swaps pen \a other with this pen. This operation is very
+ fast and never fails.
+*/
+
+/*!
Returns the pen as a QVariant.
*/
QPen::operator QVariant() const
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index 4006112..a7b946c 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -78,6 +78,7 @@ public:
inline QPen &operator=(QPen &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QPen &other) { qSwap(d, other.d); }
Qt::PenStyle style() const;
void setStyle(Qt::PenStyle);
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index 76b11d7..83323d0 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -709,6 +709,8 @@ QPolygon QPolygonF::toPolygon() const
/*!
\fn void QPolygonF::swap(QPolygonF &other)
+ \since 4.8
+
Swaps polygon \a other with this polygon. This operation is very
fast and never fails.
*/
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index c5d5dc9..cd997f4 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -391,6 +391,14 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt
*/
/*!
+ \fn void QRegion::swap(QRegion &other)
+ \since 4.8
+
+ Swaps region \a other with this region. This operation is very
+ fast and never fails.
+*/
+
+/*!
\relates QRegion
Writes the region \a r to the stream \a s and returns a reference
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index 91d82e0..50052b3 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -85,6 +85,7 @@ public:
inline QRegion &operator=(QRegion &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QRegion &other) { qSwap(d, other.d); }
#ifdef QT3_SUPPORT
inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
#endif