From f6f517bc5442f8c649ed18136d099d9ae1092a22 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 5 Apr 2012 14:49:02 +0200 Subject: QtGui: add member-swap to shared classes Implemented as in other shared classes (e.g. QPen). Change-Id: I5b96d4a4795870d6252aa53de6fbaedde7c0095a Reviewed-by: Gunnar Sletta --- src/gui/text/qfont.cpp | 16 ++++++++++++++++ src/gui/text/qfont.h | 3 +++ src/gui/text/qfontinfo.h | 2 ++ src/gui/text/qfontmetrics.cpp | 18 ++++++++++++++++++ src/gui/text/qfontmetrics.h | 5 +++++ src/gui/text/qglyphrun.cpp | 8 ++++++++ src/gui/text/qglyphrun.h | 2 ++ src/gui/text/qrawfont.cpp | 8 ++++++++ src/gui/text/qrawfont.h | 2 ++ src/gui/text/qstatictext.cpp | 8 ++++++++ src/gui/text/qstatictext.h | 2 ++ src/gui/text/qtextcursor.cpp | 8 ++++++++ src/gui/text/qtextcursor.h | 2 ++ src/gui/text/qtextformat.cpp | 8 ++++++++ src/gui/text/qtextformat.h | 3 +++ 15 files changed, 95 insertions(+) (limited to 'src/gui/text') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 2144930f70..5fc98cdf04 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -738,6 +738,14 @@ QFont &QFont::operator=(const QFont &font) return *this; } +/*! + \fn void QFont::swap(QFont &other) + \since 5.0 + + Swaps this font instance with \a other. This function is very fast + and never fails. +*/ + /*! Returns the requested font family name, i.e. the name set in the constructor or the last setFont() call. @@ -2293,6 +2301,14 @@ QFontInfo &QFontInfo::operator=(const QFontInfo &fi) return *this; } +/*! + \fn void QFontInfo::swap(QFontInfo &other) + \since 5.0 + + Swaps this font info instance with \a other. This function is very + fast and never fails. +*/ + /*! Returns the family name of the matched window system font. diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 5e2fd5227b..38086a989d 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -161,6 +161,9 @@ public: QFont(const QFont &); ~QFont(); + void swap(QFont &other) + { qSwap(d, other.d); qSwap(resolve_mask, other.resolve_mask); } + QString family() const; void setFamily(const QString &); diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h index edaed281fe..c0c478f0c2 100644 --- a/src/gui/text/qfontinfo.h +++ b/src/gui/text/qfontinfo.h @@ -59,6 +59,8 @@ public: QFontInfo &operator=(const QFontInfo &); + void swap(QFontInfo &other) { qSwap(d, other.d); } + QString family() const; QString styleName() const; int pixelSize() const; diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 22b9038524..41e561bf7a 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -213,6 +213,14 @@ QFontMetrics &QFontMetrics::operator=(const QFontMetrics &fm) return *this; } +/*! + \fn void QFontMetrics::swap(QFontMetrics &other) + \since 5.0 + + Swaps this font metrics instance with \a other. This function is + very fast and never fails. +*/ + /*! Returns true if \a other is equal to this object; otherwise returns false. @@ -1004,6 +1012,16 @@ QFontMetricsF &QFontMetricsF::operator=(const QFontMetrics &other) return *this; } +/*! + \fn void QFontMetricsF::swap(QFontMetricsF &other) + \since 5.0 + + Swaps this font metrics instance with \a other. This function is + very fast and never fails. +*/ + + + /*! Constructs a font metrics object for \a font. diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index e48460ffd0..3de7011cde 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -72,6 +72,8 @@ public: { qSwap(d, other.d); return *this; } #endif + void swap(QFontMetrics &other) { qSwap(d, other.d); } + int ascent() const; int descent() const; int height() const; @@ -139,6 +141,9 @@ public: inline QFontMetricsF &operator=(QFontMetricsF &&other) { qSwap(d, other.d); return *this; } #endif + + void swap(QFontMetricsF &other) { qSwap(d, other.d); } + qreal ascent() const; qreal descent() const; qreal height() const; diff --git a/src/gui/text/qglyphrun.cpp b/src/gui/text/qglyphrun.cpp index c298893002..b3191891ae 100644 --- a/src/gui/text/qglyphrun.cpp +++ b/src/gui/text/qglyphrun.cpp @@ -152,6 +152,14 @@ QGlyphRun &QGlyphRun::operator=(const QGlyphRun &other) return *this; } +/*! + \fn void QGlyphRun::swap(QGlyphRun &other) + \since 5.0 + + Swaps this glyph run instance with \a other. This function is very + fast and never fails. +*/ + /*! Compares \a other to this QGlyphRun object. Returns true if the list of glyph indexes, the list of positions and the font are all equal, otherwise returns false. diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h index b590775d8b..8188e13e27 100644 --- a/src/gui/text/qglyphrun.h +++ b/src/gui/text/qglyphrun.h @@ -71,6 +71,8 @@ public: QGlyphRun(const QGlyphRun &other); ~QGlyphRun(); + void swap(QGlyphRun &other) { qSwap(d, other.d); } + QRawFont rawFont() const; void setRawFont(const QRawFont &rawFont); diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 468ab4e8cb..7148edf304 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -185,6 +185,14 @@ QRawFont &QRawFont::operator=(const QRawFont &other) return *this; } +/*! + \fn void QRawFont::operator=(QRawFont &other) + \since 5.0 + + Swaps this raw font with \a other. This function is very fast and + never fails. +*/ + /*! Returns true if the QRawFont is valid and false otherwise. */ diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h index 870e714340..35a17675f0 100644 --- a/src/gui/text/qrawfont.h +++ b/src/gui/text/qrawfont.h @@ -81,6 +81,8 @@ public: QRawFont &operator=(const QRawFont &other); + void swap(QRawFont &other) { qSwap(d, other.d); } + bool operator==(const QRawFont &other) const; inline bool operator!=(const QRawFont &other) const { return !operator==(other); } diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 534ba8345e..775051bc9c 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -223,6 +223,14 @@ QStaticText &QStaticText::operator=(const QStaticText &other) return *this; } +/*! + \fn void QStaticText::swap(QStaticText &other) + \since 5.0 + + Swaps this static text instance with \a other. This function is + very fast and never fails. +*/ + /*! Compares \a other to this QStaticText. Returns true if the texts, fonts and text widths are equal. diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h index a67d4ca595..6f9c9d8526 100644 --- a/src/gui/text/qstatictext.h +++ b/src/gui/text/qstatictext.h @@ -69,6 +69,8 @@ public: QStaticText(const QStaticText &other); ~QStaticText(); + void swap(QStaticText &other) { qSwap(data, other.data); } + void setText(const QString &text); QString text() const; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index 1beff17e8d..2beda0d223 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1118,6 +1118,14 @@ QTextCursor &QTextCursor::operator=(const QTextCursor &cursor) return *this; } +/*! + \fn void QTextCursor::swap(QTextCursor &other) + \since 5.0 + + Swaps this text cursor instance with \a other. This function is + very fast and never fails. +*/ + /*! Destroys the QTextCursor. */ diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index bf7c4a8787..f9441daf6d 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -79,6 +79,8 @@ public: QTextCursor &operator=(const QTextCursor &other); ~QTextCursor(); + void swap(QTextCursor &other) { qSwap(d, other.d); } + bool isNull() const; enum MoveMode { diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index d8c7a4c52f..4dd7b285c9 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -795,6 +795,14 @@ QTextFormat &QTextFormat::operator=(const QTextFormat &rhs) return *this; } +/*! + \fn void QTextFormat::swap(QTextFormat &other) + \since 5.0 + + Swaps this text format with \a other. This function is very fast + and never fails. +*/ + /*! Destroys this text format. */ diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h index 6843995124..58525a3dd0 100644 --- a/src/gui/text/qtextformat.h +++ b/src/gui/text/qtextformat.h @@ -291,6 +291,9 @@ public: QTextFormat &operator=(const QTextFormat &rhs); ~QTextFormat(); + void swap(QTextFormat &other) + { qSwap(d, other.d); qSwap(format_type, other.format_type); } + void merge(const QTextFormat &other); inline bool isValid() const { return type() != InvalidFormat; } -- cgit v1.2.3