diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-01 22:48:38 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-07-04 09:07:32 +0900 |
commit | f1ffe1e7a3e81c07a07a8416ce307e4413ec8fbc (patch) | |
tree | f2435183d11a4cea52a7532eb9ff3d4d837e1d22 /lib/events/directchatevent.cpp | |
parent | d5397fe5ae2ca34d5cfb11394dac17728a2b50ce (diff) | |
download | libquotient-f1ffe1e7a3e81c07a07a8416ce307e4413ec8fbc.tar.gz libquotient-f1ffe1e7a3e81c07a07a8416ce307e4413ec8fbc.zip |
Event types system remade to be extensible
There were two common points that had to be updated every time a new event is introduced:
the EventType enumeration and one of 3 doMakeEvent<> specialisations. The new code
has a template class, EventFactory<>, that uses a list of static factory methods
to create events instead of typelists used in doMakeEvent<>(); the EventType enumeration
is replaced with a namespace populated with constants as necessary.
In general, EventType is considered a deprecated mechanism altogether; instead, a set
of facilities is provided: is<>() to check if an event has a certain type (to replace
comparison against an EventType value) and visit<>() to execute actions based on
the event type (replacing switch statements over EventType values).
Closes #129.
Diffstat (limited to 'lib/events/directchatevent.cpp')
-rw-r--r-- | lib/events/directchatevent.cpp | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/events/directchatevent.cpp b/lib/events/directchatevent.cpp index 63d638a3..6f5d34f2 100644 --- a/lib/events/directchatevent.cpp +++ b/lib/events/directchatevent.cpp @@ -18,18 +18,12 @@ #include "directchatevent.h" -#include "converters.h" - using namespace QMatrixClient; -DirectChatEvent::DirectChatEvent(const QJsonObject& obj) - : Event(Type::DirectChat, obj) -{ } - QMultiHash<QString, QString> DirectChatEvent::usersToDirectChats() const { QMultiHash<QString, QString> result; - const auto json = contentJson(); + const auto& json = contentJson(); for (auto it = json.begin(); it != json.end(); ++it) { // Beware of range-for's over temporary returned from temporary |