summary refs log tree commit diff
path: root/src/RoomList.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-15 19:04:02 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-15 19:04:02 +0300
commite1d48367f8ccb83fc1fcdaee899e5bf4f8ac2669 (patch)
treeae84a8e5f6d1208d5cbf7a05c6e8ab2eaf322c48 /src/RoomList.cc
parentMove the main window to the center (diff)
downloadnheko-e1d48367f8ccb83fc1fcdaee899e5bf4f8ac2669.tar.xz
Show the unread message count on the window title
Diffstat (limited to 'src/RoomList.cc')
-rw-r--r--src/RoomList.cc15
1 files changed, 14 insertions, 1 deletions
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);