changeset 5fe718640116 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=5fe718640116
description:
        Do not clear model if the selection is still the same

        Clearing the model reset the scroll position of the ScrolledWindow 
which is
        unnecessary if the content is still the same.

        issue10121
        review339981002
diffstat:

 tryton/gui/window/view_form/view/form_gtk/multiselection.py |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r dfb547dc1b8a -r 5fe718640116 
tryton/gui/window/view_form/view/form_gtk/multiselection.py
--- a/tryton/gui/window/view_form/view/form_gtk/multiselection.py       Sun Feb 
21 19:46:22 2021 +0100
+++ b/tryton/gui/window/view_form/view/form_gtk/multiselection.py       Mon Mar 
01 23:30:23 2021 +0100
@@ -77,12 +77,15 @@
             # it will be set back in the super call
             selection.set_select_function(lambda *a: True)
             self.update_selection(self.record, self.field)
-            self.model.clear()
+            new_model = self.selection != [list(row) for row in self.model]
+            if new_model:
+                self.model.clear()
             if not self.field:
                 return
             value2path = {}
             for idx, (value, name) in enumerate(self.selection):
-                self.model.append((value, name))
+                if new_model:
+                    self.model.append((value, name))
                 value2path[value] = idx
             selection.unselect_all()
             values = self.field.get_eval(self.record)

Reply via email to