diff cagou/core/common.py @ 405:84ff5c917064

widgets: implemented ordering in ContactItem and CagouWidget: ordering of slides in collection_carousel were using a specific key during the sort, this has been replaced by an ordering implemented directly into the classes. Ordering has also been implemented in ContactItem to have items appearing in a consistent order notably for opened chats.
author Goffi <goffi@goffi.org>
date Wed, 12 Feb 2020 20:02:58 +0100
parents f7476818f9fb
children 03554ad70846
line wrap: on
line diff
--- a/cagou/core/common.py	Wed Feb 12 20:02:58 2020 +0100
+++ b/cagou/core/common.py	Wed Feb 12 20:02:58 2020 +0100
@@ -19,7 +19,7 @@
 """common simple widgets"""
 
 import json
-from functools import partial
+from functools import partial, total_ordering
 from sat.core.i18n import _
 from sat.core import log as logging
 from kivy.uix.widget import Widget
@@ -54,7 +54,7 @@
 class NotifLabel(Label):
     pass
 
-
+@total_ordering
 class ContactItem(BoxLayout):
     """An item from ContactList
 
@@ -86,6 +86,9 @@
                 self.avatar_layout.remove_widget(self.badge)
                 self.badge = None
 
+    def __lt__(self, other):
+        return self.jid < other.jid
+
 
 class ContactButton(ButtonBehavior, ContactItem):
     pass