QUrl: Implement a number of ## Qt5 TODOs (merging overloads)
authorDavid Faure <faure@kde.org>
Wed, 25 Jan 2012 17:03:37 +0000 (18:03 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 26 Jan 2012 14:23:36 +0000 (15:23 +0100)
Change-Id: I629c20f10e3667937d488ea30f93bf86f980ee1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/io/qurl.cpp
src/corelib/io/qurl.h

index 9856d5d..b9430c6 100644 (file)
@@ -4179,6 +4179,8 @@ QString QUrlPrivate::createErrorString()
     readable representation, with no percent encoding. QUrl will automatically
     percent encode all characters that are not allowed in a URL.
 
+    The parsing mode \a parsingMode is used for parsing \a url.
+
     Example:
 
     \snippet doc/src/snippets/code/src_corelib_io_qurl.cpp 0
@@ -4189,19 +4191,6 @@ QString QUrlPrivate::createErrorString()
 
     \sa setUrl(), setEncodedUrl(), fromEncoded(), TolerantMode
 */
-QUrl::QUrl(const QString &url) : d(0)
-{
-    if (!url.isEmpty())
-        setUrl(url);
-}
-
-/*!
-    \overload
-
-    Parses the \a url using the parser mode \a parsingMode.
-
-    \sa setUrl()
-*/
 QUrl::QUrl(const QString &url, ParsingMode parsingMode) : d(0)
 {
     if (!url.isEmpty())
@@ -4294,23 +4283,13 @@ void QUrl::clear()
     \a url is assumed to be in unicode format, with no percent
     encoding.
 
+    The parsing mode \a parsingMode is used for parsing \a url.
+
     Calling isValid() will tell whether or not a valid URL was
     constructed.
 
     \sa setEncodedUrl()
 */
-void QUrl::setUrl(const QString &url)
-{
-    setUrl(url, TolerantMode);
-}
-
-/*!
-    \overload
-
-    Parses \a url using the parsing mode \a parsingMode.
-
-    \sa setEncodedUrl()
-*/
 void QUrl::setUrl(const QString &url, ParsingMode parsingMode)
 {
     detach();
@@ -4353,21 +4332,6 @@ void QUrl::setUrl(const QString &url, ParsingMode parsingMode)
     setEncodedUrl(encodedUrl, StrictMode);
 }
 
-/*!
-    Constructs a URL by parsing the contents of \a encodedUrl.
-
-    \a encodedUrl is assumed to be a URL string in percent encoded
-    form, containing only ASCII characters.
-
-    Use isValid() to determine if a valid URL was constructed.
-
-    \sa setUrl()
-*/
-void QUrl::setEncodedUrl(const QByteArray &encodedUrl)
-{
-    setEncodedUrl(encodedUrl, TolerantMode);
-}
-
 inline static bool isHex(char c)
 {
     c |= 0x20;
@@ -4380,8 +4344,16 @@ static inline char toHex(quint8 c)
 }
 
 /*!
-    Constructs a URL by parsing the contents of \a encodedUrl using
-    the given \a parsingMode.
+    Constructs a URL by parsing the contents of \a encodedUrl.
+
+    \a encodedUrl is assumed to be a URL string in percent encoded
+    form, containing only ASCII characters.
+
+    The parsing mode \a parsingMode is used for parsing \a encodedUrl.
+
+    Use isValid() to determine if a valid URL was constructed.
+
+    \sa setUrl()
 */
 void QUrl::setEncodedUrl(const QByteArray &encodedUrl, ParsingMode parsingMode)
 {
@@ -4808,18 +4780,6 @@ void QUrl::setPort(int port)
 }
 
 /*!
-    Returns the port of the URL, or -1 if the port is unspecified.
-*/
-int QUrl::port() const
-{
-    if (!d) return -1;
-    if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();
-    if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Validated)) d->validate();
-    return d->port;
-}
-
-/*!
-    \overload
     \since 4.1
 
     Returns the port of the URL, or \a defaultPort if the port is
@@ -5701,6 +5661,8 @@ bool QUrl::isRelative() const
     URL. The output can be customized by passing flags with \a
     options.
 
+    The resulting QString can be passed back to a QUrl later on.
+
     \sa FormattingOptions, toEncoded()
 */
 QString QUrl::toString(FormattingOptions options) const
@@ -5765,21 +5727,7 @@ QByteArray QUrl::toEncoded(FormattingOptions options) const
     Parses \a input and returns the corresponding QUrl. \a input is
     assumed to be in encoded form, containing only ASCII characters.
 
-    The URL is parsed using TolerantMode.
-
-    \sa toEncoded(), setUrl()
-*/
-QUrl QUrl::fromEncoded(const QByteArray &input)
-{
-    QUrl tmp;
-    tmp.setEncodedUrl(input, TolerantMode);
-    return tmp;
-}
-
-/*!
-    \overload
-
-    Parses the URL using \a parsingMode.
+    The URL is parsed using \a parsingMode.
 
     \sa toEncoded(), setUrl()
 */
index a47272c..cc56a90 100644 (file)
@@ -85,9 +85,7 @@ public:
 #ifdef QT_NO_URL_CAST_FROM_STRING
     explicit
 #endif
-    QUrl(const QString &url);
-    QUrl(const QString &url, ParsingMode mode);
-    // ### Qt 5: merge the two constructors, with mode = TolerantMode
+    QUrl(const QString &url, ParsingMode mode = TolerantMode);
     QUrl(const QUrl &copy);
     QUrl &operator =(const QUrl &copy);
 #ifndef QT_NO_URL_CAST_FROM_STRING
@@ -101,12 +99,8 @@ public:
 
     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
-    void setEncodedUrl(const QByteArray &url);
-    void setEncodedUrl(const QByteArray &url, ParsingMode mode);
-    // ### Qt 5: merge the two setEncodedUrl() functions, with mode = TolerantMode
+    void setUrl(const QString &url, ParsingMode mode = TolerantMode);
+    void setEncodedUrl(const QByteArray &url, ParsingMode mode = TolerantMode);
 
     bool isValid() const;
 
@@ -139,9 +133,7 @@ public:
     QByteArray encodedHost() const;
 
     void setPort(int port);
-    int port() const;
-    int port(int defaultPort) const;
-    // ### Qt 5: merge the two port() functions, with defaultPort = -1
+    int port(int defaultPort = -1) const;
 
     void setPath(const QString &path);
     QString path() const;
@@ -196,9 +188,7 @@ public:
     QString toString(FormattingOptions options = None) const;
 
     QByteArray toEncoded(FormattingOptions options = None) const;
-    static QUrl fromEncoded(const QByteArray &url);
-    static QUrl fromEncoded(const QByteArray &url, ParsingMode mode);
-    // ### Qt 5: merge the two fromEncoded() functions, with mode = TolerantMode
+    static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
 
     static QUrl fromUserInput(const QString &userInput);