From 0dd491fbd189baaabadcab2344a05e3cf3898287 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sat, 2 Jun 2018 13:32:47 +0900 Subject: csapi: Use Omittable<> container instead of intrusive 'omitted' field Also: use the latest feature of GTAD, +set/+on, to make gtad.yaml more compact. --- lib/csapi/list_public_rooms.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/csapi/list_public_rooms.cpp') diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index b60d14fd..97beba1c 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -94,10 +94,10 @@ class GetPublicRoomsJob::Private QVector chunk; QString nextBatch; QString prevBatch; - qint64 totalRoomCountEstimate; + Omittable totalRoomCountEstimate; }; -BaseJob::Query queryToGetPublicRooms(int limit, const QString& since, const QString& server) +BaseJob::Query queryToGetPublicRooms(Omittable limit, const QString& since, const QString& server) { BaseJob::Query _q; _q.addQueryItem("limit", QString("%1").arg(limit)); @@ -108,14 +108,14 @@ BaseJob::Query queryToGetPublicRooms(int limit, const QString& since, const QStr return _q; } -QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, int limit, const QString& since, const QString& server) +QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable limit, const QString& since, const QString& server) { return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server)); } -GetPublicRoomsJob::GetPublicRoomsJob(int limit, const QString& since, const QString& server) +GetPublicRoomsJob::GetPublicRoomsJob(Omittable limit, const QString& since, const QString& server) : BaseJob(HttpVerb::Get, "GetPublicRoomsJob", basePath % "/publicRooms", queryToGetPublicRooms(limit, since, server), @@ -141,7 +141,7 @@ const QString& GetPublicRoomsJob::prevBatch() const return d->prevBatch; } -qint64 GetPublicRoomsJob::totalRoomCountEstimate() const +Omittable GetPublicRoomsJob::totalRoomCountEstimate() const { return d->totalRoomCountEstimate; } @@ -166,9 +166,6 @@ namespace QMatrixClient QJsonObject toJson(const QueryPublicRoomsJob::Filter& pod) { QJsonObject _json; - if (pod.omitted) - return _json; - addToJson(_json, "generic_search_term", pod.genericSearchTerm); return _json; } @@ -209,7 +206,7 @@ class QueryPublicRoomsJob::Private QVector chunk; QString nextBatch; QString prevBatch; - qint64 totalRoomCountEstimate; + Omittable totalRoomCountEstimate; }; BaseJob::Query queryToQueryPublicRooms(const QString& server) @@ -220,7 +217,7 @@ BaseJob::Query queryToQueryPublicRooms(const QString& server) return _q; } -QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, int limit, const QString& since, const Filter& filter) +QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable limit, const QString& since, const Omittable& filter) : BaseJob(HttpVerb::Post, "QueryPublicRoomsJob", basePath % "/publicRooms", queryToQueryPublicRooms(server)) @@ -250,7 +247,7 @@ const QString& QueryPublicRoomsJob::prevBatch() const return d->prevBatch; } -qint64 QueryPublicRoomsJob::totalRoomCountEstimate() const +Omittable QueryPublicRoomsJob::totalRoomCountEstimate() const { return d->totalRoomCountEstimate; } -- cgit v1.2.3