Move Qt::escape to QtCore
authorDavid Faure <faure@kde.org>
Thu, 29 Sep 2011 11:31:39 +0000 (13:31 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 29 Sep 2011 13:22:07 +0000 (15:22 +0200)
Merge-request: 56
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Change-Id: I25c5f46cf53a653db26dbeb92865e61f69980bfd
Reviewed-on: http://codereview.qt-project.org/5792
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
doc/src/snippets/code/src_corelib_tools_qstring.cpp
doc/src/snippets/code/src_gui_text_qtextdocument.cpp
src/corelib/tools/qstring.cpp
src/corelib/tools/qstring.h
src/gui/text/qtextdocument.cpp
src/gui/text/qtextdocument.h

index 0cd1801..740ec54 100644 (file)
@@ -85,3 +85,10 @@ if (str == QLatin1String("auto")
 //! [6]
 QLabel *label = new QLabel(QLatin1String("MOD"), this);
 //! [6]
+
+
+//! [7]
+QString plain = "#include <QtCore>"
+QString html = Qt::escape(plain);
+// html == "#include &lt;QtCore&gt;"
+//! [7]
index 775cc0f..8165086 100644 (file)
 ****************************************************************************/
 
 //! [0]
-QString plain = "#include <QtCore>"
-QString html = Qt::escape(plain);
-// html == "#include &lt;QtCore&gt;"
-//! [0]
-
-
-//! [1]
 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>...
-//! [1]
+//! [0]
index 3a2e35c..37f8554 100644 (file)
@@ -8789,6 +8789,39 @@ QVector<uint> QStringRef::toUcs4() const
 }
 
 /*!
+    Converts the plain text string \a plain to a HTML string with
+    HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML
+    entities.
+
+    Example:
+
+    \snippet doc/src/snippets/code/src_gui_text_qtextdocument.cpp 0
+
+    This function is defined in the \c <QString> header file.
+
+    \sa convertFromPlainText(), mightBeRichText()
+*/
+QString Qt::escape(const QString &plain)
+{
+    QString rich;
+    rich.reserve(int(plain.length() * 1.1));
+    for (int i = 0; i < plain.length(); ++i) {
+        if (plain.at(i) == QLatin1Char('<'))
+            rich += QLatin1String("&lt;");
+        else if (plain.at(i) == QLatin1Char('>'))
+            rich += QLatin1String("&gt;");
+        else if (plain.at(i) == QLatin1Char('&'))
+            rich += QLatin1String("&amp;");
+        else if (plain.at(i) == QLatin1Char('"'))
+            rich += QLatin1String("&quot;");
+        else
+            rich += plain.at(i);
+    }
+    rich.squeeze();
+    return rich;
+}
+
+/*!
   \macro QStringLiteral(str)
   \relates QString
 
index 5009686..adb7e06 100644 (file)
@@ -1249,6 +1249,9 @@ inline QBool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const
 inline QBool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const
 { return QBool(indexOf(s, 0, cs) != -1); }
 
+namespace Qt {
+    Q_CORE_EXPORT QString escape(const QString &plain);
+}
 
 QT_END_NAMESPACE
 
index c1714ed..c44e98b 100644 (file)
@@ -142,38 +142,6 @@ bool Qt::mightBeRichText(const QString& text)
 }
 
 /*!
-    Converts the plain text string \a plain to a HTML string with
-    HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML
-    entities.
-
-    Example:
-
-    \snippet doc/src/snippets/code/src_gui_text_qtextdocument.cpp 0
-
-    This function is defined in the \c <QTextDocument> header file.
-
-    \sa convertFromPlainText(), mightBeRichText()
-*/
-QString Qt::escape(const QString& plain)
-{
-    QString rich;
-    rich.reserve(int(plain.length() * 1.1));
-    for (int i = 0; i < plain.length(); ++i) {
-        if (plain.at(i) == QLatin1Char('<'))
-            rich += QLatin1String("&lt;");
-        else if (plain.at(i) == QLatin1Char('>'))
-            rich += QLatin1String("&gt;");
-        else if (plain.at(i) == QLatin1Char('&'))
-            rich += QLatin1String("&amp;");
-        else if (plain.at(i) == QLatin1Char('"'))
-            rich += QLatin1String("&quot;");
-        else
-            rich += plain.at(i);
-    }
-    return rich;
-}
-
-/*!
     \fn QString Qt::convertFromPlainText(const QString &plain, WhiteSpaceMode mode)
 
     Converts the plain text string \a plain to an HTML-formatted
@@ -3002,7 +2970,7 @@ void QTextHtmlExporter::emitFrameStyle(const QTextFrameFormat &format, FrameType
     The \a encoding parameter specifies the value for the charset attribute
     in the html header. For example if 'utf-8' is specified then the
     beginning of the generated html will look like this:
-    \snippet doc/src/snippets/code/src_gui_text_qtextdocument.cpp 1
+    \snippet doc/src/snippets/code/src_gui_text_qtextdocument.cpp 0
 
     If no encoding is specified then no such meta information is generated.
 
index 363d7ab..9d9af2b 100644 (file)
@@ -84,7 +84,6 @@ namespace Qt
     };
 
     Q_GUI_EXPORT bool mightBeRichText(const QString&);
-    Q_GUI_EXPORT QString escape(const QString& plain);
     Q_GUI_EXPORT QString convertFromPlainText(const QString &plain, WhiteSpaceMode mode = WhiteSpacePre);
 
 #ifndef QT_NO_TEXTCODEC