From e1d48367f8ccb83fc1fcdaee899e5bf4f8ac2669 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 15 Apr 2017 19:04:02 +0300 Subject: Show the unread message count on the window title --- src/RoomList.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/RoomList.cc') diff --git a/src/RoomList.cc b/src/RoomList.cc index b1186d39..99553842 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -89,6 +89,18 @@ void RoomList::updateUnreadMessageCount(const QString &roomid, int count) } rooms_[roomid]->updateUnreadMessageCount(count); + + calculateUnreadMessageCount(); +} + +void RoomList::calculateUnreadMessageCount() +{ + int total_unread_msgs = 0; + + for (const auto &room : rooms_) + total_unread_msgs += room->unreadMessageCount(); + + emit totalUnreadMessageCountUpdated(total_unread_msgs); } void RoomList::setInitialRooms(const Rooms &rooms) @@ -132,11 +144,12 @@ void RoomList::highlightSelectedRoom(const RoomInfo &info) return; } - // TODO: Send a read receipt for the last event. auto room = rooms_[info.id()]; room->clearUnreadMessageCount(); + calculateUnreadMessageCount(); + for (auto it = rooms_.constBegin(); it != rooms_.constEnd(); it++) { if (it.key() != info.id()) it.value()->setPressedState(false); -- cgit 1.5.1