aboutsummaryrefslogtreecommitdiff
path: root/room.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2016-11-01 14:03:54 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2016-11-01 14:15:31 +0900
commit416460b8da337bca3f12fb8bdc00371b2c56481d (patch)
tree261dddc3c817336d3568023a0f7fdf3fb4cf5974 /room.cpp
parent17135e362a3c7b5355934837b548ceab40af9a9f (diff)
downloadlibquotient-416460b8da337bca3f12fb8bdc00371b2c56481d.tar.gz
libquotient-416460b8da337bca3f12fb8bdc00371b2c56481d.zip
Moved MemberNameSorter from Quaternion to lib
This code is useful for any client that uses the Room class and needs to display the list of room members. Also removed an unused #include.
Diffstat (limited to 'room.cpp')
-rw-r--r--room.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/room.cpp b/room.cpp
index 6fad463b..85ab1720 100644
--- a/room.cpp
+++ b/room.cpp
@@ -28,7 +28,6 @@
#include "connection.h"
#include "state.h"
#include "user.h"
-#include "events/event.h"
#include "events/roommessageevent.h"
#include "events/roomnameevent.h"
#include "events/roomaliasesevent.h"
@@ -677,3 +676,19 @@ void Room::Private::updateDisplayname()
if (old_name != displayname)
emit q->displaynameChanged(q);
}
+
+MemberSorter Room::memberSorter() const
+{
+ return MemberSorter(this);
+}
+
+bool MemberSorter::operator()(User *u1, User *u2) const
+{
+ auto n1 = room->roomMembername(u1);
+ auto n2 = room->roomMembername(u2);
+ if (n1[0] == '@')
+ n1.remove(0, 1);
+ if (n2[0] == '@')
+ n2.remove(0, 1);
+ return n1 < n2;
+}