⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kurl.h

📁 monqueror一个很具有参考价值的源玛
💻 H
📖 第 1 页 / 共 2 页
字号:
  /**   * @return @p false if the URL is malformed. This function does @em not test   *         whether sub URLs are well-formed, too.   */  bool isValid() const  { return !m_bIsMalformed; }  /*   * @deprecated   */  bool isMalformed() const { return !isValid(); }  /**   * @return @p true if the file is a plain local file and has no filter protocols   *         attached to it.   */  bool isLocalFile() const;  /**   * @return @p true if the file has at least one sub URL.   *         Use @ref split() to get the sub URLs.   */  bool hasSubURL() const;  /**   * Add to the current path.   * Assumes that the current path is a directory. @p _txt is appended to the   * current path. The function adds '/' if needed while concatenating.   * This means it does not matter whether the current path has a trailing   * '/' or not. If there is none, it becomes appended. If @p _txt   * has a leading '/' then this one is stripped.   *   * @param _txt This is considered to be decoded   */  void addPath( const QString& _txt );  /**   * In comparison to @ref addPath() this function does not assume that the current path   * is a directory. This is only assumed if the current path ends with '/'.   *   * Any reference is reset.   *   * @param _txt This is considered to be decoded. If the current path ends with '/'   *             then @p _txt ist just appended, otherwise all text behind the last '/'   *             in the current path is erased and @p _txt is appended then. It does   *             not matter whether @p _txt starts with '/' or not.   */  void setFileName( const QString&_txt );  /**   * @return The filename of the current path. The returned string is decoded.   *   * @param _ignore_trailing_slash_in_path This tells whether a trailing '/' should be ignored.   *                                     This means that the function would return "torben" for   *                                     <tt>file:/hallo/torben/</tt> and <tt>file:/hallo/torben</tt>.   *                                     If the flag is set to false, then everything behind the last '/'   *                                     is considered to be the filename.   */  QString fileName( bool _ignore_trailing_slash_in_path = true ) const;  QString filename( bool _ignore_trailing_slash_in_path = true ) const  {    return fileName(_ignore_trailing_slash_in_path);  }  /**   * @return The directory part of the current path. Everything between the last and the second last '/'   *         is returned. For example <tt>file:/hallo/torben/</tt> would return "/hallo/torben/" while   *         <tt>file:/hallo/torben</tt> would return "hallo/". The returned string is decoded.   *   * @param _strip_trailing_slash_from_result tells whether the returned result should end with '/' or not.   *                                          If the path is empty or just "/" then this flag has no effect.   * @param _ignore_trailing_slash_in_path means that <tt>file:/hallo/torben</tt> and   *                                       <tt>file:/hallo/torben/"</tt> would both return <tt>/hallo/</tt>   *                                       or <tt>/hallo</tt> depending on the other flag   */  QString directory( bool _strip_trailing_slash_from_result = true,		     bool _ignore_trailing_slash_in_path = true ) const;  /**   * Change directory by descending into the given directory.   * It is assumed the current URL represents a directory.   * If @p dir starts with a "/" the   * current URL will be "protocol://host/dir" otherwise @p _dir will   * be appended to the path. @p _dir can be ".."   * This function won't strip protocols. That means that when you are in   * file:/dir/dir2/my.tgz#tar:/ and you do cd("..") you will   * still be in file:/dir/dir2/my.tgz#tar:/   *   * @return true   */  bool cd( const QString& _dir );  /**   * @return The complete URL, with all escape sequences intact.   * Example: http://localhost:8080/test.cgi?test=hello%20world&name=fred   *   * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds   *                  a trailing '/' if there is none yet and 0 returns the   *                  path unchanged.   */  QString url( int _trailing = 0 ) const;  /**   * @return The complete URL, 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.   *   * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds   *                  a trailing '/' if there is none yet and 0 returns the   *                  path unchanged.   * @param encoding_hint The charset to use for encoding (see QFont::Charset).   */  QString url( int _trailing, int encoding_hint ) const;  /**   * @return A human readable URL, with no non-necessary encodings/escaped   * characters.   * Example: http://localhost:8080/test.cgi?test=hello world&name=fred   */  QString prettyURL( int _trailing = 0) const;  /**   * Test to see if the @ref KURL is empty.   **/  bool isEmpty() const;  /**   * This function is useful to implement the "Up" button in a file manager for example.   * @ref cd() never strips a sub-protocol. That means that if you are in   * file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see   * file:/home. 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.   */  KURL upURL( ) const;  KURL& operator=( const KURL& _u );  KURL& operator=( const QString& _url );  KURL& operator=( const char * _url );  KURL& operator=( const QUrl & u );  bool operator==( const KURL& _u ) const;  bool operator==( const QString& _u ) const;  bool operator!=( const KURL& _u ) const { return !( *this == _u ); }  bool operator!=( const QString& _u ) const { return !( *this == _u ); }  /**   * Compare this url with @p u   * @param ignore_trailing set to true to ignore trailing '/' characters.   * @return true if both urls are the same   * @see operator==. This function should be used if you want to   * ignore trailing '/' characters.   */  bool cmp( const KURL &u, bool ignore_trailing = false ) const;  /**   * @return true if this url is a parent of @p u (or the same URL as @p u)   * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.   */  bool isParentOf( const KURL& u ) const;  /**   * 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.   * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL.   * Since HTML-style references mark   * a certain position in a document this reference is appended to every URL.   * The idea behind this is that browsers, for example, only look at the first URL while   * the rest is not of interest to them.   *   * @return An empty list on error or the list of split URLs.   *   * @param _url The URL that has to be split.   */  static List split( const QString& _url );  /**   * A convenience function.   */  static List split( const KURL& _url );  /**   * Reverses @ref split(). Only the first URL may have a reference. This reference   * is considered to be HTML-like and is appended at the end of the resulting   * joined URL.   */  static KURL join( const List& _list );  /**   * Convenience function   *   * Convert unicoded string to local encoding and use %-style   * encoding for all common delimiters / non-ascii characters.   * @param str String to encode   * @param encoding_hint Reserved, should be 0.   **/  static QString encode_string(const QString &str, int encoding_hint = 0);  /**   * Convenience function   *   * Convert unicoded string to local encoding and use %-style   * encoding for all common delimiters / non-ascii characters   * as well as the slash '/'.   * @param str String to encode   * @param encoding_hint Reserved, should be 0.   **/  static QString encode_string_no_slash(const QString &str, int encoding_hint = 0);  /**   * Convenience function   *   * Decode %-style encoding and convert from local encoding to unicode.   *   * Revers of encode_string()   * @param str String to decode   * @param encoding_hint Reserved, should be 0.   **/  static QString decode_string(const QString &str, int encoding_hint = 0);  /**   * Convenience function   *   * Returns whether '_url' is likely to be a "relative" URL instead of   * an "absolute" URL.   * @param _url URL to examine   * @return true when the URL is likely to be "relative", false otherwise.   */  static bool isRelativeURL(const QString &_url);  /**   *  Add by weiym to return the completed url.   **/  static KURL completeURL (const DOM::DOMString & _url, const DOM::DOMString & _baseUrl);protected:  void reset();  void parse( const QString& _url, int encoding_hint = 0);private:  QString m_strProtocol;  QString m_strUser;  QString m_strPass;  QString m_strHost;  QString m_strPath;  QString m_strRef_encoded;  QString m_strQuery_encoded;  KURLPrivate* d;  bool m_bIsMalformed : 1;  int freeForUse      : 7;  unsigned short int m_iPort;  QString m_strPath_encoded;  friend QDataStream & operator<< (QDataStream & s, const KURL & a);  friend QDataStream & operator>> (QDataStream & s, KURL & a);};/** * Compares URLs. They are parsed, split and compared. * Two malformed URLs with the same string representation * are nevertheless considered to be unequal. * That means no malformed URL equals anything else. */bool urlcmp( const QString& _url1, const QString& _url2 );/** * Compares URLs. They are parsed, split and compared. * Two malformed URLs with the same string representation * are nevertheless considered to be unequal. * That means no malformed URL equals anything else. * * @param _ignore_trailing Described in @ref KURL::cmp * @param _ignore_ref If @p true, disables comparison of HTML-style references. */bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref );QDataStream & operator<< (QDataStream & s, const KURL & a);QDataStream & operator>> (QDataStream & s, KURL & a);//to get an unsigned char URL for requesting image from net void uncharURL(DOM::DOMString& url, DOM::DOMString& baseUrl,unsigned char *u);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -