mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kdecore: simplify KUrl by using QDir::cleanPath() and QUrl::resolved()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c44c545b1a
commit
3cdc7da129
4 changed files with 533 additions and 767 deletions
1253
kdecore/io/kurl.cpp
1253
kdecore/io/kurl.cpp
File diff suppressed because it is too large
Load diff
|
@ -377,35 +377,12 @@ public:
|
|||
/// \reimp so that KUrl u; u.setPath(path); implies "file" protocol.
|
||||
void setPath( const QString& path );
|
||||
|
||||
/**
|
||||
* Options to be used in cleanPath
|
||||
*/
|
||||
enum CleanPathOption
|
||||
{
|
||||
/**
|
||||
* if set, occurrences of consecutive directory separators
|
||||
* (e.g. /foo//bar) are cleaned up as well. (set by default)
|
||||
*/
|
||||
SimplifyDirSeparators = 0x00,
|
||||
|
||||
/**
|
||||
* The opposite of SimplifyDirSeparators.
|
||||
*/
|
||||
KeepDirSeparators = 0x01
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(CleanPathOptions,CleanPathOption)
|
||||
|
||||
/**
|
||||
* Resolves "." and ".." components in path.
|
||||
* Some servers seem not to like the removal of extra '/'
|
||||
* even though it is against the specification in RFC 2396.
|
||||
*
|
||||
* @param options use KeepDirSeparators if you don't want to remove consecutive
|
||||
* occurrences of directory separator
|
||||
*/
|
||||
void cleanPath(const CleanPathOption& options = SimplifyDirSeparators);
|
||||
|
||||
void cleanPath();
|
||||
|
||||
/**
|
||||
* Add or remove a trailing slash to/from the path.
|
||||
|
@ -532,21 +509,6 @@ public:
|
|||
*/
|
||||
void setDirectory(const QString &dir);
|
||||
|
||||
/**
|
||||
* Changes the 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:/
|
||||
*
|
||||
* @param _dir the directory to change to
|
||||
* @return true if successful
|
||||
*/
|
||||
bool cd( const QString& _dir );
|
||||
|
||||
/**
|
||||
* Returns the URL as string, with all escape sequences intact,
|
||||
* encoded in a given charset.
|
||||
|
@ -799,7 +761,6 @@ private:
|
|||
operator QString() const; // forbidden, use url(), prettyUrl(), or pathOrUrl() instead.
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::CleanPathOptions)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::EqualsOptions)
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KUrl::DirectoryOptions)
|
||||
|
||||
|
|
|
@ -1169,9 +1169,7 @@ KUrl KDirOperator::url() const
|
|||
|
||||
void KDirOperator::cdUp()
|
||||
{
|
||||
KUrl tmp(d->currUrl);
|
||||
tmp.cd(QLatin1String(".."));
|
||||
setUrl(tmp, true);
|
||||
setUrl(d->currUrl.upUrl(), true);
|
||||
}
|
||||
|
||||
void KDirOperator::home()
|
||||
|
|
|
@ -422,7 +422,7 @@ void KDirSelectDialog::setCurrentUrl( const KUrl& url )
|
|||
|
||||
if (url.protocol() != d->m_rootUrl.protocol()) {
|
||||
KUrl u( url );
|
||||
u.cd("/");//NOTE portability?
|
||||
u.setPath(QDir::rootPath());
|
||||
d->m_treeView->setRootUrl( u );
|
||||
d->m_rootUrl = u;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue