summary refs log tree commit diff
path: root/src/RoomInfoListItem.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-03-15 21:13:55 +0000
committerGitHub <noreply@github.com>2020-03-15 21:13:55 +0000
commitb41e2e6f18c0dafc7dbcac8c37524a76c5cdf88e (patch)
tree0251df81da3ae60f6505da45748c74f955a3330b /src/RoomInfoListItem.cpp
parentMerge pull request #145 from PC25/master (diff)
parentFixed bug caused by me forgetting what types im using (invites appearing at t... (diff)
downloadnheko-b41e2e6f18c0dafc7dbcac8c37524a76c5cdf88e.tar.xz
Merge pull request #146 from Alch-Emi/priority-sort
Place unread rooms higher in the room list
Diffstat (limited to 'src/RoomInfoListItem.cpp')
-rw-r--r--src/RoomInfoListItem.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/RoomInfoListItem.cpp b/src/RoomInfoListItem.cpp

index 61fb5e47..cc5f5776 100644 --- a/src/RoomInfoListItem.cpp +++ b/src/RoomInfoListItem.cpp
@@ -26,6 +26,7 @@ #include "Config.h" #include "RoomInfoListItem.h" #include "Splitter.h" +#include "UserSettingsPage.h" #include "Utils.h" #include "ui/Menu.h" #include "ui/Ripple.h" @@ -99,7 +100,10 @@ RoomInfoListItem::init(QWidget *parent) menu_->addAction(leaveRoom_); } -RoomInfoListItem::RoomInfoListItem(QString room_id, const RoomInfo &info, QWidget *parent) +RoomInfoListItem::RoomInfoListItem(QString room_id, + const RoomInfo &info, + QSharedPointer<UserSettings> userSettings, + QWidget *parent) : QWidget(parent) , roomType_{info.is_invite ? RoomType::Invited : RoomType::Joined} , roomId_(std::move(room_id)) @@ -107,6 +111,7 @@ RoomInfoListItem::RoomInfoListItem(QString room_id, const RoomInfo &info, QWidge , isPressed_(false) , unreadMsgCount_(0) , unreadHighlightedMsgCount_(0) + , settings(userSettings) { init(parent); } @@ -324,6 +329,34 @@ RoomInfoListItem::updateUnreadMessageCount(int count, int highlightedCount) update(); } +enum NotificationImportance : short +{ + ImportanceDisabled = -1, + AllEventsRead = 0, + NewMessage = 1, + NewMentions = 2, + Invite = 3 +}; + +short int +RoomInfoListItem::calculateImportance() const +{ + // Returns the degree of importance of the unread messages in the room. + // If sorting by importance is disabled in settings, this only ever + // returns ImportanceDisabled or Invite + if (isInvite()) { + return Invite; + } else if (!settings->isSortByImportanceEnabled()) { + return ImportanceDisabled; + } else if (unreadHighlightedMsgCount_) { + return NewMentions; + } else if (unreadMsgCount_) { + return NewMessage; + } else { + return AllEventsRead; + } +} + void RoomInfoListItem::setPressedState(bool state) {