QtCore: add member-swap to shared classes

Implemented as in other shared classes (e.g. QPen).

Special case:
 QUrlQuery: document existing swap().

Change-Id: I4b36cc9577fbf2232d4b2a2d8822d26e41e22cad
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marc Mutz 2012-04-05 14:49:02 +02:00 committed by Qt by Nokia
parent 02aee5d174
commit b97070f2c4
13 changed files with 67 additions and 0 deletions

View File

@ -124,6 +124,14 @@
Flushes any pending data to be written and destroys the debug stream.
*/
/*!
\fn QDebug::swap(QDebug &other)
\since 5.0
Swaps this debug stream instance with \a other. This function is
very fast and never fails.
*/
/*!
\fn QDebug &QDebug::space()

View File

@ -91,6 +91,8 @@ public:
delete stream;
}
}
inline void swap(QDebug &other) { qSwap(stream, other.stream); }
inline QDebug &space() { stream->space = true; stream->ts << ' '; return *this; }
inline QDebug &nospace() { stream->space = false; return *this; }
inline QDebug &maybeSpace() { if (stream->space) stream->ts << ' '; return *this; }

View File

@ -1710,6 +1710,14 @@ QDir &QDir::operator=(const QString &path)
return *this;
}
/*!
\fn void QDir::swap(QDir &other)
\since 5.0
Swaps this QDir instance with \a other. This function is very fast
and never fails.
*/
/*!
\fn bool QDir::operator!=(const QDir &dir) const

View File

@ -115,6 +115,9 @@ public:
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
inline void swap(QDir &other)
{ qSwap(d_ptr, other.d_ptr); }
void setPath(const QString &path);
QString path() const;
QString absolutePath() const;

View File

@ -429,6 +429,14 @@ QFileInfo &QFileInfo::operator=(const QFileInfo &fileinfo)
return *this;
}
/*!
\fn void QFileInfo::swap(QFileInfo &other)
\since 5.0
Swaps this file info with \a other. This function is very fast and
never fails.
*/
/*!
Sets the file that the QFileInfo provides information about to \a
file.

View File

@ -74,6 +74,10 @@ public:
inline QFileInfo&operator=(QFileInfo &&other)
{ qSwap(d_ptr, other.d_ptr); return *this; }
#endif
inline void swap(QFileInfo &other)
{ qSwap(d_ptr, other.d_ptr); }
bool operator==(const QFileInfo &fileinfo) const;
inline bool operator!=(const QFileInfo &fileinfo) const { return !(operator==(fileinfo)); }

View File

@ -236,6 +236,14 @@ QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &o
return *this;
}
/*!
\fn void QProcessEnvironment::swap(QProcessEnvironment &other)
\since 5.0
Swaps this process environment instance with \a other. This
function is very fast and never fails.
*/
/*!
\fn bool QProcessEnvironment::operator !=(const QProcessEnvironment &other) const

View File

@ -72,6 +72,8 @@ public:
~QProcessEnvironment();
QProcessEnvironment &operator=(const QProcessEnvironment &other);
inline void swap(QProcessEnvironment &other) { qSwap(d, other.d); }
bool operator==(const QProcessEnvironment &other) const;
inline bool operator!=(const QProcessEnvironment &other) const
{ return !(*this == other); }

View File

@ -358,6 +358,13 @@ QUrlQuery &QUrlQuery::operator =(const QUrlQuery &other)
return *this;
}
/*!
\fn void QUrlQuery::swap(QUrlQuery &other)
Swaps this URL query instance with \a other. This function is very
fast and never fails.
*/
/*!
Destroys this QUrlQuery object.
*/

View File

@ -213,6 +213,13 @@ QPersistentModelIndex &QPersistentModelIndex::operator=(const QPersistentModelIn
if (d) d->ref.ref();
return *this;
}
/*!
\fn void QPersistentModelIndex::swap(QPersistentModelIndex &other)
\since 5.0
Swaps this persistent modelindex with \a other. This function is
very fast and never fails.
*/
/*!
Sets the persistent model index to refer to the same item in a model

View File

@ -116,6 +116,7 @@ public:
inline bool operator!=(const QPersistentModelIndex &other) const
{ return !operator==(other); }
QPersistentModelIndex &operator=(const QPersistentModelIndex &other);
inline void swap(QPersistentModelIndex &other) { qSwap(d, other.d); }
bool operator==(const QModelIndex &other) const;
bool operator!=(const QModelIndex &other) const;
QPersistentModelIndex &operator=(const QModelIndex &other);

View File

@ -2208,6 +2208,13 @@ QDateTime &QDateTime::operator=(const QDateTime &other)
d = other.d;
return *this;
}
/*!
\fn void QDateTime::swap(QDateTime &other)
\since 5.0
Swaps this date-time with \a other. This operation is very fast
and never fails.
*/
/*!
Returns true if both the date and the time are null; otherwise

View File

@ -210,6 +210,8 @@ public:
QDateTime &operator=(const QDateTime &other);
inline void swap(QDateTime &other) { qSwap(d, other.d); }
bool isNull() const;
bool isValid() const;