From eefe7203109ee4da56a5f93cfbfb760589b97dc9 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 19 Jun 2013 10:12:55 -0500 Subject: Add ability to ignore internal reference URLs in KURL equality comparison --- tdecore/kurl.cpp | 7 ++++++- tdecore/kurl.h | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tdecore/kurl.cpp b/tdecore/kurl.cpp index 0b5f88c3d..7fd8ad26a 100644 --- a/tdecore/kurl.cpp +++ b/tdecore/kurl.cpp @@ -1182,6 +1182,11 @@ bool KURL::cmp( const KURL &u, bool ignore_trailing ) const } bool KURL::equals( const KURL &_u, bool ignore_trailing ) const +{ + return equals(_u, ignore_trailing, false); +} + +bool KURL::equals( const KURL &_u, bool ignore_trailing, bool ignore_internalReferenceURLS ) const { if ( !isValid() || !_u.isValid() ) return false; @@ -1200,7 +1205,7 @@ bool KURL::equals( const KURL &_u, bool ignore_trailing ) const m_strQuery_encoded == _u.m_strQuery_encoded && m_strRef_encoded == _u.m_strRef_encoded && m_iPort == _u.m_iPort && - d->m_strInternalReferenceURL == _u.d->m_strInternalReferenceURL ) + ((ignore_internalReferenceURLS) || (d->m_strInternalReferenceURL == _u.d->m_strInternalReferenceURL)) ) return true; return false; diff --git a/tdecore/kurl.h b/tdecore/kurl.h index bcb44907e..740c8a0df 100644 --- a/tdecore/kurl.h +++ b/tdecore/kurl.h @@ -1483,7 +1483,23 @@ public: * * @since 3.1 */ - bool equals( const KURL &u, bool ignore_trailing = false ) const; // TODO KDE4: add bool _ignore_ref = false + bool equals( const KURL &u, bool ignore_trailing = false ) const; + + /** + * @brief Compares this URL with another one + * + * @param u the URL to compare this one with + * @param ignore_trailing set to @c true to ignore trailing @c '/' characters + * @param ignore_internalReferenceURLS set to @c true to ignore the internal reference URLs during comparison + * + * @return @c true if both urls are the same + * + * @see operator==. This function should be used if you want to + * ignore trailing @c '/' characters + * + * @since R14.0.0 + */ + bool equals( const KURL &u, bool ignore_trailing, bool ignore_internalReferenceURLS ) const; // TODO KDE4: add bool _ignore_ref = false /** * @brief Tests if the given URL is parent of this URL -- cgit v1.2.1