File indexing completed on 2024-10-06 12:18:00
0001 /* This file is part of the KDE libraries 0002 * Copyright (C) 1999 Torben Weis <weis@kde.org> 0003 * Copyright (C) 2005-2006 David Faure <faure@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef kurl_h 0022 #define kurl_h 0023 0024 #include <kdelibs4support_export.h> 0025 0026 #ifdef KDELIBS4SUPPORT_NO_DEPRECATED_NOISE 0027 #warning "This file is deprecated." 0028 #endif 0029 0030 #include <QVariant> 0031 #include <QUrl> 0032 #include <QMap> 0033 0034 class QStringList; 0035 class QMimeData; 0036 0037 class KUrlPrivate; 0038 0039 /** 0040 * \class KUrl kurl.h <KUrl> 0041 * 0042 * Represents and parses a URL. 0043 * 0044 * A prototypical URL looks like: 0045 * \code 0046 * protocol://user:password\@hostname:port/path/to/file.ext#reference 0047 * \endcode 0048 * 0049 * KUrl handles escaping of URLs. This means that the specification 0050 * of a full URL will differ from the corresponding string that would specify a 0051 * local file or directory in file-operations like fopen. This is because an URL 0052 * doesn't allow certain characters and escapes them. (e.g. '#'->"%23", space->"%20") 0053 * (In a URL the hash-character '#' is used to specify a "reference", i.e. the position 0054 * within a document). 0055 * 0056 * The constructor KUrl(const QString&) expects a string properly escaped, 0057 * or at least non-ambiguous. 0058 * If you have the absolute path you should use KUrl::fromPath(const QString&). 0059 * \code 0060 * KUrl kurl = KUrl::fromPath("/bar/#foo#"); 0061 * QString url = kurl.url(); // -> "file:///bar/%23foo%23" 0062 * \endcode 0063 * 0064 * If you have the URL of a local file or directory and need the absolute path, 0065 * you would use toLocalFile(). 0066 * \code 0067 * KUrl url( "file:///bar/%23foo%23" ); 0068 * ... 0069 * if ( url.isLocalFile() ) 0070 * QString path = url.toLocalFile(); // -> "/bar/#foo#" 0071 * \endcode 0072 * 0073 * This must also be considered when you have separated directory and file 0074 * strings and need to put them together. 0075 * While you can simply concatenate normal path strings, you must take care if 0076 * the directory-part is already an escaped URL. 0077 * (This might be needed if the user specifies a relative path, and your 0078 * program supplies the rest from elsewhere.) 0079 * 0080 * Wrong: 0081 * \code 0082 * QString dirUrl = "file:///bar/"; 0083 * QString fileName = "#foo#"; 0084 * QString invalidURL = dirUrl + fileName; // -> "file:///bar/#foo#" won't behave like you would expect. 0085 * \endcode 0086 * Instead you should use addPath(): 0087 * Right: 0088 * \code 0089 * KUrl url( "file:///bar/" ); 0090 * QString fileName = "#foo#"; 0091 * url.addPath( fileName ); 0092 * QString validURL = url.url(); // -> "file:///bar/%23foo%23" 0093 * \endcode 0094 * 0095 * Also consider that some URLs contain the password, but this shouldn't be 0096 * visible. Your program should use prettyUrl() every time it displays a 0097 * URL, whether in the GUI or in debug output or... 0098 * 0099 * \code 0100 * KUrl url( "ftp://name:password@ftp.faraway.org/bar/%23foo%23"); 0101 * QString visibleURL = url.prettyUrl(); // -> "ftp://name@ftp.faraway.org/bar/%23foo%23" 0102 * \endcode 0103 * Note that prettyUrl() doesn't change the character escapes (like "%23"). 0104 * Otherwise the URL would be invalid and the user wouldn't be able to use it in another 0105 * context. 0106 * 0107 * @deprecated since 5.0; use QUrl directly 0108 */ 0109 class KDELIBS4SUPPORT_DEPRECATED_EXPORT_NOISE KUrl : public QUrl // krazy:exclude=dpointer,qclasses (krazy can't deal with embedded classes) 0110 { 0111 public: 0112 typedef QMap<QString, QString> MetaDataMap; 0113 enum MimeDataFlags { DefaultMimeDataFlags = 0, NoTextExport = 1 }; 0114 0115 /** 0116 * Options to be used in adjustPath 0117 */ 0118 enum AdjustPathOption { 0119 /** 0120 * strips a trailing '/', except when the path is already just "/". 0121 */ 0122 RemoveTrailingSlash, 0123 0124 /** 0125 * Do not change the path. 0126 */ 0127 LeaveTrailingSlash, 0128 0129 /** 0130 * adds a trailing '/' if there is none yet 0131 */ 0132 AddTrailingSlash 0133 }; 0134 0135 /** 0136 * \class List kurl.h <KUrl> 0137 * 0138 * KUrl::List is a QList that contains KUrls with a few 0139 * convenience methods. 0140 * @see KUrl 0141 * @see QList 0142 */ 0143 class KDELIBS4SUPPORT_DEPRECATED_EXPORT_NOISE List : public QList<KUrl> //krazy:exclude=dpointer (just some convenience methods) 0144 { 0145 public: 0146 /** 0147 * Creates an empty List. 0148 */ 0149 List() { } 0150 /** 0151 * Creates a list that contains the given URL as only 0152 * item. 0153 * @param url the url to add. 0154 */ 0155 List(const KUrl &url); 0156 /** 0157 * Creates a list that contains the URLs from the given 0158 * list of strings. 0159 * @param list the list containing the URLs as strings 0160 */ 0161 List(const QStringList &list); 0162 /** 0163 * Creates a list that contains the URLs from the given QList<KUrl>. 0164 * @param list the list containing the URLs 0165 */ 0166 List(const QList<KUrl> &list); 0167 /** 0168 * Creates a list that contains the URLs from the given QList<KUrl>. 0169 * @param list the list containing the URLs 0170 * @since 4.7 0171 */ 0172 List(const QList<QUrl> &list); 0173 /** 0174 * Converts the URLs of this list to a list of strings. 0175 * @return the list of strings 0176 */ 0177 QStringList toStringList() const; 0178 0179 /** 0180 * Converts the URLs of this list to a list of strings. 0181 * 0182 * @param trailing use to add or remove a trailing slash to/from the path. 0183 * 0184 * @return the list of strings 0185 * 0186 * @since 4.6 0187 */ 0188 QStringList toStringList(KUrl::AdjustPathOption trailing) const; 0189 0190 /** 0191 * Converts this KUrl::List to a QVariant, this allows to use KUrl::List 0192 * in QVariant() constructor 0193 */ 0194 operator QVariant() const; 0195 0196 /** 0197 * Converts this KUrl::List into a list of QUrl instances. 0198 * @since 4.7 0199 */ 0200 operator QList<QUrl>() const; 0201 0202 /** 0203 * Adds URLs data into the given QMimeData. 0204 * 0205 * By default, populateMimeData also exports the URLs as plain text, for e.g. dropping 0206 * onto a text editor. 0207 * But in some cases this might not be wanted, e.g. if adding other mime data 0208 * which provides better plain text data. 0209 * 0210 * WARNING: do not call this method multiple times on the same mimedata object, 0211 * you can add urls only once. But you can add other things, e.g. images, XML... 0212 * 0213 * @param mimeData the QMimeData instance used to drag or copy this URL 0214 * @param metaData KIO metadata shipped in the mime data, which is used for instance to 0215 * set a correct HTTP referrer (some websites require it for downloading e.g. an image) 0216 * @param flags set NoTextExport to prevent setting plain/text data into @p mimeData 0217 * 0218 * @deprecated since 5.0, use QMimeData::setUrls, followed by KUrlMimeData::setMetaData if you have metadata. 0219 */ 0220 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0221 KDELIBS4SUPPORT_DEPRECATED void populateMimeData(QMimeData *mimeData, 0222 const KUrl::MetaDataMap &metaData = MetaDataMap(), 0223 MimeDataFlags flags = DefaultMimeDataFlags) const; 0224 #endif 0225 0226 /** 0227 * Adds URLs into the given QMimeData. 0228 * 0229 * This should add both the KDE-style URLs (eg: desktop:/foo) and 0230 * the "most local" version of the URLs (eg: 0231 * file:///home/jbloggs/Desktop/foo) to the mimedata. 0232 * 0233 * This method should be called on the KDE-style URLs. 0234 * 0235 * @code 0236 * QMimeData* mimeData = new QMimeData(); 0237 * 0238 * KUrl::List kdeUrls; 0239 * kdeUrls << "desktop:/foo"; 0240 * kdeUrls << "desktop:/bar"; 0241 * 0242 * KUrl::List normalUrls; 0243 * normalUrls << "file:///home/jbloggs/Desktop/foo"; 0244 * normalUrls << "file:///home/jbloggs/Desktop/bar"; 0245 * 0246 * kdeUrls.populateMimeData(normalUrls, mimeData); 0247 * @endcode 0248 * 0249 * @param mostLocalUrls the "most local" urls 0250 * @param mimeData the mime data object to populate 0251 * @param metaData KIO metadata shipped in the mime data, which is 0252 * used for instance to set a correct HTTP referrer 0253 * (some websites require it for downloading e.g. an 0254 * image) 0255 * @param flags set NoTextExport to prevent setting plain/text 0256 * data into @p mimeData. 0257 * @since 4.2 0258 * @deprecated since 5.0, use KUrlMimeData::setUrls, followed by KUrlMimeData::setMetaData if you have metadata. 0259 */ 0260 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0261 KDELIBS4SUPPORT_DEPRECATED void populateMimeData(const KUrl::List &mostLocalUrls, 0262 QMimeData *mimeData, 0263 const KUrl::MetaDataMap &metaData = MetaDataMap(), 0264 MimeDataFlags flags = DefaultMimeDataFlags) const; 0265 #endif 0266 0267 /** 0268 * Return true if @p mimeData contains URI data 0269 * @deprecated since 5.0, use QMimeData::hasUrls 0270 */ 0271 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0272 KDELIBS4SUPPORT_DEPRECATED static bool canDecode(const QMimeData *mimeData); 0273 #endif 0274 0275 /** 0276 * Return the list of mimeTypes that can be decoded by fromMimeData 0277 * @deprecated since 5.0, use KUrlMimeData::mimeDataTypes 0278 */ 0279 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0280 KDELIBS4SUPPORT_DEPRECATED static QStringList mimeDataTypes(); 0281 #endif 0282 0283 /** 0284 * Flags to be used in fromMimeData. 0285 * @since 4.2.3 0286 * @deprecated since 5.0, use KUrlMimeData 0287 */ 0288 enum DecodeOptions { 0289 /** 0290 * When the mimedata contains both KDE-style URLs (eg: desktop:/foo) and 0291 * the "most local" version of the URLs (eg: file:///home/dfaure/Desktop/foo), 0292 * decode it as local urls. Useful in paste/drop operations that end up calling KIO, 0293 * so that urls from other users work as well. 0294 */ 0295 PreferLocalUrls, 0296 /** 0297 * When the mimedata contains both KDE-style URLs (eg: desktop:/foo) and 0298 * the "most local" version of the URLs (eg: file:///home/dfaure/Desktop/foo), 0299 * decode it as the KDE-style URL. Useful in DnD code e.g. when moving icons, 0300 * and the kde-style url is used as identifier for the icons. 0301 */ 0302 PreferKdeUrls 0303 }; 0304 0305 /** 0306 * Extract a list of KUrls from the contents of @p mimeData. 0307 * Decoding will fail if @p mimeData does not contain any URLs, or if at 0308 * least one extracted URL is not valid. 0309 * @param mimeData the mime data to extract from; cannot be 0 0310 * @param decodeOptions options for decoding 0311 * @param metaData optional pointer to a map holding the metadata 0312 * @return the list of urls 0313 * @since 4.2.3 0314 * @deprecated since 5.0, use KUrlMimeData::urlsFromMimeData 0315 */ 0316 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0317 KDELIBS4SUPPORT_DEPRECATED static KUrl::List fromMimeData(const QMimeData *mimeData, 0318 DecodeOptions decodeOptions = PreferKdeUrls, 0319 KUrl::MetaDataMap *metaData = nullptr); 0320 #endif 0321 }; 0322 /** 0323 * Constructs an empty URL. 0324 */ 0325 KUrl(); 0326 0327 /** 0328 * Destructs the KUrl object. 0329 */ 0330 ~KUrl(); 0331 0332 /** 0333 * Usual constructor, to construct from a string. 0334 * @param urlOrPath An encoded URL or a path. 0335 * 0336 * @deprecated since 5.0, use QUrl(str) if it's a URL, QUrl::fromLocalFile(str) if it's a local path, 0337 * and QUrl::fromUserInput() if it could be either. 0338 */ 0339 KUrl(const QString &urlOrPath); 0340 /** 0341 * Constructor taking a char * @p urlOrPath, which is an _encoded_ representation 0342 * of the URL, exactly like the usual constructor. This is useful when 0343 * the URL, in its encoded form, is strictly ascii. 0344 * @param urlOrPath An encoded URL, or a path. 0345 * 0346 * @deprecated since 5.0, use QUrl(str) if it's a URL, QUrl::fromLocalFile(str) if it's a local path, 0347 * and QUrl::fromUserInput() if it could be either. 0348 */ 0349 KDELIBS4SUPPORT_DEPRECATED explicit KUrl(const char *urlOrPath); 0350 /** 0351 * Constructor taking a QByteArray @p urlOrPath, which is an _encoded_ representation 0352 * of the URL, exactly like the usual constructor. This is useful when 0353 * the URL, in its encoded form, is strictly ascii. 0354 * @param urlOrPath An encoded URL, or a path. 0355 * 0356 * @deprecated since 5.0, use QUrl(str) if it's a URL, QUrl::fromLocalFile(str) if it's a local path, 0357 * and QUrl::fromUserInput() if it could be either. 0358 */ 0359 KDELIBS4SUPPORT_DEPRECATED explicit KUrl(const QByteArray &urlOrPath); 0360 0361 /** 0362 * Copy constructor. 0363 * @param u the KUrl to copy 0364 */ 0365 KUrl(const KUrl &u); 0366 /** 0367 * Converts from a QUrl. 0368 * @param u the QUrl 0369 */ 0370 KUrl(const QUrl &u); //krazy:exclude=qclasses 0371 /** 0372 * Constructor allowing relative URLs. 0373 * 0374 * @param _baseurl The base url. 0375 * @param _rel_url A relative or absolute URL. 0376 * If this is an absolute URL then @p _baseurl will be ignored. 0377 * If this is a relative URL it will be combined with @p _baseurl. 0378 * Note that _rel_url should be encoded too, in any case. 0379 * So do NOT pass a path here (use setPath or addPath instead). 0380 * 0381 * @deprecated since 5.0, use QUrl(_baseurl).resolved(QUrl(_rel_url)) 0382 */ 0383 KUrl(const KUrl &_baseurl, const QString &_rel_url); 0384 0385 /** 0386 * Returns the protocol for the URL (i.e., file, http, etc.), lowercased. 0387 * @deprecated since 5.0, use QUrl::scheme() instead 0388 */ 0389 QString protocol() const; 0390 0391 /** 0392 * @deprecated since 5.0, use QUrl::setScheme() instead 0393 */ 0394 void setProtocol(const QString &proto); 0395 0396 /** 0397 * @deprecated since 5.0, use QUrl::userName() instead 0398 */ 0399 QString user() const; 0400 0401 /** 0402 * @deprecated since 5.0, use QUrl::setUserName() instead 0403 */ 0404 void setUser(const QString &user); 0405 0406 /** 0407 * @deprecated since 5.0, use QUrl::userName() and QString::isEmpty() instead 0408 */ 0409 bool hasUser() const; 0410 0411 /** 0412 * @deprecated since 5.0, use QUrl::password() instead 0413 **/ 0414 QString pass() const; 0415 0416 /** 0417 * @deprecated since 5.0, use QUrl::setPassword() instead 0418 **/ 0419 void setPass(const QString &pass); 0420 0421 /** 0422 * @deprecated since 5.0, use QUrl::password() and QString::isEmpty() instead 0423 **/ 0424 bool hasPass() const; 0425 0426 /** 0427 * @deprecated since 5.0, use QUrl::host() and QString::isEmpty() instead 0428 **/ 0429 bool hasHost() const; 0430 0431 /** 0432 * @param trailing use to add or remove a trailing slash to/from the path. see adjustPath 0433 0434 * @return The current decoded path. This does not include the query. Can 0435 * be QString() if no path is set. 0436 * 0437 * @deprecated since 5.0, use OUrl::toLocalFile() for local file urls and 0438 * QUrl::path() for all other cases. You may use QUrl::isLocalFile() to decide 0439 * which method to choose. If RemoveTrailingSlash was used, use 0440 * url.adjusted(QUrl::StripTrailingSlash).path(). 0441 */ 0442 QString path(AdjustPathOption trailing = LeaveTrailingSlash) const; 0443 0444 /** 0445 * @param trailing use to add or remove a trailing slash to/from the local path. see adjustPath 0446 * 0447 * @return The current local path. Can 0448 * be QString() if no path is set. 0449 * 0450 * @deprecated since 5.0, use QUrl::toLocalFile() instead; if 0451 * RemoveTrailingSlash was used, use 0452 * url.adjusted(QUrl::StripTrailingSlash).toLocalFile() 0453 */ 0454 QString toLocalFile(AdjustPathOption trailing = LeaveTrailingSlash) const; 0455 0456 /** 0457 * KUrl's setPath on an empty url implies the "file" protocol. 0458 * @deprecated since 5.0, use QUrl::fromLocalFile instead, for the case of local paths. 0459 * Do not port to QUrl u; u.setPath(...); since that would lead to a URL without a scheme! 0460 */ 0461 KDELIBS4SUPPORT_DEPRECATED void setPath(const QString &path); 0462 0463 /** 0464 * @deprecated since 5.0, use QUrl::path() and QString::isEmpty() 0465 **/ 0466 bool hasPath() const; 0467 0468 /** 0469 * Options to be used in cleanPath 0470 */ 0471 enum CleanPathOption { 0472 /** 0473 * if set, occurrences of consecutive directory separators 0474 * (e.g. /foo//bar) are cleaned up as well. (set by default) 0475 */ 0476 SimplifyDirSeparators = 0x00, 0477 0478 /** 0479 * The opposite of SimplifyDirSeparators. 0480 */ 0481 KeepDirSeparators = 0x01 0482 }; 0483 0484 Q_DECLARE_FLAGS(CleanPathOptions, CleanPathOption) 0485 0486 /** 0487 * Resolves "." and ".." components in path. 0488 * Some servers seem not to like the removal of extra '/' 0489 * even though it is against the specification in RFC 2396. 0490 * 0491 * @param options use KeepDirSeparators if you don't want to remove consecutive 0492 * occurrences of directory separator 0493 * @deprecated since 5.0, use url.setPath(QDir::cleanPath(url.path())) in file-management code. 0494 * No replacement available yet for the old HTTP issue mentionned above. 0495 */ 0496 void cleanPath(const CleanPathOption &options = SimplifyDirSeparators); 0497 0498 /** 0499 * Add or remove a trailing slash to/from the path. 0500 * 0501 * If the URL has no path, then no '/' is added 0502 * anyway. And on the other side: If the path is "/", then this 0503 * character won't be stripped. Reason: "ftp://weis\@host" means something 0504 * completely different than "ftp://weis\@host/". So adding or stripping 0505 * the '/' would really alter the URL, while "ftp://host/path" and 0506 * "ftp://host/path/" mean the same directory. 0507 * 0508 * @param trailing RemoveTrailingSlash strips any trailing '/' and 0509 * AddTrailingSlash adds a trailing '/' if there is none yet 0510 * @deprecated For RemoveTrailingSlash, use url = url.adjusted(QUrl::StripTrailingSlash) (remember 0511 * to add the assignment!). For AppendTrailingSlash, use: 0512 * if (!url.path().endsWith('/')) url.setPath(url.path() + '/'). 0513 */ 0514 void adjustPath(AdjustPathOption trailing); 0515 0516 /** 0517 * This is useful for HTTP. It looks first for '?' and decodes then. 0518 * The encoded path is the concatenation of the current path and the query. 0519 * @param _txt the new path and query. 0520 * 0521 * @deprecated since 5.0, use QUrl::setPath() and 0522 * QUrl::fromPercentEncoding() to set the encoded path; use QUrl::setQuery() 0523 * with an appropriate QUrl::ParsingMode value to set the query. 0524 */ 0525 void setEncodedPathAndQuery(const QString &_txt); 0526 0527 /** 0528 * Option to be used in encodedPathAndQuery 0529 **/ 0530 enum EncodedPathAndQueryOption { 0531 /** 0532 * Permit empty path (default) 0533 */ 0534 PermitEmptyPath = 0x00, 0535 /** 0536 * If set to true then an empty path is substituted by "/" 0537 * (this is the opposite of PermitEmptyPath) 0538 */ 0539 AvoidEmptyPath = 0x01 0540 }; 0541 Q_DECLARE_FLAGS(EncodedPathAndQueryOptions, EncodedPathAndQueryOption) 0542 0543 /** 0544 * Returns the encoded path and the query. 0545 * 0546 * @param trailing add or remove a trailing '/', see adjustPath 0547 * @param options a set of flags from EncodedPathAndQueryOption 0548 * @return The concatenation of the encoded path , '?' and the encoded query. 0549 * 0550 * @deprecated since 5.0, use QUrl::path() and QUrl::query(); 0551 * QUrl::adjusted() can be used to remove a trailing slash if necessary. 0552 */ 0553 QString encodedPathAndQuery(AdjustPathOption trailing = LeaveTrailingSlash, const EncodedPathAndQueryOptions &options = PermitEmptyPath) const; 0554 0555 /** 0556 * @param query This is considered to be encoded. This has a good reason: 0557 * The query may contain the 0 character. 0558 * 0559 * The query should start with a '?'. If it doesn't '?' is prepended. 0560 * 0561 * @deprecated since 5.0, use QUrl::setQuery(QString), but note that it 0562 * doesn't start with '?' (it uses null vs empty, instead). 0563 */ 0564 void setQuery(const QString &query); 0565 0566 /** 0567 * Returns the query of the URL. 0568 * The query may contain the 0 character. 0569 * If a query is present it always starts with a '?'. 0570 * A single '?' means an empty query. 0571 * An empty string means no query. 0572 * @return The encoded query, or QString() if there is none. 0573 * 0574 * @deprecated since 5.0, use QByteArray QUrl::query(), but note that it 0575 * doesn't start with '?' (QUrl::hasQuery() can be used to distinguish 0576 * between no query and an empty query). 0577 */ 0578 QString query() const; 0579 0580 /** 0581 * Returns the @em encoded reference (or "fragment") of the URL (everything after '#'). 0582 * @return the encoded reference, or QString("") if the reference part is empty, 0583 * or QString() if the URL has no reference. 0584 * @deprecated since 5.0, use QUrl::fragment(QUrl::FullyEncoded) 0585 */ 0586 QString ref() const; 0587 0588 /** 0589 * Sets the reference/fragment part (everything after '#'). 0590 * If you have an encoded fragment already (as a QByteArray), you can call setFragment directly. 0591 * @param fragment the @em encoded reference (or QString() to remove it). 0592 * @deprecated since 5.0, use QUrl::setFragment() 0593 */ 0594 void setRef(const QString &fragment); 0595 0596 /** 0597 * Checks whether the URL has a reference/fragment part. 0598 * @return true if the URL has a reference part. In a URL like 0599 * http://www.kde.org/kdebase.tar#tar:/README it would 0600 * return true, too. 0601 * @deprecated since 5.0, use QUrl::hasFragment() 0602 */ 0603 bool hasRef() const; 0604 0605 /** 0606 * Returns the @em unencoded reference (or "fragment") of the URL (everything after '#'). 0607 * @return the unencoded reference, or QString("") if the reference part is empty, 0608 * or QString() if the URL has no reference. 0609 * @see split 0610 * @see hasSubUrl 0611 * @see encodedHtmlRef 0612 * @deprecated since 5.0, use QUrl::fragment(QUrl::FullyDecoded) 0613 */ 0614 QString htmlRef() const; 0615 0616 /** 0617 * Returns the @em encoded reference (or "fragment") of the URL (everything after '#'). 0618 * @return the encoded reference, or QString("") if the reference part is empty, 0619 * or QString() if the URL has no reference. 0620 * @see ref 0621 * @deprecated since 5.0, use QUrl::fragment(QUrl::FullyEncoded) 0622 */ 0623 QString encodedHtmlRef() const; 0624 0625 /** 0626 * Sets the HTML-style reference. 0627 * 0628 * @param ref The new reference. This is considered to be @em not encoded in 0629 * contrast to setRef(). Use QString() to remove it. 0630 * @see htmlRef() 0631 * @deprecated since 5.0, use QUrl::setFragment(ref, QUrl::DecodedMode) 0632 */ 0633 void setHTMLRef(const QString &ref); 0634 0635 /** 0636 * Checks whether there is a HTML reference. 0637 * @return true if the URL has an HTML-style reference. 0638 * @see htmlRef() 0639 * @deprecated since 5.0, use QUrl::hasFragment() 0640 */ 0641 bool hasHTMLRef() const; 0642 0643 /** 0644 * Checks whether the file is local. 0645 * @return true if the file is a plain local file (i.e. uses the file protocol 0646 * and no hostname, or the local hostname). 0647 * When isLocalFile returns true, you can use toLocalFile to read the file contents. 0648 * Otherwise you need to use KIO (e.g. KIO::get). 0649 */ 0650 bool isLocalFile() const; 0651 0652 /** 0653 * Adds encoding information to url by adding a "charset" parameter. If there 0654 * is already a charset parameter, it will be replaced. 0655 * @param encoding the encoding to add or QString() to remove the 0656 * encoding. 0657 */ 0658 void setFileEncoding(const QString &encoding); 0659 0660 /** 0661 * Returns encoding information from url, the content of the "charset" 0662 * parameter. 0663 * @return An encoding suitable for QTextCodec::codecForName() 0664 * or QString() if not encoding was specified. 0665 */ 0666 QString fileEncoding() const; 0667 0668 /** 0669 * Checks whether the URL has any sub URLs. See split() 0670 * for examples for sub URLs. 0671 * @return true if the file has at least one sub URL. 0672 * @see split 0673 */ 0674 bool hasSubUrl() const; 0675 0676 /** 0677 * Adds to the current path. 0678 * Assumes that the current path is a directory. @p txt is appended to the 0679 * current path. The function adds '/' if needed while concatenating. 0680 * This means it does not matter whether the current path has a trailing 0681 * '/' or not. If there is none, it becomes appended. If @p txt 0682 * has a leading '/' then this one is stripped. 0683 * 0684 * @param txt The text to add. It is considered to be decoded. 0685 * @deprecated since 5.0, use u.setPath(u.path() + '/' + txt). 0686 * If the path might already have a trailing slash, use u = u.adjusted(QUrl::StripTrailingSlash) first. 0687 */ 0688 void addPath(const QString &txt); 0689 0690 /** 0691 * Options for queryItems. Currently, only one option is 0692 * defined: 0693 * 0694 * @param CaseInsensitiveKeys normalize query keys to lowercase. 0695 **/ 0696 enum QueryItemsOption { CaseInsensitiveKeys = 1 }; 0697 Q_DECLARE_FLAGS(QueryItemsOptions, QueryItemsOption) 0698 0699 /** 0700 * Returns the list of query items as a map mapping keys to values. 0701 * 0702 * This does the same as QUrl::queryItems(), except that it 0703 * decodes "+" into " " in the value, supports CaseInsensitiveKeys, 0704 * and returns a different data type. 0705 * 0706 * @param options any of QueryItemsOption <em>or</em>ed together. 0707 * 0708 * @return the map of query items or the empty map if the url has no 0709 * query items. 0710 * @deprecated since 5.0, use QUrlQuery(url).queryItems() 0711 */ 0712 QMap< QString, QString > queryItems(const QueryItemsOptions &options = {}) const; 0713 0714 /** 0715 * Returns the value of a certain query item. 0716 * 0717 * This does the same as QUrl::queryItemValue(), except that it 0718 * decodes "+" into " " in the value. 0719 * 0720 * @param item Item whose value we want 0721 * 0722 * @return the value of the given query item name or QString() if the 0723 * specified item does not exist. 0724 * @deprecated since 5.0, use QUrlQuery(url).queryItemValue(item) 0725 */ 0726 QString queryItem(const QString &item) const; 0727 0728 /** 0729 * Add an additional query item. 0730 * To replace an existing query item, the item should first be 0731 * removed with removeQueryItem() 0732 * 0733 * @param _item Name of item to add 0734 * @param _value Value of item to add 0735 * @deprecated since 5.0, use QUrlQuery(url), then addQueryItem(), then QUrl::setQuery() 0736 */ 0737 void addQueryItem(const QString &_item, const QString &_value); 0738 0739 /** 0740 * Sets the filename of the path. 0741 * In comparison to addPath() this function does not assume that the current 0742 * path is a directory. This is only assumed if the current path ends with '/'. 0743 * 0744 * Any reference is reset. 0745 * 0746 * @param _txt The filename to be set. It is considered to be decoded. If the 0747 * current path ends with '/' then @p _txt int just appended, otherwise 0748 * all text behind the last '/' in the current path is erased and 0749 * @p _txt is appended then. It does not matter whether @p _txt starts 0750 * with '/' or not. 0751 * @deprecated since 5.0, use u = u.adjusted(QUrl::RemoveFilename); followed by 0752 * u.setPath(u.path() + txt); 0753 */ 0754 void setFileName(const QString &_txt); 0755 0756 /** 0757 * option to be used in fileName and directory 0758 */ 0759 enum DirectoryOption { 0760 /** 0761 * This tells whether a trailing '/' should be ignored. 0762 * 0763 * If the flag is not set, for both <tt>file:///hallo/torben/</tt> and <tt>file:///hallo/torben</tt> 0764 * the fileName is "torben" and the path is "hallo" 0765 * 0766 * If the flag is set, then everything behind the last '/'is considered to be the filename. 0767 * So "hallo/torben" will be the path and the filename will be empty. 0768 */ 0769 ObeyTrailingSlash = 0x02, 0770 /** 0771 * tells whether the returned result should end with '/' or not. 0772 * If the flag is set, '/' is added to the end of the path 0773 * 0774 * If the path is empty or just "/" then this flag has no effect. 0775 * 0776 * This option should only be used in directory(), it has no effect in fileName() 0777 */ 0778 AppendTrailingSlash = 0x04, 0779 /** 0780 * Opposite of ObeyTrailingSlash (default) 0781 * fileName("file:/foo/") and fileName("file:/foo") is "foo" in both cases. 0782 */ 0783 IgnoreTrailingSlash = 0x01 0784 0785 }; 0786 Q_DECLARE_FLAGS(DirectoryOptions, DirectoryOption) 0787 0788 /** 0789 * Returns the filename of the path. 0790 * @param options a set of DirectoryOption flags. (StripTrailingSlashFromResult has no effect) 0791 * @return The filename of the current path. The returned string is decoded. Null 0792 * if there is no file (and thus no path). 0793 * @deprecated since 5.0, use url.fileName(), which behaves like ObeyTrailingSlash though. 0794 * To get rid of the trailing slash if there could be one, use adjusted(QUrl::StripTrailingSlash) first. 0795 */ 0796 QString fileName(const DirectoryOptions &options = IgnoreTrailingSlash) const; 0797 0798 /** 0799 * Returns the directory of the path. 0800 * @param options a set of DirectoryOption flags 0801 * @return The directory part of the current path. Everything between the last and the second last '/' 0802 * is returned. For example <tt>file:///hallo/torben/</tt> would return "/hallo/torben/" while 0803 * <tt>file:///hallo/torben</tt> would return "hallo/". The returned string is decoded. 0804 * QString() is returned when there is no path. 0805 * @deprecated since 5.0, use url.adjusted(QUrl::RemoveFilename).path(), which behaves like ObeyTrailingSlash though. 0806 * To get rid of the trailing slash if there could be one, use adjusted(QUrl::StripTrailingSlash) first. 0807 * Do not combine the two calls! You want to remove the trailing slash first, and then remove the filename. 0808 */ 0809 QString directory(const DirectoryOptions &options = IgnoreTrailingSlash) const; 0810 0811 /** 0812 * Set the directory to @p dir, leaving the filename empty. 0813 */ 0814 void setDirectory(const QString &dir); 0815 0816 /** 0817 * Changes the directory by descending into the given directory. 0818 * It is assumed the current URL represents a directory. 0819 * If @p dir starts with a "/" the 0820 * current URL will be "protocol://host/dir" otherwise @p _dir will 0821 * be appended to the path. @p _dir can be ".." 0822 * This function won't strip protocols. That means that when you are in 0823 * file:///dir/dir2/my.tgz#tar:/ and you do cd("..") you will 0824 * still be in file:///dir/dir2/my.tgz#tar:/ 0825 * 0826 * @param _dir the directory to change to 0827 * @return true if successful 0828 */ 0829 bool cd(const QString &_dir); 0830 0831 /** 0832 * Returns the URL as string, with all escape sequences intact, 0833 * encoded in a given charset. 0834 * This is used in particular for encoding URLs in UTF-8 before using them 0835 * in a drag and drop operation. 0836 * Please note that the string returned by url() will include 0837 * the password of the URL. If you want to show the URL to the 0838 * user, use prettyUrl(). 0839 * 0840 * @param trailing use to add or remove a trailing slash to/from the path. See adjustPath 0841 * @return The complete URL, with all escape sequences intact, encoded 0842 * in a given charset. 0843 * @see prettyUrl() 0844 * 0845 * @deprecated since 5.0, use QUrl::toString() instead. 0846 * In case of RemoveTrailingSlash, call adjusted(QUrl::StripTrailingSlash) first. 0847 * AddTrailingSlash is not available directly, test if path ends with '/', and if not setPath(path() + '/'). 0848 */ 0849 QString url(AdjustPathOption trailing = LeaveTrailingSlash) const; 0850 0851 /** 0852 * Returns the URL as string in human-friendly format. 0853 * Example: 0854 * \code 0855 * http://localhost:8080/test.cgi?test=hello world&name=fred 0856 * \endcode 0857 * @param trailing use to add or remove a trailing slash to/from the path. see adjustPath. 0858 * 0859 * @return A human readable URL, with no non-necessary encodings/escaped 0860 * characters. Password will not be shown. 0861 * @see url() 0862 * 0863 * @deprecated since 5.0, use QUrl::toDisplayString() instead. 0864 */ 0865 QString prettyUrl(AdjustPathOption trailing = LeaveTrailingSlash) const; 0866 0867 /** 0868 * Return the URL as a string, which will be either the URL (as prettyUrl 0869 * would return) or, when the URL is a local file without query or ref, 0870 * the path. 0871 * Use this method, to display URLs to the user. 0872 * You can give the result of pathOrUrl back to the KUrl constructor, it accepts 0873 * both paths and urls. 0874 * 0875 * @return the new KUrl 0876 * @param trailing use to add or remove a trailing slash to/from the path. see adjustPath. 0877 * @since 4.2 0878 * @deprecated since 5.0, use QUrl::toDisplayString(QUrl::PreferLocalFile | ...) instead. 0879 */ 0880 QString pathOrUrl(AdjustPathOption trailing = LeaveTrailingSlash) const; 0881 0882 /** 0883 * Returns the URL as a string, using the standard conventions for mime data 0884 * (drag-n-drop or copy-n-paste). 0885 * Internally used by KUrl::List::fromMimeData, which is probably what you want to use instead. 0886 * @deprecated since 5.0, use QMimeData::setUrls directly, or KUrlMimeData::setUrls 0887 */ 0888 QString toMimeDataString() const; 0889 0890 /** 0891 * This function is useful to implement the "Up" button in a file manager for example. 0892 * cd() never strips a sub-protocol. That means that if you are in 0893 * file:///home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see 0894 * file:///home. The algorithm tries to go up on the right-most URL. If that is not 0895 * possible it strips the right most URL. It continues stripping URLs. 0896 * @return a URL that is a level higher 0897 * @deprecated since 5.0, use KIO::upUrl() instead, from kio/global.h 0898 */ 0899 KUrl upUrl() const; 0900 0901 KUrl &operator=(const KUrl &_u); 0902 0903 // Define those, since the constructors are explicit 0904 KUrl &operator=(const char *_url) 0905 { 0906 *this = KUrl(_url); 0907 return *this; 0908 } 0909 KUrl &operator=(const QByteArray &_url) 0910 { 0911 *this = KUrl(_url); 0912 return *this; 0913 } 0914 KUrl &operator=(const QString &_url) 0915 { 0916 *this = KUrl(_url); 0917 return *this; 0918 } 0919 0920 bool operator==(const KUrl &_u) const; 0921 bool operator==(const QString &_u) const; 0922 bool operator!=(const KUrl &_u) const 0923 { 0924 return !(*this == _u); 0925 } 0926 bool operator!=(const QString &_u) const 0927 { 0928 return !(*this == _u); 0929 } 0930 0931 /** 0932 * Converts this KUrl to a QVariant, this allows to use KUrl 0933 * in QVariant() constructor 0934 */ 0935 operator QVariant() const; 0936 0937 /** 0938 * The same as equals(), just with a less obvious name. 0939 * Compares this url with @p u. 0940 * @param u the URL to compare this one with. 0941 * @param ignore_trailing set to true to ignore trailing '/' characters. 0942 * @return True if both urls are the same. If at least one of the urls is invalid, 0943 * false is returned. 0944 * @see operator==. This function should be used if you want to 0945 * ignore trailing '/' characters. 0946 * @deprecated since 4.0, use equals() instead. 0947 */ 0948 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0949 KDELIBS4SUPPORT_DEPRECATED bool cmp(const KUrl &u, bool ignore_trailing = false) const; 0950 #endif 0951 0952 /** 0953 * Flags to be used in URL comparison functions like equals, or urlcmp 0954 */ 0955 enum EqualsOption { 0956 /** 0957 * ignore trailing '/' characters. The paths "dir" and "dir/" are treated the same. 0958 * Note however, that by default, the paths "" and "/" are not the same 0959 * (For instance ftp://user@host redirects to ftp://user@host/home/user (on a linux server), 0960 * while ftp://user@host/ is the root dir). 0961 * This is also why path(RemoveTrailingSlash) for "/" returns "/" and not "". 0962 * 0963 * When dealing with web pages however, you should also set AllowEmptyPath so that 0964 * no path and "/" are considered equal. 0965 */ 0966 CompareWithoutTrailingSlash = 0x01, 0967 /** 0968 * disables comparison of HTML-style references. 0969 */ 0970 CompareWithoutFragment = 0x02, 0971 /** 0972 * Treat a URL with no path as equal to a URL with a path of "/", 0973 * when CompareWithoutTrailingSlash is set. 0974 * Example: 0975 * KUrl::urlcmp("http://www.kde.org", "http://www.kde.org/", KUrl::CompareWithoutTrailingSlash | KUrl::AllowEmptyPath) 0976 * returns true. 0977 * This option is ignored if CompareWithoutTrailingSlash isn't set. 0978 * @since 4.5 0979 */ 0980 AllowEmptyPath = 0x04 0981 }; 0982 Q_DECLARE_FLAGS(EqualsOptions, EqualsOption) 0983 0984 /** 0985 * Compares this url with @p u. 0986 * @param u the URL to compare this one with. 0987 * @param options a set of EqualsOption flags 0988 * @return True if both urls are the same. If at least one of the urls is invalid, 0989 * false is returned. 0990 * @see operator==. This function should be used if you want to 0991 * set additional options, like ignoring trailing '/' characters. 0992 * @deprecated since 5.0, use matches(u, formattingOptions) 0993 * equals(u, KUrl::CompareWithoutTrailingSlash) becomes matches(u, QUrl::StripTrailingSlash) 0994 * equals(u, KUrl::CompareWithoutFragment) becomes matches(u, QUrl::RemoveFragment) 0995 * equals(u, KUrl::CompareWithoutTrailingSlash|KUrl::AllowEmptyPath) needs manual handling 0996 * (it was mostly unused). 0997 */ 0998 bool equals(const KUrl &u, const EqualsOptions &options = {}) const; 0999 1000 /** 1001 * Checks whether the given URL is parent of this URL. 1002 * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/. 1003 * @return true if this url is a parent of @p u (or the same URL as @p u) 1004 * @deprecated since 5.0. url.isParentOf(child) is now 1005 * url.isParentOf(child) || url.matches(child, QUrl::StripTrailingSlash); 1006 */ 1007 bool isParentOf(const KUrl &child) const; 1008 1009 /** 1010 * Splits nested URLs like file:///home/weis/kde.tgz#gzip:/#tar:/kdebase 1011 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in 1012 * http://www.kde.org and tar:/kde/README.html#ref1. 1013 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL. 1014 * Since HTML-style references mark 1015 * a certain position in a document this reference is appended to every URL. 1016 * The idea behind this is that browsers, for example, only look at the first URL while 1017 * the rest is not of interest to them. 1018 * 1019 * 1020 * @param _url The URL that has to be split. 1021 * @return An empty list on error or the list of split URLs. 1022 * @see hasSubUrl 1023 */ 1024 static List split(const QString &_url); 1025 1026 /** 1027 * Splits nested URLs like file:///home/weis/kde.tgz#gzip:/#tar:/kdebase 1028 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in 1029 * http://www.kde.org and tar:/kde/README.html#ref1. 1030 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL. 1031 * Since HTML-style references mark 1032 * a certain position in a document this reference is appended to every URL. 1033 * The idea behind this is that browsers, for example, only look at the first URL while 1034 * the rest is not of interest to them. 1035 * 1036 * @return An empty list on error or the list of split URLs. 1037 * 1038 * @param _url The URL that has to be split. 1039 * @see hasSubUrl 1040 */ 1041 static List split(const KUrl &_url); 1042 1043 /** 1044 * Reverses split(). Only the first URL may have a reference. This reference 1045 * is considered to be HTML-like and is appended at the end of the resulting 1046 * joined URL. 1047 * @param _list the list to join 1048 * @return the joined URL 1049 */ 1050 static KUrl join(const List &_list); 1051 1052 /** 1053 * Creates a KUrl object from a QString representing an absolute local path. 1054 * KUrl url( somePath ) is almost the same, but this method is more explicit, 1055 * avoids the path-or-url detection in the KUrl constructor, and parses 1056 * "abc:def" as a filename, not as URL. 1057 * 1058 * @param text the local path 1059 * @return the new KUrl 1060 * 1061 * @deprecated since 5.0, use QUrl::fromLocalFile 1062 */ 1063 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 1064 static KDELIBS4SUPPORT_DEPRECATED KUrl fromPath(const QString &text) 1065 { 1066 return fromLocalFile(text); 1067 } 1068 #endif 1069 1070 /** 1071 * @deprecated since 4.0, use QUrl() instead 1072 */ 1073 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 1074 static KDELIBS4SUPPORT_DEPRECATED KUrl fromPathOrUrl(const QString &text); 1075 #endif 1076 1077 /** 1078 * Adds URL data into the given QMimeData. 1079 * 1080 * By default, populateMimeData also exports the URL as plain text, for e.g. dropping 1081 * onto a text editor. 1082 * But in some cases this might not be wanted, e.g. if adding other mime data 1083 * which provides better plain text data. 1084 * 1085 * WARNING: do not call this method multiple times, use KUrl::List::populateMimeData instead. 1086 * 1087 * @param mimeData the QMimeData instance used to drag or copy this URL 1088 * @param metaData KIO metadata shipped in the mime data, which is used for instance to 1089 * set a correct HTTP referrer (some websites require it for downloading e.g. an image) 1090 * @param flags set NoTextExport to prevent setting plain/text data into @p mimeData 1091 * 1092 * @deprecated since 5.0, use QMimeData::setUrls(QList<QUrl>() << url), 1093 * followed by KUrlMimeData::setMetaData if you have metadata. 1094 */ 1095 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 1096 KDELIBS4SUPPORT_DEPRECATED void populateMimeData(QMimeData *mimeData, 1097 const MetaDataMap &metaData = MetaDataMap(), 1098 MimeDataFlags flags = DefaultMimeDataFlags) const; 1099 #endif 1100 1101 /** 1102 * Convenience function. 1103 * 1104 * Returns whether '_url' is likely to be a "relative" URL instead of 1105 * an "absolute" URL. 1106 * 1107 * This is mostly meant for KUrl(url, relativeUrl). 1108 * 1109 * If you are looking for the notion of "relative path" (foo) vs "absolute path" (/foo), 1110 * use QUrl::isRelative() instead. 1111 * Indeed, isRelativeUrl() returns true for the string "/foo" since it doesn't contain a protocol, 1112 * while KUrl("/foo").isRelative() is false since the KUrl constructor turns it into file:///foo. 1113 * The two methods basically test the same thing, but this one takes a string (which is faster) 1114 * while the class method requires a QUrl/KUrl which gives a more expected result, given 1115 * the "magic" in the KUrl constructor. 1116 * 1117 * @param _url URL to examine 1118 * @return true when the URL is likely to be "relative", false otherwise. 1119 * @deprecated since 5.0, use QUrl(_url)::isRelative instead 1120 */ 1121 static bool isRelativeUrl(const QString &_url); 1122 1123 /** 1124 * Convenience function 1125 * 1126 * Returns a "relative URL" based on @p base_url that points to @p url. 1127 * 1128 * If no "relative URL" can be created, e.g. because the protocol 1129 * and/or hostname differ between @p base_url and @p url an absolute 1130 * URL is returned. 1131 * Note that if @p base_url represents a directory, it should contain 1132 * a trailing slash. 1133 * @param base_url the URL to derive from 1134 * @param url new URL 1135 * @see adjustPath() 1136 * @deprecated since 5.0, check that the URLs have the same scheme+host+port+user+pass, 1137 * then make the path relative with QDir(base_url.path()).relativeFilePath(url.path()) 1138 */ 1139 static QString relativeUrl(const KUrl &base_url, const KUrl &url); 1140 1141 /** 1142 * Convenience function 1143 * 1144 * Returns a relative path based on @p base_dir that points to @p path. 1145 * @param base_dir the base directory to derive from 1146 * @param path the new target directory 1147 * @param isParent A pointer to a boolean which, if provided, will be set to reflect 1148 * whether @p path has @p base_dir is a parent dir. 1149 * @deprecated since 5.0, use QDir(base_dir).relativeFilePath(path). isParent can be 1150 * replaced with a call to startsWith("..") on the result value. 1151 */ 1152 static QString relativePath(const QString &base_dir, const QString &path, bool *isParent = nullptr); 1153 1154 private: 1155 void _setQuery(const QString &query); 1156 void _setEncodedUrl(const QByteArray &url); 1157 operator QString() const; // forbidden, use url(), prettyUrl(), or pathOrUrl() instead. 1158 }; 1159 1160 Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::EncodedPathAndQueryOptions) 1161 Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::CleanPathOptions) 1162 Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::QueryItemsOptions) 1163 Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::EqualsOptions) 1164 Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::DirectoryOptions) 1165 1166 Q_DECLARE_METATYPE(KUrl) 1167 Q_DECLARE_METATYPE(KUrl::List) 1168 1169 /** 1170 * \relates KUrl 1171 * Compares URLs. They are parsed, split and compared. 1172 * Two malformed URLs with the same string representation 1173 * are nevertheless considered to be unequal. 1174 * That means no malformed URL equals anything else. 1175 * @deprecated since 4.5, use QUrl(_url1) == QUrl(_url2) instead. 1176 */ 1177 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 1178 KDELIBS4SUPPORT_DEPRECATED_EXPORT bool urlcmp(const QString &_url1, const QString &_url2); // KDE5: remove, KUrl::equals is better API 1179 #endif 1180 1181 /** 1182 * \relates KUrl 1183 * Compares URLs. They are parsed, split and compared. 1184 * Two malformed URLs with the same string representation 1185 * are nevertheless considered to be unequal. 1186 * That means no malformed URL equals anything else. 1187 * 1188 * @param _url1 A reference URL 1189 * @param _url2 A URL that will be compared with the reference URL 1190 * @param options a set of KUrl::EqualsOption flags 1191 * @deprecated since 4.5, use QUrl(_url1).adjusted(options) == QUrl(_url2).adjusted(options) instead. 1192 */ 1193 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 1194 KDELIBS4SUPPORT_DEPRECATED_EXPORT bool urlcmp(const QString &_url1, const QString &_url2, const KUrl::EqualsOptions &options); // KDE5: remove, KUrl::equals is better API 1195 #endif 1196 1197 #endif