Use std::unordered_map consistently and support legacy Qt

This commit is contained in:
Martchus 2020-03-02 15:38:38 +01:00
parent 5227a7961e
commit cb0d414018
4 changed files with 25 additions and 1 deletions

View File

@ -19,6 +19,7 @@ set(HEADER_FILES
syncthingconfig.h
syncthingprocess.h
syncthingservice.h
qstringhash.h
utils.h)
set(SRC_FILES
syncthingdir.cpp

21
connector/qstringhash.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef SYNCTHING_CONNECTOR_QSTRING_HASH_H
#define SYNCTHING_CONNECTOR_QSTRING_HASH_H
#include <QString>
#include <functional>
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
namespace std {
template <> struct hash<QString> {
inline std::size_t operator()(const QString &str) const
{
return qHash(str);
}
};
} // namespace std
#endif
#endif // SYNCTHING_CONNECTOR_QSTRING_HASH_H

View File

@ -1,6 +1,7 @@
#ifndef DATA_SYNCTHINGDEV_H
#define DATA_SYNCTHINGDEV_H
#include "./qstringhash.h"
#include "./syncthingcompletion.h"
#include <c++utilities/chrono/datetime.h>

View File

@ -1,6 +1,7 @@
#ifndef DATA_SYNCTHINGDIR_H
#define DATA_SYNCTHINGDIR_H
#include "./qstringhash.h"
#include "./syncthingcompletion.h"
#include <c++utilities/chrono/datetime.h>
@ -130,7 +131,7 @@ struct LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingDir {
int scanningPercentage = 0;
double scanningRate = 0;
double fileSystemWatcherDelay = 0.0;
std::map<QString, SyncthingCompletion> completionByDevice;
std::unordered_map<QString, SyncthingCompletion> completionByDevice;
QString globalError;
quint64 pullErrorCount = 0;
std::vector<SyncthingItemError> itemErrors;