KDECore
kurl.cpp
Go to the documentation of this file.
47 static int kurlDebugArea() { static int s_area = KDebug::registerArea("kdecore (KUrl)"); return s_area; }
138 && IS_DRIVE_OR_DOUBLESLASH(str[8].isLetter(), str[8], str[9], QLatin1Char(':'), QLatin1Char('/')) )
141 && IS_DRIVE_OR_DOUBLESLASH(str[7].isLetter(), str[7], str[8], QLatin1Char(':'), QLatin1Char('/')) )
144 && IS_DRIVE_OR_DOUBLESLASH(str[6].isLetter(), str[6], str[7], QLatin1Char(':'), QLatin1Char('/')) )
151 && IS_DRIVE_OR_DOUBLESLASH(str[1].isLetter(), str[1], str[2], QLatin1Char(':'), QLatin1Char('/')) )
154 else if ( len >= 2 && IS_DRIVE_OR_DOUBLESLASH(str[0].isLetter(), str[0], str[1], QLatin1Char(':'), QLatin1Char('/')) )
307 return QStringList() << QString::fromLatin1(s_kdeUriListMime) << QString::fromLatin1("text/uri-list");
406 kDebug(kurlDebugArea()) << "KUrl::KUrl ( const QString &str = " << str.toLatin1().data() << " )";
415 // remember the possible query using _setEncodedUrl(), then set up the correct path without query protocol part
440 ((c >= QLatin1Char('A') && c <= QLatin1Char('Z')) || (c >= QLatin1Char('a') && c <= QLatin1Char('z')))
444 ( QLatin1Char(str[0]) == QLatin1Char('/') && IS_DRIVE_OR_DOUBLESLASH(IS_LETTER(QLatin1Char(str[1])), QLatin1Char(str[1]), QLatin1Char(str[2]), QLatin1Char(':'), QLatin1Char('/')) )
448 ( IS_DRIVE_OR_DOUBLESLASH(IS_LETTER(QLatin1Char(str[0])), QLatin1Char(str[0]), QLatin1Char(str[1]), QLatin1Char(':'), QLatin1Char('/')) )
493 kDebug(kurlDebugArea()) << "KUrl::KUrl(KUrl) " << " path " << _u.path() << " toLocalFile " << _u.toLocalFile();
501 kDebug(kurlDebugArea()) << "KUrl::KUrl(Qurl) " << " path " << u.path() << " toLocalFile " << u.toLocalFile();
509 kDebug(kurlDebugArea()) << "KUrl::KUrl(KUrl,QString rel_url) " << " path " << _u.path() << " toLocalFile " << _u.toLocalFile();
638 QString path1 = path((options & CompareWithoutTrailingSlash) ? RemoveTrailingSlash : LeaveTrailingSlash);
639 QString path2 = _u.path((options & CompareWithoutTrailingSlash) ? RemoveTrailingSlash : LeaveTrailingSlash);
816 QString KUrl::encodedPathAndQuery( AdjustPathOption trailing , const EncodedPathAndQueryOptions &options) const
877 kWarning() << (isLocalFile() ? "converted to local file - the related call should be converted to toLocalFile()" : "") << QUrl::path();
893 #warning FIXME: Remove #ifdef below once upstream bug, QTBUG-20322, is fixed. Also see BR# 194746.
907 if ( url.scheme().compare(QLatin1String("file"), Qt::CaseInsensitive) != 0 || hasSubUrl( url ) )
950 args.append(QLatin1String("charset=") + QString::fromLatin1(QUrl::toPercentEncoding(encoding)));
1060 return QString::fromLatin1(toEncoded(trailing == RemoveTrailingSlash ? StripTrailingSlash : None));
1128 tmp.prepend(QLatin1Char('/')); // KUrl::path() returns toLocalFile() on windows so we need to add the / back to create a proper url
1135 else if (trailing == RemoveTrailingSlash && tmp.length() > 1 && tmp.endsWith(QLatin1Char('/')))
1180 QString KUrl::toMimeDataString() const // don't fold this into populateMimeData, it's also needed by other code like konqdrag
1691 QString _path(QDir::cleanPath(path.isEmpty() || QDir::isRelativePath(path) ? _base_dir+QLatin1Char('/')+path : path));
1756 relURL = QString::fromLatin1(QUrl::toPercentEncoding(_relativePath(basePath, url.path(), dummy), s_pathExcludeChars));
1802 result.insert( options & CaseInsensitiveKeys ? item.first.toLower() : item.first, item.second );
1848 const QStringList items = strQueryEncoded.split( QString(QLatin1Char('&')), QString::SkipEmptyParts );
1919 return qHash(kurl.protocol()) ^ qHash(kurl.path()) ^ qHash(kurl.fragment()) ^ qHash(kurl.query());
void adjustPath(AdjustPathOption trailing)
Add or remove a trailing slash to/from the path.
Definition: kurl.cpp:802
static QString cleanpath(const QString &_path, bool cleanDirSeparator, bool decodeDots)
KDE4 TODO: maybe we should use QUrl::resolved()
Definition: kurl.cpp:50
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QString & append(QChar ch)
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
Returns the directory of the path.
Definition: kurl.cpp:1380
QByteArray data(const QString &mimeType) const
strips a trailing '/', except when the path is already just "/".
Definition: kurl.h:125
static QString relativeUrl(const KUrl &base_url, const KUrl &url)
Convenience function.
Definition: kurl.cpp:1738
static List split(const QString &_url)
Splits nested URLs like file:///home/weis/kde.tgz#gzip:/#tar:/kdebase A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in http://www.kde.org and tar:/kde/README.html::ref1.
Definition: kurl.cpp:1256
void truncate(int position)
void setFragment(const QString &fragment)
static QString relativePath(const QString &base_dir, const QString &path, bool *isParent=0)
Convenience function.
Definition: kurl.cpp:1724
QString fromNativeSeparators(const QString &pathName)
QString userName() const
void setPort(int port)
const T & previous()
void populateMimeData(QMimeData *mimeData, const KUrl::MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
Adds URLs data into the given QMimeData.
Definition: kurl.cpp:248
QString fileEncoding() const
Returns encoding information from url, the content of the "charset" parameter.
Definition: kurl.cpp:958
virtual bool hasFormat(const QString &mimeType) const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
bool hasHost() const
Test to see if this URL has a hostname included in it.
Definition: kurl.cpp:712
QString & prepend(QChar ch)
QList< QPair< QString, QString > > queryItems() const
QString encodedHtmlRef() const
Returns the encoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1525
bool operator==(const QUrl &url) const
QString convertSeparators(const QString &pathName)
const T & at(int i) const
#define IS_DRIVE_OR_DOUBLESLASH(isletter, char1, char2, colon, slash)
Definition: kurl.cpp:126
bool isNull() const
QString ref() const
Returns the encoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1901
QString host() const
void cleanPath(const CleanPathOption &options=SimplifyDirSeparators)
Resolves "." and ".." components in path.
Definition: kurl.cpp:759
bool isEmpty() const
bool startsWith(const QByteArray &ba) const
#define IS_DRIVE_OR_DOUBLESLASH_0
void setRef(const QString &fragment)
Sets the reference/fragment part (everything after '#').
Definition: kurl.cpp:1893
void setPassword(const QString &password)
bool cd(const QString &_dir)
Changes the directory by descending into the given directory.
Definition: kurl.cpp:1420
static KUrl fromPath(const QString &text)
Creates a KUrl object from a QString representing an absolute path.
Definition: kurl.cpp:722
iterator erase(iterator pos)
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
Definition: kurl.cpp:885
void addQueryItem(const QString &_item, const QString &_value)
Add an additional query item.
Definition: kurl.cpp:1868
QString join(const QString &separator) const
QString & remove(int position, int n)
int port() const
static bool canDecode(const QMimeData *mimeData)
Return true if mimeData contains URI data.
Definition: kurl.cpp:299
void populateMimeData(QMimeData *mimeData, const MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
Adds URL data into the given QMimeData.
Definition: kurl.cpp:1880
QString toMimeDataString() const
Returns the URL as a string, using the standard conventions for mime data (drag-n-drop or copy-n-past...
Definition: kurl.cpp:1180
void chop(int n)
bool isParentOf(const KUrl &u) const
Checks whether the given URL is parent of this URL.
Definition: kurl.cpp:1909
bool hasPass() const
Test to see if this URL has a password included in it.
Definition: kurl.cpp:707
bool isEmpty() const
QString homePath()
void ref()
Tells KGlobal about one more operations that should be finished before the application exits...
Definition: kglobal.cpp:321
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
bool isNull() const
void clear()
void setUser(const QString &user)
Sets the user name (login, user id, ...) included in the URL.
Definition: kurl.cpp:687
void setPath(const QString &path)
Definition: kuitsemantics.cpp:82
void setProtocol(const QString &proto)
Sets the protocol for the URL (i.e., file, http, etc.)
Definition: kurl.cpp:677
QString number(int n, int base)
int count(const T &value) const
bool cmp(const KUrl &u, bool ignore_trailing=false) const
The same as equals(), just with a less obvious name.
Definition: kurl.cpp:625
void append(const KUrl &value)
QString fromUtf8(const char *str, int size)
void setUrl(const QString &url)
static KUrl::List fromMimeData(const QMimeData *mimeData, KUrl::MetaDataMap *metaData=0)
Extract a list of KUrls from the contents of mimeData.
Definition: kurl.cpp:369
static QString toPrettyPercentEncoding(const QString &input, bool forFragment)
Definition: kurl.cpp:1063
QString user() const
Returns the decoded user name (login, user id, ...) included in the URL.
Definition: kurl.cpp:682
QString protocol() const
Returns the protocol for the URL (i.e., file, http, etc.), lowercased.
Definition: kurl.cpp:672
KUrl upUrl() const
This function is useful to implement the "Up" button in a file manager for example.
Definition: kurl.cpp:1477
QString pass() const
Returns the decoded password (corresponding to user()) included in the URL.
Definition: kurl.cpp:697
bool isEmpty() const
bool isEmpty() const
const char * constData() const
QString fragment() const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
QString pathOrUrl() const
Return the URL as a string, which will be either the URL (as prettyUrl would return) or...
Definition: kurl.cpp:1165
static int registerArea(const QByteArray &areaName, bool enabled=true)
Definition: kdebug.cpp:856
void setScheme(const QString &scheme)
void setPass(const QString &pass)
Sets the password (corresponding to user()) included in the URL.
Definition: kurl.cpp:702
QString path() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
typedef Iterator
static KUrl fromMimeDataByteArray(const QByteArray &str)
Creates a KUrl from a string, using the standard conventions for mime data (drag-n-drop or copy-n-pas...
Definition: kurl.cpp:1211
bool hasUser() const
Test to see if this URL has a user name included in it.
Definition: kurl.cpp:692
void toBack()
#define IS_LETTER(c)
iterator end()
ushort unicode() const
QString fromPercentEncoding(const QByteArray &input)
QByteArray mid(int pos, int len) const
void setEncodedPath(const QByteArray &path)
QString scheme() const
QByteArray encodedFragment() const
Definition: kurl.h:673
QString authority() const
iterator begin()
QUrl & operator=(const QUrl &url)
QString htmlRef() const
Returns the unencoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1514
QString password() const
#define IS_SLASH_AND_DRIVE_OR_DOUBLESLASH_0
QString right(int n) const
QString toLocalFile() const
QByteArray & append(char ch)
iterator end()
QString toLower() const
bool isParentOf(const QUrl &childUrl) const
QByteArray toLocal8Bit() const
void decode(QString &url)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setUserName(const QString &userName)
QByteArray encodedPath() const
char toLatin1() const
bool isRelativePath(const QString &path)
QString fileName() const
static QString _relativePath(const QString &base_dir, const QString &path, bool &isParent)
Definition: kurl.cpp:1688
void setFileEncoding(const QString &encoding)
Adds encoding information to url by adding a "charset" parameter.
Definition: kurl.cpp:929
QString & replace(int position, int n, QChar after)
const QChar * unicode() const
KUrl::List is a QList that contains KUrls with a few convenience methods.
Definition: kurl.h:146
QString cleanPath(const QString &path)
static QString removeSlashOrFilePrefix(const QString &str)
Definition: kurl.cpp:132
void setEncodedQuery(const QByteArray &query)
bool hasPrevious() const
QByteArray left(int len) const
bool isValid() const
static QString trailingSlash(KUrl::AdjustPathOption trailing, const QString &path)
Definition: kurl.cpp:769
QByteArray toLatin1() const
QString encodedPathAndQuery(AdjustPathOption trailing=LeaveTrailingSlash, const EncodedPathAndQueryOptions &options=PermitEmptyPath) const
Returns the encoded path and the query.
Definition: kurl.cpp:816
QString mid(int position, int n) const
bool isRelative() const
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
Returns the filename of the path.
Definition: kurl.cpp:1283
QString rootPath()
int count() const
bool isRelative() const
const QChar at(int position) const
QByteArray encodedQuery() const
T & last()
typedef ConstIterator
QByteArray toPercentEncoding(const QString &input, const QByteArray &exclude, const QByteArray &include)
QStringList toStringList() const
Converts the URLs of this list to a list of strings.
Definition: kurl.cpp:211
void removeLast()
tells whether the returned result should end with '/' or not.
Definition: kurl.h:754
int length() const
void reserve(int size)
char * data()
QString left(int n) const
QString fromLatin1(const char *str, int size)
int indexOf(const QRegExp &rx, int from) const
static QStringList mimeDataTypes()
Return the list of mimeTypes that can be decoded by fromMimeData.
Definition: kurl.cpp:305
void setEncodedUrl(const QByteArray &encodedUrl)
iterator insert(const Key &key, const T &value)
void setDirectory(const QString &dir)
Set the directory to dir, leaving the filename empty.
Definition: kurl.cpp:1562
void setHost(const QString &host)
QString url(AdjustPathOption trailing=LeaveTrailingSlash) const
Returns the URL as string, with all escape sequences intact, encoded in a given charset.
Definition: kurl.cpp:1035
bool isEmpty() const
void setData(const QString &mimeType, const QByteArray &data)
bool hasFragment() const
If set to true then an empty path is substituted by "/" (this is the opposite of PermitEmptyPath) ...
Definition: kurl.h:534
const_iterator constEnd() const
const_iterator constBegin() const
int size() const
bool hasQuery() const
void setUserInfo(const QString &userInfo)
int compare(const QString &other) const
Treat a URL with no path as equal to a URL with a path of "/", when CompareWithoutTrailingSlash is se...
Definition: kurl.h:931
bool equals(const KUrl &u, const EqualsOptions &options=0) const
Compares this url with u.
Definition: kurl.cpp:631
iterator begin()
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
Returns the URL as string in human-friendly format.
Definition: kurl.cpp:1086
Definition: kurl.h:115
QByteArray toEncoded(QFlags< QUrl::FormattingOption > options) const
QString queryItem(const QString &item) const
Returns the value of a certain query item.
Definition: kurl.cpp:1841
QString userInfo() const
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.