summaryrefslogtreecommitdiffabout
path: root/microkde/kurl.h
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kurl.h
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kurl.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kurl.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/microkde/kurl.h b/microkde/kurl.h
index cd65a1c..016eb24 100644
--- a/microkde/kurl.h
+++ b/microkde/kurl.h
@@ -1,212 +1,214 @@
/* This file is part of the KDE libraries
* Copyright (C) 1999 Torben Weis <weis@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
**/
#ifndef __kurl_h__
#define __kurl_h__ "$Id$"
#include <qstring.h>
-#include <qvaluelist.h>
+#include <q3valuelist.h>
+//Added by qt3to4:
+#include <Q3CString>
-class QUrl;
+class Q3Url;
class QStringList;
template <typename K, typename V> class QMap;
class KURLPrivate;
/**
* Represents and parses a URL.
*
* A prototypical URL looks like:
* <pre>
* protocol:/user:password\@hostname:port/path/to/file.ext#reference
* </pre>
*
* KURL has some restrictions regarding the path
* encoding. KURL works internally with the decoded path and
* and encoded query. For example,
* <pre>
* http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
* </pre>
* would result in a decoded path "/cgi-bin/test me.pl"
* and in the encoded query "?cmd=Hello%20you".
* Since path is internally always encoded you may @em not use
* "%00" in the path, although this is OK for the query.
*
* @author Torben Weis <weis@kde.org>
*/
class KURL
{
public:
enum AdjustementFlags
{
NoAdjustements = 0,
StripFileProtocol = 1
};
/**
* KURL::List is a QValueList that contains KURLs with a few
* convenience methods.
* @see KURL
* @see QValueList
*/
- class List : public QValueList<KURL>
+ class List : public Q3ValueList<KURL>
{
public:
/**
* Creates an empty List.
*/
List() { }
/**
* Creates a list that contains the given URL as only
* item.
* @param url the url to add.
*/
List(const KURL &url);
/**
* Creates a list that contains the URLs from the given
* list.
* @param list the list containing the URLs as strings
*/
List(const QStringList &list);
/**
* Converts the URLs of this list to a list of strings.
* @return the list of strings
*/
QStringList toStringList() const;
};
/**
* Constructs an empty URL.
*/
KURL();
/**
* Destructs the KURL object.
*/
~KURL();
/**
* Usual constructor, to construct from a string.
* @param url A URL, not a filename. If the URL does not have a protocol
* part, "file:" is assumed.
* It is dangerous to feed unix filenames into this function,
* this will work most of the time but not always.
* For example "/home/Torben%20Weis" will be considered a URL
* pointing to the file "/home/Torben Weis" instead of to the
* file "/home/Torben%20Weis".
* This means that if you have a usual UNIX like path you
* should not use this constructor.
* Instead create an empty url and set the path by using
* @ref setPath().
* @param encoding_hint MIB of original encoding of URL.
* @see QTextCodec::mibEnum()
*/
KURL( const QString& url, int encoding_hint = 0 );
/**
* Constructor taking a char * @p url, which is an _encoded_ representation
* of the URL, exactly like the usual constructor. This is useful when
* then URL, in its encoded form, is strictly ascii.
* @param url A encoded URL. If the URL does not have a protocol part,
* "file:" is assumed.
* @param encoding_hint MIB of original encoding of URL.
* @see QTextCodec::mibEnum()
*/
KURL( const char * url, int encoding_hint = 0 );
/**
* Constructor taking a QCString @p url, which is an _encoded_ representation
* of the URL, exactly like the usual constructor. This is useful when
* then URL, in its encoded form, is strictly ascii.
* @param url A encoded URL. If the URL does not have a protocol part,
* "file:" is assumed.
* @param encoding_hint MIB of original encoding of URL.
* @see QTextCodec::mibEnum()
*/
- KURL( const QCString& url, int encoding_hint = 0 );
+ KURL( const Q3CString& url, int encoding_hint = 0 );
/**
* Copy constructor.
* @param u the KURL to copy
*/
KURL( const KURL& u );
/**
* Converts from a @ref QUrl.
* @param u the QUrl
*/
- KURL( const QUrl &u );
+ KURL( const Q3Url &u );
/**
* Constructor allowing relative URLs.
*
* @param _baseurl The base url.
* @param _rel_url A relative or absolute URL.
* If this is an absolute URL then @p _baseurl will be ignored.
* If this is a relative URL it will be combined with @p _baseurl.
* Note that _rel_url should be encoded too, in any case.
* So do NOT pass a path here (use setPath or addPath instead).
* @param encoding_hint MIB of original encoding of URL.
* @see QTextCodec::mibEnum()
*/
KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 );
/**
* Returns the protocol for the URL (i.e., file, http, etc.).
* @return the protocol of the URL, does not include the colon. If the
* URL is malformed, QString::null will be returned.
**/
QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; }
/**
* Sets the protocol for the URL (i.e., file, http, etc.)
* @param _txt the new protocol of the URL (without colon)
**/
void setProtocol( const QString& _txt );
/**
* Returns the decoded user name (login, user id, ...) included in the URL.
* @return the user name or QString::null if there is no user name
**/
QString user() const { return m_strUser; }
/**
* Sets the user name (login, user id, ...) included in the URL.
*
* Special characters in the user name will appear encoded in the URL.
* @param _txt the name of the user or QString::null to remove the user
**/
void setUser( const QString& _txt );
/**
* Test to see if this URL has a user name included in it.
* @return true if the URL has an non-empty user name
**/
bool hasUser() const { return !m_strUser.isEmpty(); }
/**
* Returns the decoded password (corresponding to \ref user()) included in the URL.
* @return the password or QString::null if it does not exist
**/
QString pass() const { return m_strPass; }
/**
* Sets the password (corresponding to @ref user()) included in the URL.
*
* Special characters in the password will appear encoded in the URL.
* Note that a password can only appear in a URL string if you also set
* a user.
* @param _txt the password to set or QString::null to remove the password
* @see #setUser
* @see #hasUser
**/
void setPass( const QString& _txt );
/**
* Test to see if this URL has a password included in it.
* @return true if there is a non-empty password set
**/
@@ -597,129 +599,129 @@ public:
* path unchanged.
* @param encoding_hint MIB of encoding to use.
* @return The complete URL, with all escape sequences intact, encoded
* in a given charset.
* @see QTextCodec::mibEnum()
* @see prettyURL()
*/
QString url( int _trailing = 0, int encoding_hint = 0) const;
/**
* Returns the URL as string in human-friendly format.
* Example:
* <pre>
* http://localhost:8080/test.cgi?test=hello world&name=fred
* </pre>
* @param _trailing -1 to strip a trailing '/' from the path, +1 adds
* a trailing '/' if there is none yet and 0 returns the
* path unchanged.
* @return A human readable URL, with no non-necessary encodings/escaped
* characters. Password will not be shown.
* @see url()
*/
QString prettyURL( int _trailing = 0) const;
/**
* 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.
*/
QString htmlURL() const;
/**
* Returns the URL as string, escaped for HTML.
* Example:
* <pre>
* http://localhost:8080/test.cgi?test=hello world&name=fred
* </pre>
* @return A human readable URL, with no non-necessary encodings/escaped
* characters. Password will not be shown.
*/
QString prettyURL( int _trailing, AdjustementFlags _flags) const;
// ### BIC: Merge the two above
/**
* Test to see if the KURL is empty.
* @return true if the URL 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.
* @return a URL that is a level higher
*/
KURL upURL( ) const;
KURL& operator=( const KURL& _u );
KURL& operator=( const QString& _url );
KURL& operator=( const char * _url );
- KURL& operator=( const QUrl & u );
+ KURL& operator=( const Q3Url & 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 ); }
/**
* The same as equals(), just with a less obvious name.
* Compares 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.
* @deprecated
*/
bool cmp( const KURL &u, bool ignore_trailing = false ) const;
/**
* Compares 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.
* @since 3.1
*/
bool equals( const KURL &u, bool ignore_trailing = false ) const;
/**
* Checks whether the given URL is parent of this URL.
* For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.
* @return true if this url is a parent of @p u (or the same URL as @p u)
*/
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.
*
*
* @param _url The URL that has to be split.
* @return An empty list on error or the list of split URLs.
* @see #hasSubURL
*/
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.
* 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.