comparison 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
comparison
equal deleted inserted replaced
1507:84250128e425 1508:ec60682a9d17
259 259
260 @param main_ui (XMLUI): the main XMLUI instance 260 @param main_ui (XMLUI): the main XMLUI instance
261 @param elt (domish.Element): form result element 261 @param elt (domish.Element): form result element
262 """ 262 """
263 if [child for child in elt.children if child.name == "item"]: 263 if [child for child in elt.children if child.name == "item"]:
264 xml_tools.dataFormResult2AdvancedList(main_ui, elt) 264 headers, xmlui_data = xml_tools.dataFormResult2XMLUIData(elt)
265 if "jid" in headers: # use XMLUI JidsListWidget to display the results
266 values = {}
267 for i in range(len(xmlui_data)):
268 header = headers.keys()[i % len(headers)]
269 widget_type, widget_args, widget_kwargs = xmlui_data[i]
270 value = widget_args[0]
271 values.setdefault(header, []).append(jid.JID(value) if header == "jid" else value)
272 main_ui.addJidsList(jids=values["jid"], name=D_(u"Search results"))
273 # TODO: also display the values other than JID
274 else:
275 xml_tools.XMLUIData2AdvancedList(main_ui, headers, xmlui_data)
265 else: 276 else:
266 main_ui.addText(D_("The search gave no result")) 277 main_ui.addText(D_("The search gave no result"))
267 278
268 279
269 ## Retrieve the search fields ## 280 ## Retrieve the search fields ##