diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-28 16:33:31 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-07-28 16:38:38 +0200 |
commit | 683ee2ec1d198a9f19572e42d78fa0b9939d7f10 (patch) | |
tree | 431ff9de138261fac04ec4f0d1166b3ca968c24e /common/typeindex.cpp | |
parent | 98411f1b4af7a420d81d4de0f6115be81680896f (diff) | |
download | sink-683ee2ec1d198a9f19572e42d78fa0b9939d7f10.tar.gz sink-683ee2ec1d198a9f19572e42d78fa0b9939d7f10.zip |
Fixed warnings
Diffstat (limited to 'common/typeindex.cpp')
-rw-r--r-- | common/typeindex.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index 1dd54e8..47512e8 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -70,14 +70,12 @@ static QByteArray toSortableByteArray(const QVariant &value) | |||
70 | return QByteArray::number(std::numeric_limits<unsigned int>::max()); | 70 | return QByteArray::number(std::numeric_limits<unsigned int>::max()); |
71 | } | 71 | } |
72 | 72 | ||
73 | switch (value.type()) { | 73 | if (value.canConvert<QDateTime>()) { |
74 | case QMetaType::QDateTime: | 74 | return toSortableByteArrayImpl(value.toDateTime()); |
75 | return toSortableByteArrayImpl(value.toDateTime()); | ||
76 | default: | ||
77 | SinkWarning() << "Not knowing how to convert a" << value.typeName() | ||
78 | << "to a sortable key, falling back to default conversion"; | ||
79 | return getByteArray(value); | ||
80 | } | 75 | } |
76 | SinkWarning() << "Not knowing how to convert a" << value.typeName() | ||
77 | << "to a sortable key, falling back to default conversion"; | ||
78 | return getByteArray(value); | ||
81 | } | 79 | } |
82 | 80 | ||
83 | TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type) | 81 | TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type) |
@@ -104,13 +102,11 @@ QByteArray TypeIndex::sampledPeriodIndexName(const QByteArray &rangeBeginPropert | |||
104 | 102 | ||
105 | static unsigned int bucketOf(const QVariant &value) | 103 | static unsigned int bucketOf(const QVariant &value) |
106 | { | 104 | { |
107 | switch (value.type()) { | 105 | if (value.canConvert<QDateTime>()) { |
108 | case QMetaType::QDateTime: | 106 | return value.value<QDateTime>().date().toJulianDay() / 7; |
109 | return value.value<QDateTime>().date().toJulianDay() / 7; | ||
110 | default: | ||
111 | SinkError() << "Not knowing how to get the bucket of a" << value.typeName(); | ||
112 | return {}; | ||
113 | } | 107 | } |
108 | SinkError() << "Not knowing how to get the bucket of a" << value.typeName(); | ||
109 | return {}; | ||
114 | } | 110 | } |
115 | 111 | ||
116 | static void update(TypeIndex::Action action, const QByteArray &indexName, const QByteArray &key, const QByteArray &value, Sink::Storage::DataStore::Transaction &transaction) | 112 | static void update(TypeIndex::Action action, const QByteArray &indexName, const QByteArray &key, const QByteArray &value, Sink::Storage::DataStore::Transaction &transaction) |