diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-07 11:05:58 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-07 11:05:58 +0900 |
commit | bd8764cbbb0ec003549261586867a6ae6f46f5cd (patch) | |
tree | e751dde2d07a0675ce79cff0c6487db0098338df /lib/events/event.cpp | |
parent | 1742f6e0f0af6aa6deefe2cee4bc41877f4ac2ad (diff) | |
download | libquotient-bd8764cbbb0ec003549261586867a6ae6f46f5cd.tar.gz libquotient-bd8764cbbb0ec003549261586867a6ae6f46f5cd.zip |
Reinstate EventTypeRegistry, keeping EventTypeTraits<> around
You can now get a (much more readable) Matrix type (event_mtype_t) for the internal event type code (event_type_t) using EventTypeRegistry::getMatrixType().
Diffstat (limited to 'lib/events/event.cpp')
-rw-r--r-- | lib/events/event.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/events/event.cpp b/lib/events/event.cpp index 44bf79a1..2cad1462 100644 --- a/lib/events/event.cpp +++ b/lib/events/event.cpp @@ -24,10 +24,16 @@ using namespace QMatrixClient; -event_type_t QMatrixClient::nextTypeId() +event_type_t EventTypeRegistry::initializeTypeId(event_mtype_t matrixTypeId) { - static event_type_t _id = EventTypeTraits<void>::id; - return ++_id; + const auto id = get().eventTypes.size(); + get().eventTypes.push_back(matrixTypeId); + if (strncmp(matrixTypeId, "", 1) == 0) + qDebug(EVENTS) << "Initialized unknown event type with id" << id; + else + qDebug(EVENTS) << "Initialized event type" << matrixTypeId + << "with id" << id; + return id; } Event::Event(Type type, const QJsonObject& json) |