diff options
author | KitsuneRal <Kitsune-Ral@users.sf.net> | 2016-09-07 08:34:03 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-07 08:34:03 +0900 |
commit | 34e7ba238f46734893111110235e032d44fd3690 (patch) | |
tree | 6fc1008c9d2dc50a7acd21c601ac06aff1365f2e /events | |
parent | c02174bc8f09761c2e4ee3ca4a250ce49025343e (diff) | |
parent | 573e0e478c4a904ba69e6b523dead41eb28121c1 (diff) | |
download | libquotient-34e7ba238f46734893111110235e032d44fd3690.tar.gz libquotient-34e7ba238f46734893111110235e032d44fd3690.zip |
Merge pull request #24 from Fxrh/kitsune-settings
Settings classes
Diffstat (limited to 'events')
-rw-r--r-- | events/event.cpp | 10 | ||||
-rw-r--r-- | events/event.h | 12 |
2 files changed, 15 insertions, 7 deletions
diff --git a/events/event.cpp b/events/event.cpp index d05d666f..0c7700ee 100644 --- a/events/event.cpp +++ b/events/event.cpp @@ -151,11 +151,11 @@ bool Event::parseJson(const QJsonObject& obj) return correct; } -QList<Event*> QMatrixClient::eventListFromJson(const QJsonArray& json) +Events QMatrixClient::eventsFromJson(const QJsonArray& json) { - QList<Event*> l; - l.reserve(json.size()); + Events evs; + evs.reserve(json.size()); for (auto event: json) - l.push_back(Event::fromJson(event.toObject())); - return l; + evs.push_back(Event::fromJson(event.toObject())); + return evs; } diff --git a/events/event.h b/events/event.h index 72d26208..d9316747 100644 --- a/events/event.h +++ b/events/event.h @@ -24,6 +24,7 @@ #include <QtCore/QString> #include <QtCore/QDateTime> #include <QtCore/QJsonObject> +#include <QtCore/QVector> class QJsonArray; @@ -38,7 +39,8 @@ namespace QMatrixClient class Event { public: - Event(EventType type); + explicit Event(EventType type); + Event(Event&) = delete; virtual ~Event(); EventType type() const; @@ -57,8 +59,9 @@ namespace QMatrixClient class Private; Private* d; }; + using Events = QVector<Event*>; - QList<Event*> eventListFromJson(const QJsonArray& contents); + Events eventsFromJson(const QJsonArray& contents); /** * Finds a place in the timeline where a new event/message could be inserted. @@ -71,6 +74,11 @@ namespace QMatrixClient { return std::lower_bound (timeline.begin(), timeline.end(), item, [](const typename ContT::value_type a, const ItemT * b) { + // FIXME: We should not order the message list by origin timestamp. + // Rather, an order of receiving should be used (which actually + // poses a question on whether this method is needed at all - + // or we'd just prepend and append, depending on whether we + // received something from /sync or from /messages. return a->timestamp() < b->timestamp(); } ); |