From 683ee2ec1d198a9f19572e42d78fa0b9939d7f10 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 28 Jul 2018 16:33:31 +0200 Subject: Fixed warnings --- common/typeindex.cpp | 22 +++++++++------------- 1 file 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) return QByteArray::number(std::numeric_limits::max()); } - switch (value.type()) { - case QMetaType::QDateTime: - return toSortableByteArrayImpl(value.toDateTime()); - default: - SinkWarning() << "Not knowing how to convert a" << value.typeName() - << "to a sortable key, falling back to default conversion"; - return getByteArray(value); + if (value.canConvert()) { + return toSortableByteArrayImpl(value.toDateTime()); } + SinkWarning() << "Not knowing how to convert a" << value.typeName() + << "to a sortable key, falling back to default conversion"; + return getByteArray(value); } TypeIndex::TypeIndex(const QByteArray &type, const Sink::Log::Context &ctx) : mLogCtx(ctx), mType(type) @@ -104,13 +102,11 @@ QByteArray TypeIndex::sampledPeriodIndexName(const QByteArray &rangeBeginPropert static unsigned int bucketOf(const QVariant &value) { - switch (value.type()) { - case QMetaType::QDateTime: - return value.value().date().toJulianDay() / 7; - default: - SinkError() << "Not knowing how to get the bucket of a" << value.typeName(); - return {}; + if (value.canConvert()) { + return value.value().date().toJulianDay() / 7; } + SinkError() << "Not knowing how to get the bucket of a" << value.typeName(); + return {}; } static void update(TypeIndex::Action action, const QByteArray &indexName, const QByteArray &key, const QByteArray &value, Sink::Storage::DataStore::Transaction &transaction) -- cgit v1.2.3