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 );
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 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
#define IS_DRIVE_OR_DOUBLESLASH(isletter, char1, char2, colon, slash)
Definition: kurl.cpp:126
void setFileEncoding(const QString &encoding)
Adds encoding information to url by adding a "charset" parameter.
Definition: kurl.cpp:929
bool isParentOf(const KUrl &u) const
Checks whether the given URL is parent of this URL.
Definition: kurl.cpp:1909
QString directory(const DirectoryOptions &options=IgnoreTrailingSlash) const
Returns the directory of the path.
Definition: kurl.cpp:1380
QString queryItem(const QString &item) const
Returns the value of a certain query item.
Definition: kurl.cpp:1841
void ref()
Tells KGlobal about one more operations that should be finished before the application exits.
Definition: kglobal.cpp:321
bool cmp(const KUrl &u, bool ignore_trailing=false) const
The same as equals(), just with a less obvious name.
Definition: kurl.cpp:625
QString pass() const
Returns the decoded password (corresponding to user()) included in the URL.
Definition: kurl.cpp:697
static bool canDecode(const QMimeData *mimeData)
Return true if mimeData contains URI data.
Definition: kurl.cpp:299
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 setDirectory(const QString &dir)
Set the directory to dir, leaving the filename empty.
Definition: kurl.cpp:1562
QString encodedHtmlRef() const
Returns the encoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1525
@ AvoidEmptyPath
If set to true then an empty path is substituted by "/" (this is the opposite of PermitEmptyPath)
Definition: kurl.h:534
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
Returns the filename of the path.
Definition: kurl.cpp:1283
@ RemoveTrailingSlash
strips a trailing '/', except when the path is already just "/".
Definition: kurl.h:125
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
#define IS_DRIVE_OR_DOUBLESLASH_0
QString toLocalFile(AdjustPathOption trailing=LeaveTrailingSlash) const
Definition: kurl.cpp:885
void adjustPath(AdjustPathOption trailing)
Add or remove a trailing slash to/from the path.
Definition: kurl.cpp:802
static QString relativeUrl(const KUrl &base_url, const KUrl &url)
Convenience function.
Definition: kurl.cpp:1738
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
QString htmlRef() const
Returns the unencoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1514
QString fileEncoding() const
Returns encoding information from url, the content of the "charset" parameter.
Definition: kurl.cpp:958
static QString toPrettyPercentEncoding(const QString &input, bool forFragment)
Definition: kurl.cpp:1063
QMap< QString, QString > queryItems(const QueryItemsOptions &options=0) const
Returns the list of query items as a map mapping keys to values.
Definition: kurl.cpp:1808
static QString removeSlashOrFilePrefix(const QString &str)
Definition: kurl.cpp:132
#define IS_LETTER(c)
void populateMimeData(QMimeData *mimeData, const MetaDataMap &metaData=MetaDataMap(), MimeDataFlags flags=DefaultMimeDataFlags) const
Adds URL data into the given QMimeData.
Definition: kurl.cpp:1880
static QString trailingSlash(KUrl::AdjustPathOption trailing, const QString &path)
Definition: kurl.cpp:769
static QString relativePath(const QString &base_dir, const QString &path, bool *isParent=0)
Convenience function.
Definition: kurl.cpp:1724
QString encodedPathAndQuery(AdjustPathOption trailing=LeaveTrailingSlash, const EncodedPathAndQueryOptions &options=PermitEmptyPath) const
Returns the encoded path and the query.
Definition: kurl.cpp:816
static int registerArea(const QByteArray &areaName, bool enabled=true)
Definition: kdebug.cpp:856
#define IS_SLASH_AND_DRIVE_OR_DOUBLESLASH_0
static KUrl fromPath(const QString &text)
Creates a KUrl object from a QString representing an absolute path.
Definition: kurl.cpp:722
bool cd(const QString &_dir)
Changes the directory by descending into the given directory.
Definition: kurl.cpp:1420
static List split(const QString &_url)
Splits nested URLs like file:///home/weis/kde.tgz#gzip:/#tar:/kdebase A URL like http://www....
Definition: kurl.cpp:1256
bool equals(const KUrl &u, const EqualsOptions &options=0) const
Compares this url with u.
Definition: kurl.cpp:631
QString pathOrUrl() const
Return the URL as a string, which will be either the URL (as prettyUrl would return) or,...
Definition: kurl.cpp:1165
@ AppendTrailingSlash
tells whether the returned result should end with '/' or not.
Definition: kurl.h:754
void setRef(const QString &fragment)
Sets the reference/fragment part (everything after '#').
Definition: kurl.cpp:1893
static QStringList mimeDataTypes()
Return the list of mimeTypes that can be decoded by fromMimeData.
Definition: kurl.cpp:305
static QString _relativePath(const QString &base_dir, const QString &path, bool &isParent)
Definition: kurl.cpp:1688
KUrl::List is a QList that contains KUrls with a few convenience methods.
Definition: kurl.h:147
void setPass(const QString &pass)
Sets the password (corresponding to user()) included in the URL.
Definition: kurl.cpp:702
void cleanPath(const CleanPathOption &options=SimplifyDirSeparators)
Resolves "." and ".." components in path.
Definition: kurl.cpp:759
void setProtocol(const QString &proto)
Sets the protocol for the URL (i.e., file, http, etc.)
Definition: kurl.cpp:677
QString ref() const
Returns the encoded reference (or "fragment") of the URL (everything after '#').
Definition: kurl.cpp:1901
QString prettyUrl(AdjustPathOption trailing=LeaveTrailingSlash) const
Returns the URL as string in human-friendly format.
Definition: kurl.cpp:1086
QString user() const
Returns the decoded user name (login, user id, ...) included in the URL.
Definition: kurl.cpp:682
static QString cleanpath(const QString &_path, bool cleanDirSeparator, bool decodeDots)
KDE4 TODO: maybe we should use QUrl::resolved()
Definition: kurl.cpp:50
void setUser(const QString &user)
Sets the user name (login, user id, ...) included in the URL.
Definition: kurl.cpp:687
QStringList toStringList() const
Converts the URLs of this list to a list of strings.
Definition: kurl.cpp:211
void addQueryItem(const QString &_item, const QString &_value)
Add an additional query item.
Definition: kurl.cpp:1868
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
@ AllowEmptyPath
Treat a URL with no path as equal to a URL with a path of "/", when CompareWithoutTrailingSlash is se...
Definition: kurl.h:931
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 27 2020 00:00:00 by doxygen 1.8.20 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 27 2020 00:00:00 by doxygen 1.8.20 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.