aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-20 14:52:58 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-01-20 14:52:58 +0900
commit3bfb1d9736e05fe216c016ae2dbb8eac4ac78048 (patch)
tree5bd9aea085ccd9db0e6a0c2b62b56b6a86f36611
parent72ff8cf1e77e859de08e343df964f496dc2f9dd8 (diff)
downloadlibquotient-3bfb1d9736e05fe216c016ae2dbb8eac4ac78048.tar.gz
libquotient-3bfb1d9736e05fe216c016ae2dbb8eac4ac78048.zip
Room: store the first displayed event as well; Room::*DisplayedMarker() methods
-rw-r--r--room.cpp33
-rw-r--r--room.h12
2 files changed, 42 insertions, 3 deletions
diff --git a/room.cpp b/room.cpp
index 68762a8a..8c6465e2 100644
--- a/room.cpp
+++ b/room.cpp
@@ -91,6 +91,7 @@ class Room::Private
QList<User*> membersLeft;
bool unreadMessages = false;
bool displayed = false;
+ QString firstDisplayedEventId;
QString lastDisplayedEventId;
QHash<const User*, QString> lastReadEventIds;
QString prevBatch;
@@ -436,18 +437,48 @@ void Room::setDisplayed(bool displayed)
}
}
+QString Room::firstDisplayedEventId() const
+{
+ return d->firstDisplayedEventId;
+}
+
+Room::rev_iter_t Room::firstDisplayedMarker() const
+{
+ return findInTimeline(firstDisplayedEventId());
+}
+
+void Room::setFirstDisplayedEventId(const QString& eventId)
+{
+ if (d->firstDisplayedEventId == eventId)
+ return;
+
+ d->firstDisplayedEventId = eventId;
+ emit firstDisplayedEventChanged();
+}
+
+void Room::setFirstDisplayedEvent(TimelineItem::index_t index)
+{
+ Q_ASSERT(isValidIndex(index));
+ setFirstDisplayedEventId(findInTimeline(index)->event()->id());
+}
+
QString Room::lastDisplayedEventId() const
{
return d->lastDisplayedEventId;
}
+Room::rev_iter_t Room::lastDisplayedMarker() const
+{
+ return findInTimeline(lastDisplayedEventId());
+}
+
void Room::setLastDisplayedEventId(const QString& eventId)
{
if (d->lastDisplayedEventId == eventId)
return;
d->lastDisplayedEventId = eventId;
- emit lastDisplayedEventIdChanged();
+ emit lastDisplayedEventChanged();
}
void Room::setLastDisplayedEvent(TimelineItem::index_t index)
diff --git a/room.h b/room.h
index 33514ac9..2284e8b1 100644
--- a/room.h
+++ b/room.h
@@ -110,7 +110,8 @@ namespace QMatrixClient
Q_PROPERTY(int memberCount READ memberCount NOTIFY memberListChanged)
Q_PROPERTY(bool displayed READ displayed WRITE setDisplayed NOTIFY displayedChanged)
- Q_PROPERTY(QString lastDisplayedEventId READ lastDisplayedEventId WRITE setLastDisplayedEventId NOTIFY lastDisplayedEventIdChanged)
+ Q_PROPERTY(QString firstDisplayedEventId READ firstDisplayedEventId WRITE setFirstDisplayedEventId NOTIFY firstDisplayedEventChanged)
+ Q_PROPERTY(QString lastDisplayedEventId READ lastDisplayedEventId WRITE setLastDisplayedEventId NOTIFY lastDisplayedEventChanged)
Q_PROPERTY(QString readMarkerEventId READ readMarkerEventId WRITE markMessagesAsRead NOTIFY readMarkerMoved)
public:
@@ -179,9 +180,15 @@ namespace QMatrixClient
bool displayed() const;
void setDisplayed(bool displayed = true);
+ QString firstDisplayedEventId() const;
+ rev_iter_t firstDisplayedMarker() const;
+ void setFirstDisplayedEventId(const QString& eventId);
+ void setFirstDisplayedEvent(TimelineItem::index_t index);
QString lastDisplayedEventId() const;
+ rev_iter_t lastDisplayedMarker() const;
void setLastDisplayedEventId(const QString& eventId);
void setLastDisplayedEvent(TimelineItem::index_t index);
+
rev_iter_t readMarker(const User* user) const;
rev_iter_t readMarker() const;
QString readMarkerEventId() const;
@@ -271,7 +278,8 @@ namespace QMatrixClient
void notificationCountChanged(Room* room);
void displayedChanged(bool displayed);
- void lastDisplayedEventIdChanged();
+ void firstDisplayedEventChanged();
+ void lastDisplayedEventChanged();
void lastReadEventChanged(User* user);
void readMarkerMoved();
void unreadMessagesChanged(Room* room);