diff options
-rw-r--r-- | connection.cpp | 3 | ||||
-rw-r--r-- | jobs/syncjob.cpp | 5 | ||||
-rw-r--r-- | room.cpp | 17 | ||||
-rw-r--r-- | room.h | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/connection.cpp b/connection.cpp index fe0cb251..d2acf928 100644 --- a/connection.cpp +++ b/connection.cpp @@ -333,8 +333,7 @@ void Connection::saveState(const QUrl &toFile) { QJsonObject rooms; for (auto i : this->roomMap()) { - QJsonObject roomObj; - i->toJson(roomObj); + QJsonObject roomObj = i->toJson(); rooms[i->id()] = roomObj; } diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 1e71e215..bbec968e 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -62,8 +62,7 @@ SyncDataList&& SyncData::takeRoomData() BaseJob::Status SyncJob::parseJson(const QJsonDocument& data) { - d->parseJson(data); - return Success; + return d->parseJson(data); } BaseJob::Status SyncData::parseJson(const QJsonDocument &data) { @@ -89,7 +88,7 @@ BaseJob::Status SyncData::parseJson(const QJsonDocument &data) { roomData.emplace_back(rkey, roomState.enumVal, rs[rkey].toObject()); } qCDebug(PROFILER) << "*** SyncData::parseJson():" << et.elapsed() << "ms"; - return Success; + return BaseJob::Success; } SyncRoomData::SyncRoomData(const QString& roomId_, JoinState joinState_, @@ -119,7 +119,7 @@ class Room::Private void setLastReadEvent(User* u, const QString& eventId); rev_iter_pair_t promoteReadMarker(User* u, rev_iter_t newMarker); - void toJson(QJsonObject &out); + QJsonObject toJson() const; private: QString calculateDisplayname() const; @@ -877,7 +877,7 @@ void Room::Private::updateDisplayname() emit q->displaynameChanged(q); } -void Room::Private::toJson(QJsonObject &out) { +QJsonObject Room::Private::toJson() const { QJsonValue nowTimestamp { QDateTime::currentMSecsSinceEpoch() }; QJsonArray stateEvents; @@ -890,7 +890,7 @@ void Room::Private::toJson(QJsonObject &out) { nameEvent.insert("content", nameEventContent); stateEvents.append(nameEvent); - for (auto i : this->membersMap) { + for (const auto &i : this->membersMap) { QJsonObject content; content.insert("membership", QStringLiteral("join")); content.insert("displayname", i->displayname()); @@ -908,7 +908,7 @@ void Room::Private::toJson(QJsonObject &out) { { QJsonArray aliases; - for (auto i : this->aliases) { + for (const auto &i : this->aliases) { aliases.append(QJsonValue(i)); } @@ -935,11 +935,14 @@ void Room::Private::toJson(QJsonObject &out) { QJsonObject roomStateObj; roomStateObj.insert("events", stateEvents); - out.insert("state", roomStateObj); + + QJsonObject result; + result.insert("state", roomStateObj); + return result; } -void Room::toJson(QJsonObject &out) const { - d->toJson(out); +QJsonObject Room::toJson() const { + return d->toJson(); } MemberSorter Room::memberSorter() const @@ -142,7 +142,7 @@ namespace QMatrixClient MemberSorter memberSorter() const; - void toJson(QJsonObject &out) const; + QJsonObject toJson() const; public slots: void postMessage(const QString& plainText, |