aboutsummaryrefslogtreecommitdiff
path: root/room.h
diff options
context:
space:
mode:
Diffstat (limited to 'room.h')
-rw-r--r--room.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/room.h b/room.h
index b2e56502..582b89c4 100644
--- a/room.h
+++ b/room.h
@@ -39,7 +39,9 @@ namespace QMatrixClient
class TimelineItem
{
public:
- using index_t = int; // For compatibility with Qt containers
+ // For compatibility with Qt containers, even though we use
+ // a std:: container now
+ using index_t = int;
TimelineItem(Event* e, index_t number) : evt(e), idx(number) { }
@@ -51,6 +53,12 @@ namespace QMatrixClient
std::unique_ptr<Event> evt;
index_t idx;
};
+ inline QDebug& operator<<(QDebug& d, const TimelineItem& ti)
+ {
+ QDebugStateSaver dss(d);
+ d.nospace() << "(" << ti.index() << "|" << ti->id() << ")";
+ return d;
+ }
class Room: public QObject
{
@@ -58,12 +66,12 @@ namespace QMatrixClient
Q_PROPERTY(QString readMarkerEventId READ readMarkerEventId WRITE markMessagesAsRead NOTIFY readMarkerMoved)
public:
using Timeline = std::deque<TimelineItem>;
+ using rev_iter_t = Timeline::const_reverse_iterator;
Room(Connection* connection, QString id);
virtual ~Room();
Q_INVOKABLE QString id() const;
- Q_INVOKABLE const Timeline& messageEvents() const;
Q_INVOKABLE QString name() const;
Q_INVOKABLE QStringList aliases() const;
Q_INVOKABLE QString canonicalAlias() const;
@@ -89,6 +97,21 @@ namespace QMatrixClient
Q_INVOKABLE void updateData(SyncRoomData& data );
Q_INVOKABLE void setJoinState( JoinState state );
+ const Timeline& messageEvents() const;
+ /**
+ * A convenience method returning the read marker to the before-oldest
+ * message
+ */
+ rev_iter_t timelineEdge() const;
+ Q_INVOKABLE TimelineItem::index_t minTimelineIndex() const;
+ Q_INVOKABLE TimelineItem::index_t maxTimelineIndex() const;
+ Q_INVOKABLE bool isValidIndex(TimelineItem::index_t timelineIndex) const;
+
+ rev_iter_t findInTimeline(TimelineItem::index_t index) const;
+ rev_iter_t findInTimeline(QString evtId) const;
+
+ rev_iter_t readMarker(const User* user) const;
+ rev_iter_t readMarker() const;
QString readMarkerEventId() const;
/**
* @brief Mark the event with uptoEventId as read
@@ -98,7 +121,7 @@ namespace QMatrixClient
* for this message or, if it's from the local user, for
* the nearest non-local message before. uptoEventId must be non-empty.
*/
- Q_INVOKABLE void markMessagesAsRead(QString uptoEventId);
+ void markMessagesAsRead(QString uptoEventId);
Q_INVOKABLE bool hasUnreadMessages();