Utils: Make FileName comparison work with URLs

Change-Id: Idfd8623338f3a74250c4bf264579cbb4ec5e70b8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2019-05-20 13:39:27 +02:00
parent 0595e67c82
commit d8f459d48e

View File

@@ -800,32 +800,36 @@ QVariant FileName::toVariant() const
bool FileName::operator==(const FileName &other) const bool FileName::operator==(const FileName &other) const
{ {
if (!m_url.isEmpty())
return m_url == other.m_url;
return QString::compare(m_data, other.m_data, HostOsInfo::fileNameCaseSensitivity()) == 0; return QString::compare(m_data, other.m_data, HostOsInfo::fileNameCaseSensitivity()) == 0;
} }
bool FileName::operator!=(const FileName &other) const bool FileName::operator!=(const FileName &other) const
{ {
return !(m_data == other.m_data); return !(*this == other);
} }
bool FileName::operator<(const FileName &other) const bool FileName::operator<(const FileName &other) const
{ {
if (!m_url.isEmpty())
return m_url < other.m_url;
return QString::compare(m_data, other.m_data, HostOsInfo::fileNameCaseSensitivity()) < 0; return QString::compare(m_data, other.m_data, HostOsInfo::fileNameCaseSensitivity()) < 0;
} }
bool FileName::operator<=(const FileName &other) const bool FileName::operator<=(const FileName &other) const
{ {
return QString::compare(m_data, other.m_data, HostOsInfo::fileNameCaseSensitivity()) <= 0; return !(other < *this);
} }
bool FileName::operator>(const FileName &other) const bool FileName::operator>(const FileName &other) const
{ {
return other.m_data < m_data; return other < *this;
} }
bool FileName::operator>=(const FileName &other) const bool FileName::operator>=(const FileName &other) const
{ {
return other.m_data <= m_data; return !(*this < other);
} }
FileName FileName::operator+(const QString &s) const FileName FileName::operator+(const QString &s) const