diff options
Diffstat (limited to 'jobs')
-rw-r--r-- | jobs/syncjob.cpp | 10 | ||||
-rw-r--r-- | jobs/syncjob.h | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp index 3a7573bc..c04a74d7 100644 --- a/jobs/syncjob.cpp +++ b/jobs/syncjob.cpp @@ -40,7 +40,7 @@ class SyncJob::Private int timeout; QString nextBatch; - QList<SyncRoomData> roomData; + SyncData roomData; }; static size_t jobId = 0; @@ -84,7 +84,7 @@ QString SyncJob::nextBatch() const return d->nextBatch; } -QList<SyncRoomData> SyncJob::roomData() const +const SyncData& SyncJob::roomData() const { return d->roomData; } @@ -128,9 +128,9 @@ void SyncJob::parseJson(const QJsonDocument& data) { const QJsonObject rs = rooms.value(roomState.jsonKey).toObject(); d->roomData.reserve(rs.size()); - for( auto r = rs.begin(); r != rs.end(); ++r ) + for( auto rkey: rs.keys() ) { - d->roomData.push_back({r.key(), r.value().toObject(), roomState.enumVal}); + d->roomData.push_back({rkey, roomState.enumVal, rs[rkey].toObject()}); } } @@ -144,7 +144,7 @@ void SyncRoomData::EventList::fromJson(const QJsonObject& roomContents) swap(l); } -SyncRoomData::SyncRoomData(QString roomId_, const QJsonObject& room_, JoinState joinState_) +SyncRoomData::SyncRoomData(QString roomId_, JoinState joinState_, const QJsonObject& room_) : roomId(roomId_) , joinState(joinState_) , state("state") diff --git a/jobs/syncjob.h b/jobs/syncjob.h index c5204c63..79185dc9 100644 --- a/jobs/syncjob.h +++ b/jobs/syncjob.h @@ -52,8 +52,11 @@ namespace QMatrixClient int highlightCount; int notificationCount; - SyncRoomData(QString roomId_, const QJsonObject& room_, JoinState joinState_); + SyncRoomData(QString roomId_ = QString(), + JoinState joinState_ = JoinState::Join, + const QJsonObject& room_ = QJsonObject()); }; + using SyncData = QVector<SyncRoomData>; class ConnectionData; class SyncJob: public BaseJob @@ -67,7 +70,7 @@ namespace QMatrixClient void setPresence(QString presence); void setTimeout(int timeout); - QList<SyncRoomData> roomData() const; + const SyncData& roomData() const; QString nextBatch() const; protected: @@ -80,5 +83,6 @@ namespace QMatrixClient Private* d; }; } +Q_DECLARE_TYPEINFO(QMatrixClient::SyncRoomData, Q_MOVABLE_TYPE); #endif // QMATRIXCLIENT_SYNCJOB_H |