changeset d4918be853dd in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset;node=d4918be853dd
description:
Keep column arrow up to date
When an order is set on a One2Many widget and the user reload the form,
the
selected order is lost and so the client should no more display those
arrow.
For that we update the arrows on each display using the screen order.
And we
unset the screen order when the group change as we do not know the
order of
this group.
issue7817
review70481002
diffstat:
tryton/gui/window/view_form/screen/screen.py | 1 +
tryton/gui/window/view_form/view/list.py | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 0 deletions(-)
diffs (48 lines):
diff -r 2ddba0a8db33 -r d4918be853dd
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py Wed Jan 02 18:53:18
2019 +0100
+++ b/tryton/gui/window/view_form/screen/screen.py Wed Jan 02 18:56:34
2019 +0100
@@ -368,6 +368,7 @@
fields[name] = field.attrs
fields_views[name] = field.views
self.tree_states_done.clear()
+ self.order = None
self.__group = group
self.parent = group.parent
self.parent_name = group.parent_name
diff -r 2ddba0a8db33 -r d4918be853dd tryton/gui/window/view_form/view/list.py
--- a/tryton/gui/window/view_form/view/list.py Wed Jan 02 18:53:18 2019 +0100
+++ b/tryton/gui/window/view_form/view/list.py Wed Jan 02 18:56:34 2019 +0100
@@ -554,6 +554,25 @@
else:
self.screen.search_filter(search_string=search_string)
+ def update_arrow(self):
+ order = self.screen.order
+ if order and len(order) == 1:
+ (name, direction), = order
+ direction = {
+ 'ASC': gtk.ARROW_DOWN,
+ 'DESC': gtk.ARROW_UP,
+ }[direction]
+ else:
+ name, direction = None, None
+
+ for col in self.treeview.get_columns():
+ arrow = getattr(col, 'arrow', None)
+ if arrow:
+ if col.name != name:
+ arrow.set(gtk.ARROW_NONE, gtk.SHADOW_NONE)
+ else:
+ arrow.set(direction, gtk.SHADOW_IN)
+
def add_last_column(self):
for column in self.treeview.get_columns():
if column.get_expand():
@@ -1033,6 +1052,7 @@
self.treeview.queue_draw()
if self.editable:
self.set_state()
+ self.update_arrow()
self.update_sum()
# Set column visibility depending on attributes and domain