diff --git a/src/core/kfileitem.h b/src/core/kfileitem.h --- a/src/core/kfileitem.h +++ b/src/core/kfileitem.h @@ -486,6 +486,18 @@ */ bool operator!=(const KFileItem &other) const; + /** + * Returns true if other's URL is lexically greater than this url; otherwise returns false + * @since 5.47 + */ + bool operator<(const KFileItem &other) const; + + /** + * Returns true if url other is lexically greater than this url; otherwise returns false + * @since 5.47 + */ + bool operator<(const QUrl &other) const; + /** * Converts this KFileItem to a QVariant, this allows to use KFileItem * in QVariant() constructor diff --git a/src/core/kfileitem.cpp b/src/core/kfileitem.cpp --- a/src/core/kfileitem.cpp +++ b/src/core/kfileitem.cpp @@ -1236,6 +1236,22 @@ return !operator==(other); } +bool KFileItem::operator<(const KFileItem &other) const +{ + if (!d || !other.d) { + return false; + } + return d->m_url < other.d->m_url; +} + +bool KFileItem::operator<(const QUrl &other) const +{ + if (!d) { + return true; + } + return d->m_url < other; +} + KFileItem::operator QVariant() const { return qVariantFromValue(*this);