Add qHash(QMimeType)

QMimeTypes can be compared for equality, so qHash should be overloaded, too.

[ChangeLog][QtCore][QMimeType] Added qHash(QMimeType).

Change-Id: I32608760cb7ef5e47f49192d0205cdca3d4e1765
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Marc Mutz 2015-04-08 19:44:48 +02:00
parent adfe9ea1e0
commit 0495970631
2 changed files with 17 additions and 0 deletions

View File

@ -43,6 +43,7 @@
#include <QtCore/QDebug>
#include <QtCore/QLocale>
#include <QtCore/QHashFunctions>
#include <memory>
@ -180,6 +181,18 @@ bool QMimeType::operator==(const QMimeType &other) const
return d == other.d || d->name == other.d->name;
}
/*!
\since 5.6
\relates QMimeType
Returns the hash value for \a key, using
\a seed to seed the calculation.
*/
uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW
{
return qHash(key.d->name, seed);
}
/*!
\fn bool QMimeType::operator!=(const QMimeType &other) const;
Returns \c true if \a other does not equal this QMimeType object, otherwise returns \c false.

View File

@ -46,6 +46,9 @@ QT_BEGIN_NAMESPACE
class QMimeTypePrivate;
class QFileinfo;
class QStringList;
class QMimeType;
Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed = 0) Q_DECL_NOTHROW;
class Q_CORE_EXPORT QMimeType
{
@ -100,6 +103,7 @@ protected:
friend class QMimeXMLProvider;
friend class QMimeBinaryProvider;
friend class QMimeTypePrivate;
friend Q_CORE_EXPORT uint qHash(const QMimeType &key, uint seed) Q_DECL_NOTHROW;
QExplicitlySharedDataPointer<QMimeTypePrivate> d;
};