changeset 110:34dfe0e32064

contact list: text entered in header input do filtering in shown contacts
author Goffi <goffi@goffi.org>
date Sun, 15 Jan 2017 21:21:32 +0100
parents 7631325e11f4
children c3952922ca56
files src/cagou/plugins/plugin_wid_contact_list.kv src/cagou/plugins/plugin_wid_contact_list.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/plugins/plugin_wid_contact_list.kv	Sun Jan 15 21:21:29 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_contact_list.kv	Sun Jan 15 21:21:32 2017 +0100
@@ -26,6 +26,7 @@
         size_hint: None, 1
         width: dp(60)
     Label:
+        id: jid_label
         padding: dp(5), 0
         text: root.jid
         text_size: self.size
--- a/src/cagou/plugins/plugin_wid_contact_list.py	Sun Jan 15 21:21:29 2017 +0100
+++ b/src/cagou/plugins/plugin_wid_contact_list.py	Sun Jan 15 21:21:32 2017 +0100
@@ -26,6 +26,7 @@
 from kivy.uix.boxlayout import BoxLayout
 from kivy.uix.listview import ListView
 from kivy.adapters.listadapter import ListAdapter
+from kivy.metrics import dp
 from kivy import properties
 from cagou.core import cagou_widget
 from cagou.core import image
@@ -86,6 +87,18 @@
         self.postInit()
         self.update()
 
+    def onHeaderInputComplete(self, wid, text):
+        # FIXME: this is implementation dependent, need to be done properly
+        items = self.children[0].children[0].children[0].children
+
+        for item in items:
+            if text not in item.ids.jid_label.text:
+                item.height = 0
+                item.opacity = 0
+            else:
+                item.height = dp(50)
+                item.opacity = 1
+
     def contactDataConverter(self, idx, bare_jid):
         return {"jid": bare_jid, "data": self._items_cache[bare_jid]}