diff src/plugins/plugin_xep_0055.py @ 1508:ec60682a9d17

plugin XEP-0055: display the search results using XMLUI JidsListWidget
author souliane <souliane@mailoo.org>
date Wed, 02 Sep 2015 13:57:46 +0200
parents 8405d622bde0
children 72e6ee3fdf53
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0055.py	Wed Sep 02 13:56:34 2015 +0200
+++ b/src/plugins/plugin_xep_0055.py	Wed Sep 02 13:57:46 2015 +0200
@@ -261,7 +261,18 @@
         @param elt (domish.Element):  form result element
         """
         if [child for child in elt.children if child.name == "item"]: 
-            xml_tools.dataFormResult2AdvancedList(main_ui, elt)
+            headers, xmlui_data = xml_tools.dataFormResult2XMLUIData(elt)
+            if "jid" in headers:  # use XMLUI JidsListWidget to display the results
+                values = {}
+                for i in range(len(xmlui_data)):
+                    header = headers.keys()[i % len(headers)]
+                    widget_type, widget_args, widget_kwargs = xmlui_data[i]
+                    value = widget_args[0]
+                    values.setdefault(header, []).append(jid.JID(value) if header == "jid" else value)
+                main_ui.addJidsList(jids=values["jid"], name=D_(u"Search results"))
+                # TODO: also display the values other than JID
+            else:
+                xml_tools.XMLUIData2AdvancedList(main_ui, headers, xmlui_data)
         else:
             main_ui.addText(D_("The search gave no result"))