kurl.h
来自「konqueror3 embedded版本, KDE环境下的当家浏览器的嵌入式版」· C头文件 代码 · 共 1,829 行 · 第 1/4 页
H
1,829 行
*/ QString queryItem( const QString& item, int encoding_hint ) const; /** * Options for queryItems() * * @since 3.1 */ enum QueryItemsOptions { /** * Normalize query keys to lowercase */ CaseInsensitiveKeys = 1 }; /** * @internal, override for the below function */ QMap< QString, QString > queryItems( int options=0 ) const; /** * @brief Returns the list of query items as a map mapping keys to values * * @param options any of QueryItemsOptions <em>OR</em>ed together * @param encoding_hint MIB of encoding of query. * See QTextCodec::mibEnum() * * @return the map of query items or the empty map if the URL has no * query items * * @see queryItem() * @see addQueryItem() * @see removeQueryItem() * @see query() * * @since 3.1 */ QMap< QString, QString > queryItems( int options, int encoding_hint ) const; /** * @brief Adds an additional query item * * To replace an existing query item, the item should first be * removed with removeQueryItem() * * @param _item name of item to add * @param _value value of item to add * @param encoding_hint MIB of encoding to use for _value. * See QTextCodec::mibEnum() * * @see queryItem() * @see queryItems() * @see query() */ void addQueryItem( const QString& _item, const QString& _value, int encoding_hint = 0 ); /** * @brief Removea an item from the query * * @param _item name of item to remove * * @see addQueryItem() * @see queryItem() * @see queryItems() * @see query() */ void removeQueryItem( const QString& _item ); /** * @brief Sets the filename of the path * * In comparison to addPath() this function does not assume that the current * path is a directory. This is only assumed if the current path ends * with @c '/'. * * If the current path ends with @c '/' then @p _txt is just appended, * otherwise all text behind the last @c '/' in the current path is erased * and @p _txt is appended then. It does not matter whether @p _txt starts * with @c '/' or not. * * Any reference is reset. * * @param _txt the filename to be set. It is considered to be decoded * * @see fileName() * @see setDirectory() * @see setPath() */ void setFileName( const QString&_txt ); /** * @brief Returns the filename of the path * * @p _ignore_trailing_slash_in_path tells whether a trailing @c '/' should * be ignored. This means that the function would return @c "torben" for * <tt>"file:///hallo/torben/"</tt> and <tt>"file:///hallo/torben"</tt>. * * @param _ignore_trailing_slash_in_path if set to @c false, then everything * behind the last @c '/' is considered to be the filename * * @return the filename of the current path. The returned string is decoded. * @c QString::null if there is no file (and thus no path) * * @see setFileName() * @see directory() * @see path() */ QString fileName( bool _ignore_trailing_slash_in_path = true ) const; /** * @brief Returns the directory of the path * * The directory is everything between the last and the second last @c '/' * is returned. For example <tt>"file:///hallo/torben/"</tt> would return * <tt>"/hallo/torben/"</tt> while <tt>"file:///hallo/torben"</tt> would * return <tt>"hallo/"</tt>. * * @p _ignore_trailing_slash_in_path tells whether a trailing @c '/' should * be ignored. This means that the function would return @c "/hallo" * (or @c "/hallo" depending on @p _strip_trailing_slash_from_result) for * <tt>"file:///hallo/torben/"</tt> and <tt>"file:///hallo/torben"</tt>. * * @param _strip_trailing_slash_from_result tells whether the returned result * should end with @c '/' or not. If the path is empty or just @c "/" * then this flag has no effect * @param _ignore_trailing_slash_in_path if set to @c false, then everything * behind the last @c '/' is considered to be the filename * * @return the directory part of the current path or @c QString::null when * there is no path. The returned string is decoded * * @see setDirectory() * @see fileName() * @see path() */ QString directory( bool _strip_trailing_slash_from_result = true, bool _ignore_trailing_slash_in_path = true ) const; /** * @brief Sets the directory of the path, leaving the filename empty * * @param dir the decoded directory to set * * @see directory() * @see setFileName() * @see setPath() */ void setDirectory(const QString &dir); /** * @brief Changes the directory by descending into the given directory * * It is assumed the current URL represents a directory. * If @p _dir starts with a @c '/' the current URL will be * <tt>"protocol://host/dir"</tt> otherwise @p _dir will be appended to the * path. @p _dir can be @c ".." * * This function won't strip protocols. That means that when you are in * <tt>"file:///dir/dir2/my.tgz#tar:/"</tt> and you do <tt>cd("..")</tt> you * will still be in <tt>"file:///dir/dir2/my.tgz#tar:/"</tt> * * @param _dir the directory to change to * @return @c true if successful * * @see directory() * @see path() */ bool cd( const QString& _dir ); /** * @brief Returns the URL as string, with all escape sequences intact, * encoded in a given charset * * This is used in particular for encoding URLs in UTF-8 before using them * in a drag and drop operation. * * @note that the string returned by url() will include the password of the * URL. If you want to show the URL to the user, use prettyURL(). * * The @p _trailing parameter allows to ensure the existance or absence of * the last (trailing) @c '/' character in the path. * If the URL has no path, then no @c '/' is added anyway. * And on the other side: if the path is just @c "/", then this character * won't be stripped. * * Reason: <tt>"ftp://weis@host"</tt> means something completely different * than <tt>"ftp://weis@host/"</tt>. * So adding or stripping the '/' would really alter the URL, while * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same * directory. * * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing * @c '/', @c +1 adds a trailing @c '/' if there is none yet * and @c 0 returns the path unchanged * @param encoding_hint MIB of encoding to use. * See QTextCodec::mibEnum() * * @return the complete URL, with all escape sequences intact, encoded * in a given charset * * @see prettyURL() * @see pathOrURL() * @see htmlURL() */ QString url( int _trailing = 0, int encoding_hint = 0) const; /** * @brief Returns the URL as string in human-friendly format * * Example: * @code * http://localhost:8080/test.cgi?test=hello world&name=fred * @endcode * * Does @em not contain the password if the URL has one, use url() if you * need to have it in the string. * * The @p _trailing parameter allows to ensure the existance or absence of * the last (trailing) @c '/' character in the path. * If the URL has no path, then no @c '/' is added anyway. * And on the other side: if the path is just @c "/", then this character * won't be stripped. * * Reason: <tt>"ftp://weis@host"</tt> means something completely different * than <tt>"ftp://weis@host/"</tt>. * So adding or stripping the '/' would really alter the URL, while * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same * directory. * * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing * @c '/', @c +1 adds a trailing @c '/' if there is none yet * and @c 0 returns the path unchanged * @return a human readable URL, with no non-necessary encodings/escaped * characters. Password will not be shown * * @see url() * @see pathOrURL() */ QString prettyURL( int _trailing = 0) const; /** * @brief Returns the URL as string in human-friendly format * Example: * @code * http://localhost:8080/test.cgi?test=hello world&name=fred * @endcode * * Does @em not contain the password if the URL has one, use url() if you * need to have it in the string. * * The @p _trailing parameter allows to ensure the existance or absence of * the last (trailing) @c '/' character in the path. * If the URL has no path, then no @c '/' is added anyway. * And on the other side: if the path is just @c "/", then this character * won't be stripped. * * Reason: <tt>"ftp://weis@host"</tt> means something completely different * than <tt>"ftp://weis@host/"</tt>. * So adding or stripping the '/' would really alter the URL, while * <tt>"ftp://host/path"</tt> and <tt>"ftp://host/path/"</tt> mean the same * directory. * * @param _trailing May be ( @c -1, @c 0, @c +1 ). @c -1 strips a trailing * @c '/', @c +1 adds a trailing @c '/' if there is none yet * and @c 0 returns the path unchanged * @param _flags if StripFileProtocol, @c "file://" will be stripped. * The use of this method is now discouraged, better use pathOrURL(). * * @return a human readable URL, with no non-necessary encodings/escaped * characters. Password will not be shown * * @see prettyURL() * @see url() * @see pathOrURL() */ QString prettyURL( int _trailing, AdjustementFlags _flags) const; // ### BIC: Merge the two above + spell it as "Adjustment" // Or remove completely, and let people use pathOrURL() instead /** * @brief Returns the URL as a string depending if it is a local file * * It will be either the URL (as prettyURL() would return) or, when the URL * is a local file without query or ref, the path(). * * Use this method, together with its opposite, fromPathOrURL(), * to display and even let the user edit URLs. * * @return the path or URL string depending on its properties * * @see prettyURL() * @see path() * @see url() * @see isLocalFile() * * @since 3.4 */ QString pathOrURL() const; /** * @brief Returns the URL as string, escaped for HTML * * @return a human readable URL, with no non-necessary encodings/escaped * characters which is HTML encoded for safe inclusion in HTML or * rich text. Password will not be shown. * * @see prettyURL() * @see url() * @see pathOrURL() */ QString htmlURL() const; /** * @brief Tests if the KURL is empty * * An empty URL has neither path nor protocol set. * * @return @c true if the URL is empty * * @see hasPath() * @see protocol() * @see isValid() */ bool isEmpty() const; /** * @brief Returns the URL that is the best possible candidate for on level * higher in the path hierachy * * This function is useful to implement the "Up" button in a file manager for * example. * cd() never strips a sub-protocol. That means that if you are in * <tt>"file:///home/x.tgz#gzip:/#tar:/"</tt> and hit the up button you * expect to see <tt>"file:///home"</tt>. The algorithm tries to go up on the * right-most URL. If that is not possible it strips the right most URL. It * continues stripping URLs until it can go up. * * @return a URL that is a level higher * * @see cd() * @see split() * @see hasSubURL() * @see path() */ KURL upURL( ) const; /** * @brief Tests if this URL is less than the given URL * * The current URL is consideres <tt>"less than"</tt> then @p _u if * (tested in this order): * - it is not valid but @p _u is. See isValid() * - its protocol is "less than" @p _u's protocol. See protocol() * - its host is "less than" @p _u's host. See host() * - its port is "less than" @p _u's port. See port() * - its path is "less than" @p _u's path. See path() * - its encoded query is "less than" @p _u's encoded query. See query() * - its endoded reference is "less than" @p _u's encoded reference. * See ref() * - its username is "less than" @p _u's username. See user() * - its password is "less than" @p _u's password. See pass() * * Examples: * @code * KURL url1; * KURL url2; * * bool lessThan = url1 < url2; // false. Both invalid, no protocols * * url2.setProtocol( QString::null ); * lessThan = url1 < url2; // true. url2 is valid because of setProtocol() * * url1.setProtocol( QString::null ); * lessThan = url1 < url2; // false. Both valid and everything empty * * url1.setProtocol( "http" ); * url2.setProtocol( "https" ); * lessThan = url1 < url2; // true. "http" < "https" * * url2.setHost( "api.kde.org" ); * url2.setProtocol( "http" ); * url2.setProtocol( "www.kde.org" ); * lessThan = url1 < url2; // true. protocols equal and "api" < "www" * * url1.setProtocol( "https" ); * url2.setProtocol( "http" ); * lessThan = url1 < url2; // false. "https" > "http". host doesn't matter yet * @endcode * * @param _u the URL to compare to * * @return @c true if the URL is less than @p _u. Otherwise @c false * (equal or greater than) * * @see operator==() * @see QString::compare() */ bool operator<(const KURL& _u) const; /** * @brief Copies the values of the given URL into this one * * Just assigns each member using the member's assignment operator. * * @param _u the URL to take the values from * * @return a reference to this URL (*this) * * @see equals() */ KURL& operator=( const KURL& _u ); /** * @brief Assigns the URL, given as a string, to this one * * This will reset the current URL and parse the given string. * See the similar constructor for known limitations. * * @param _url the QString to parse for values * * @return a reference to this URL (*this) * * @see equals() * @see KURL(const QString &, int) */ KURL& operator=( const QString& _url ); /** * @brief Assigns the URL, given as a C string, to this one * * This will reset the current URL and parse the given string. * See the similar constructor for known limitations. * * @param _url the C string to parse for values * * @return a reference to this URL (*this) * * @see equals() * @see KURL(const char *, int) */ KURL& operator=( const char * _url ); /** * @brief Assigns the URL, given as a Qt URL, to this one * * This will reset the current URL and parse the given string. * * @param u the Qt URL to take the values from * * @return a reference to this URL (*this) * * @see equals() * @see KURL(const QUrl &) */ KURL& operator=( const QUrl & u );
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?