changeset 430:a927a98b398d

browser_side (xmlui): fix multi-selection
author souliane <souliane@mailoo.org>
date Thu, 03 Apr 2014 15:49:01 +0200
parents 9283f9e5e5dd
children 4fcf9bac109c
files browser_side/xmlui.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/xmlui.py	Tue Apr 01 11:00:28 2014 +0200
+++ b/browser_side/xmlui.py	Thu Apr 03 15:49:01 2014 +0200
@@ -154,7 +154,10 @@
 
     def __init__(self, parent, options, selected, flags):
         ListBox.__init__(self)
-        self.setMultipleSelect('single' not in flags)
+        multi_selection = 'single' not in flags
+        self.setMultipleSelect(multi_selection)
+        if multi_selection:
+            self.setVisibleItemCount(5)
         for option in options:
             self.addItem(option[1])
         self._xmlui_attr_map = {label: value for value, label in options}
@@ -185,8 +188,9 @@
     def _xmluiAddValues(self, values, select=True):
         selected = self._xmluiGetSelectedValues()
         for value in values:
-            self.addItem(value)
-            self._xmlui_attr_map[value] = value
+            if value not in self._xmlui_attr_map.values():
+                self.addItem(value)
+                self._xmlui_attr_map[value] = value
             if value not in selected:
                 selected.append(value)
         self._xmluiSelectValues(selected)