ChoiceBox: do not sort the list on init if nothing has changed.
authorTaapat <taapat@gmail.com>
Fri, 13 Mar 2015 16:15:39 +0000 (18:15 +0200)
committerlittlesat <littlesat99@yahoo.com>
Fri, 13 Mar 2015 16:23:49 +0000 (17:23 +0100)
Signed-off-by: littlesat <littlesat99@yahoo.com>

lib/python/Screens/ChoiceBox.py

index bf5de9f..7636ef6 100644 (file)
@@ -31,25 +31,26 @@ class ChoiceBox(Screen):
                self.keymap = {}
                pos = 0
                if self.reorderConfig:
-                       prev_list = zip(list, self.__keys)
-                       new_list = []
                        self.config_type = eval("config.misc.pluginlist." + self.reorderConfig)
-                       for x in self.config_type.value.split(","):
-                               for entry in prev_list:
-                                       if entry[0][0] == x:
-                                               new_list.append(entry)
-                                               prev_list.remove(entry)
-                       list = zip(*(new_list + prev_list))
-                       list, self.__keys = list[0], list[1]
-                       number = 1
-                       new_keys = []
-                       for x in self.__keys:
-                               if (not x or x.isdigit()) and number <= 10:
-                                       new_keys.append(str(number % 10))
-                                       number+=1
-                               else:
-                                       new_keys.append(not x.isdigit() and x or "")
-                       self.__keys = new_keys
+                       if self.config_type.value:
+                               prev_list = zip(list, self.__keys)
+                               new_list = []
+                               for x in self.config_type.value.split(","):
+                                       for entry in prev_list:
+                                               if entry[0][0] == x:
+                                                       new_list.append(entry)
+                                                       prev_list.remove(entry)
+                               list = zip(*(new_list + prev_list))
+                               list, self.__keys = list[0], list[1]
+                               number = 1
+                               new_keys = []
+                               for x in self.__keys:
+                                       if (not x or x.isdigit()) and number <= 10:
+                                               new_keys.append(str(number % 10))
+                                               number+=1
+                                       else:
+                                               new_keys.append(not x.isdigit() and x or "")
+                               self.__keys = new_keys
                for x in list:
                        strpos = str(self.__keys[pos])
                        self.list.append(ChoiceEntryComponent(key = strpos, text = x))