summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-01-11 11:51:15 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-01-11 11:52:48 (GMT)
commit039387d498f4ca0125938c7c79c5aff29dab5361 (patch)
treef085a6aa3d420952d8bc9359fee43f4d176352f5 /src/corelib/io
parent64ce2950db4e140d1e65da632acbc812cabc6e03 (diff)
downloadQt-039387d498f4ca0125938c7c79c5aff29dab5361.zip
Qt-039387d498f4ca0125938c7c79c5aff29dab5361.tar.gz
Qt-039387d498f4ca0125938c7c79c5aff29dab5361.tar.bz2
Add a way to access the normalised URL in QUrl.
This is private API for now. For 4.7, decide whether to have a public method for this. Also investigate whether to provide a qHash function. Adding one to Qt would break source- and binary-compatibility with code that already has that (like Soprano). Patch-By: Warwick Allison Reviewed-by: Thiago Macieira
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qurl.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 1ba5e3f..74e5f74 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -350,8 +350,8 @@ public:
};
int stateFlags;
- QByteArray encodedNormalized;
- const QByteArray & normalized();
+ mutable QByteArray encodedNormalized;
+ const QByteArray & normalized() const;
mutable QUrlErrorInfo errorInfo;
QString createErrorString();
@@ -3850,6 +3850,9 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const
if (!QURL_HASFLAG(stateFlags, Parsed)) parse();
else ensureEncodedParts();
+ if (options==0x100) // private - see qHash(QUrl)
+ return normalized();
+
QByteArray url;
if (!(options & QUrl::RemoveScheme) && !scheme.isEmpty()) {
@@ -3920,12 +3923,13 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const
#define qToLower(ch) (((ch|32) >= 'a' && (ch|32) <= 'z') ? (ch|32) : ch)
-const QByteArray &QUrlPrivate::normalized()
+const QByteArray &QUrlPrivate::normalized() const
{
if (QURL_HASFLAG(stateFlags, QUrlPrivate::Normalized))
return encodedNormalized;
- QURL_SETFLAG(stateFlags, QUrlPrivate::Normalized);
+ QUrlPrivate *that = const_cast<QUrlPrivate *>(this);
+ QURL_SETFLAG(that->stateFlags, QUrlPrivate::Normalized);
QUrlPrivate tmp = *this;
tmp.scheme = tmp.scheme.toLower();