Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

QString QUrl::toString ( FormattingOptions  options = None  )  const

Returns the human-displayable string representation of the URL. The output can be customized by passing flags with options.

See also:
FormattingOptions, toEncoded()

Definition at line 5140 of file qurl.cpp.

References QString::at(), QString::chop(), fragment(), fromPercentEncoding(), QString::isEmpty(), path(), QString::right(), and QString::startsWith().

Referenced by QPatternist::ReportContext::codeFromURI(), Q3TextEdit::contentsMouseReleaseEvent(), QHelpEngineCore::fileData(), QHelpEngineCore::findFile(), QTextBrowser::focusNextPrevChild(), QPatternist::AnyURI::fromLexical(), QSourceLocation::qHash(), QPatternist::AnyURI::resolveURI(), BookmarksModel::setData(), and Q3TextEdit::updateCursor().

{
    if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse();

    QString url;

    if (!(options & QUrl::RemoveScheme) && !d->scheme.isEmpty())
        url += d->scheme + QLatin1Char(':');
    QString ourPath = path();
    if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority) {
        bool doFileScheme = d->scheme == QLatin1String("file") && !ourPath.isEmpty();
        QString tmp = d->authority(options);
        if (!tmp.isEmpty() || doFileScheme) {
            if (doFileScheme && !ourPath.startsWith(QLatin1Char('/')))
                url += QLatin1Char('/');
            url += QLatin1String("//");
            url += tmp;
        }
    }
    if (!(options & QUrl::RemovePath)) {
        // check if we need to insert a slash
        if ((options & QUrl::RemoveAuthority) != QUrl::RemoveAuthority
            && !d->authority(options).isEmpty() && !ourPath.isEmpty() && ourPath.at(0) != QLatin1Char('/'))
            url += QLatin1Char('/');
        url += ourPath;
        // check if we need to remove trailing slashes
        while ((options & StripTrailingSlash) && url.right(1) == QLatin1String("/"))
            url.chop(1);
    }

    if (!(options & QUrl::RemoveQuery) && d->hasQuery) {
        url += QLatin1Char('?');
        url += fromPercentEncoding(d->query);
    }
    if (!(options & QUrl::RemoveFragment) && d->hasFragment) {
        url += QLatin1Char('#');
        url += fragment();
    }

    return url;
}


Generated by  Doxygen 1.6.0   Back to index