aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/room.cpp20
-rw-r--r--lib/room.h9
2 files changed, 24 insertions, 5 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 3b00d2d9..7e0806a7 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -224,9 +224,15 @@ public:
return evt;
}
- const QHash<StateEventKey, const StateEventBase*> stateEvents() const
+ QVector<const StateEventBase*> stateEventsOfType(const QString& evtType) const
{
- return currentState;
+ QVector<const StateEventBase*> vals = QVector<const StateEventBase*>();
+ for (const auto* val : currentState) {
+ if (val->matrixType() == evtType) {
+ vals.append(val);
+ }
+ }
+ return vals;
}
template <typename EventT>
@@ -1298,9 +1304,15 @@ const StateEventBase* Room::getCurrentState(const QString& evtType,
return d->getCurrentState({ evtType, stateKey });
}
-const QHash<StateEventKey, const StateEventBase*> Room::stateEvents() const
+const QVector<const StateEventBase*>
+Room::stateEventsOfType(const QString& evtType) const
+{
+ return d->stateEventsOfType(evtType);
+}
+
+const QHash<StateEventKey, const StateEventBase*>& Room::currentState() const
{
- return d->stateEvents();
+ return d->currentState;
}
RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent)
diff --git a/lib/room.h b/lib/room.h
index 452ea306..51538b8f 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -512,7 +512,14 @@ public:
/*! This method returns all known state events that have occured in
* the room, as a mapping from the event type and state key to value.
*/
- Q_INVOKABLE const QHash<StateEventKey, const StateEventBase*> stateEvents() const;
+ const QHash<StateEventKey, const StateEventBase*>& currentState() const;
+
+ /// Get all state events in the room of a certain type.
+ /*! This method returns all known state events that have occured in
+ * the room of the given type.
+ */
+ Q_INVOKABLE const QVector<const StateEventBase*>
+ stateEventsOfType(const QString& evtType) const;
/// Get a state event with the given event type and state key
/*! This is a typesafe overload that accepts a C++ event type instead of