From 853fda2e7942ffb3bc8051e6411faa23cff6f3c2 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Thu, 3 May 2018 12:14:10 +0900 Subject: Cleanup --- lib/converters.h | 35 ++++++++++++++++++----------------- lib/events/roommemberevent.h | 7 ++++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/lib/converters.h b/lib/converters.h index cfe9c01c..baa14c7b 100644 --- a/lib/converters.h +++ b/lib/converters.h @@ -96,32 +96,32 @@ namespace QMatrixClient template <> struct FromJson { - bool operator()(const QJsonValue& jv) const { return jv.toBool(); } + auto operator()(const QJsonValue& jv) const { return jv.toBool(); } }; template <> struct FromJson { - int operator()(const QJsonValue& jv) const { return jv.toInt(); } + auto operator()(const QJsonValue& jv) const { return jv.toInt(); } }; template <> struct FromJson { - double operator()(const QJsonValue& jv) const { return jv.toDouble(); } + auto operator()(const QJsonValue& jv) const { return jv.toDouble(); } }; template <> struct FromJson { - qint64 operator()(const QJsonValue& jv) const { return qint64(jv.toDouble()); } + auto operator()(const QJsonValue& jv) const { return qint64(jv.toDouble()); } }; template <> struct FromJson { - QString operator()(const QJsonValue& jv) const { return jv.toString(); } + auto operator()(const QJsonValue& jv) const { return jv.toString(); } }; template <> struct FromJson { - QDateTime operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return QDateTime::fromMSecsSinceEpoch(fromJson(jv), Qt::UTC); } @@ -129,7 +129,7 @@ namespace QMatrixClient template <> struct FromJson { - QDate operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return fromJson(jv).date(); } @@ -137,7 +137,7 @@ namespace QMatrixClient template <> struct FromJson { - QJsonObject operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject(); } @@ -145,7 +145,7 @@ namespace QMatrixClient template <> struct FromJson { - QJsonArray operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toArray(); } @@ -153,10 +153,11 @@ namespace QMatrixClient template struct FromJson> { - std::vector operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { + using size_type = typename std::vector::size_type; const auto jsonArray = jv.toArray(); - std::vector vect; vect.resize(size_t(jsonArray.size())); + std::vector vect; vect.resize(size_type(jsonArray.size())); std::transform(jsonArray.begin(), jsonArray.end(), vect.begin(), FromJson()); return vect; @@ -165,7 +166,7 @@ namespace QMatrixClient template struct FromJson> { - QVector operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto jsonArray = jv.toArray(); QVector vect; vect.resize(jsonArray.size()); @@ -177,7 +178,7 @@ namespace QMatrixClient template struct FromJson> { - QList operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto jsonArray = jv.toArray(); QList sl; sl.reserve(jsonArray.size()); @@ -191,7 +192,7 @@ namespace QMatrixClient template <> struct FromJson { - inline QByteArray operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return fromJson(jv).toLatin1(); } @@ -199,7 +200,7 @@ namespace QMatrixClient template <> struct FromJson { - inline auto operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject().toVariantMap(); } @@ -208,7 +209,7 @@ namespace QMatrixClient #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) template <> struct FromJson { - inline auto operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { return jv.toObject().toVariantHash(); } @@ -217,7 +218,7 @@ namespace QMatrixClient template struct FromJson> { - QHash operator()(const QJsonValue& jv) const + auto operator()(const QJsonValue& jv) const { const auto json = jv.toObject(); QHash h; h.reserve(json.size()); diff --git a/lib/events/roommemberevent.h b/lib/events/roommemberevent.h index 89b970c9..5f1e578d 100644 --- a/lib/events/roommemberevent.h +++ b/lib/events/roommemberevent.h @@ -56,12 +56,14 @@ namespace QMatrixClient using MembershipType = MemberEventContent::MembershipType; + explicit RoomMemberEvent(Type type, const QJsonObject& obj) + : StateEvent(type, obj) + { } RoomMemberEvent(MemberEventContent&& c) : StateEvent(Type::RoomMember, c) { } explicit RoomMemberEvent(const QJsonObject& obj) - : StateEvent(Type::RoomMember, obj) -// , _userId(obj["state_key"].toString()) + : RoomMemberEvent(Type::RoomMember, obj) { } MembershipType membership() const { return content().membership; } @@ -72,7 +74,6 @@ namespace QMatrixClient QUrl avatarUrl() const { return content().avatarUrl; } private: -// QString _userId; REGISTER_ENUM(MembershipType) }; } // namespace QMatrixClient -- cgit v1.2.3