Add std::hash for FileName

Change-Id: Iaef49c826c0febf3a9cb1fdc97de9f92c261cf40
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Eike Ziller
2017-06-13 14:57:30 +02:00
parent a36536813f
commit 2897414d3b
2 changed files with 16 additions and 1 deletions

View File

@@ -27,6 +27,8 @@
#include "utils_global.h"
#include "hostosinfo.h"
#include <QCoreApplication>
#include <QXmlStreamWriter> // Mac.
#include <QMetaType>
@@ -233,4 +235,18 @@ QT_BEGIN_NAMESPACE
QTCREATOR_UTILS_EXPORT uint qHash(const Utils::FileName &a);
QT_END_NAMESPACE
namespace std {
template<> struct hash<Utils::FileName>
{
using argument_type = Utils::FileName;
using result_type = size_t;
result_type operator()(const argument_type &fn) const
{
if (Utils::HostOsInfo::fileNameCaseSensitivity() == Qt::CaseInsensitive)
return hash<string>()(fn.toString().toUpper().toStdString());
return hash<string>()(fn.toString().toStdString());
}
};
} // namespace std
Q_DECLARE_METATYPE(Utils::FileName)