aboutsummaryrefslogtreecommitdiff
path: root/jobs
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-13 23:55:35 +0200
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-10-14 09:17:32 +0200
commitee214de7b829b08155bc223ea64c61c9ce2bcdf3 (patch)
treed81c2238692674a131a0353ddf915d278d9ad355 /jobs
parent76c42a9863b83229e6afaf4be32e9582e3d97d3f (diff)
downloadlibquotient-ee214de7b829b08155bc223ea64c61c9ce2bcdf3.tar.gz
libquotient-ee214de7b829b08155bc223ea64c61c9ce2bcdf3.zip
Make JoinState (de)serializable library-wide
Diffstat (limited to 'jobs')
-rw-r--r--jobs/syncjob.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/jobs/syncjob.cpp b/jobs/syncjob.cpp
index 6d37db5c..ce5dd894 100644
--- a/jobs/syncjob.cpp
+++ b/jobs/syncjob.cpp
@@ -69,19 +69,13 @@ BaseJob::Status SyncData::parseJson(const QJsonDocument &data)
// TODO: account_data
QJsonObject rooms = json.value("rooms").toObject();
- static const struct { QString jsonKey; JoinState enumVal; } roomStates[]
+ for (size_t i = 0; i < JoinStateStrings.size(); ++i)
{
- { "join", JoinState::Join },
- { "invite", JoinState::Invite },
- { "leave", JoinState::Leave }
- };
- for (const auto& roomState: roomStates)
- {
- const QJsonObject rs = rooms.value(roomState.jsonKey).toObject();
+ const auto rs = rooms.value(JoinStateStrings[i]).toObject();
// We have a Qt container on the right and an STL one on the left
roomData.reserve(static_cast<size_t>(rs.size()));
for(auto roomIt = rs.begin(); roomIt != rs.end(); ++roomIt)
- roomData.emplace_back(roomIt.key(), roomState.enumVal,
+ roomData.emplace_back(roomIt.key(), JoinState(i),
roomIt.value().toObject());
}
qCDebug(PROFILER) << "*** SyncData::parseJson():" << et.elapsed() << "ms";