Merge lp:~ralsina/ubuntuone-control-panel/fix-scroll into lp:ubuntuone-control-panel

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 268
Merged at revision: 269
Proposed branch: lp:~ralsina/ubuntuone-control-panel/fix-scroll
Merge into: lp:ubuntuone-control-panel
Diff against target: 43 lines (+15/-0)
2 files modified
ubuntuone/controlpanel/gui/qt/folders.py (+5/-0)
ubuntuone/controlpanel/gui/qt/tests/test_folders.py (+10/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-control-panel/fix-scroll
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+95006@code.launchpad.net

Commit message

- Preserved the scrollbar position when clearing/filling the folder list (LP: #942355).

Description of the change

Preserve the scrollbar position when clearing/filling the folder list.

To test IRL:

In an account with many UDFs/Shares, go to the bottom of the list and choose "sync" (or
"unsync") and the folder list should stay put, not scrolling to the top.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great! Tested IRL as well.

review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gui/qt/folders.py'
2--- ubuntuone/controlpanel/gui/qt/folders.py 2012-02-22 15:35:13 +0000
3+++ ubuntuone/controlpanel/gui/qt/folders.py 2012-02-28 17:51:20 +0000
4@@ -112,6 +112,10 @@
5 @log_call(logger.debug)
6 def process_info(self, info):
7 """Load folders info into the tree view."""
8+ # FIXME: this is a bit of a hack for bug #942355
9+ # The correct solution is to not clear the list at all, but
10+ # the code would be much more complicated.
11+ scrollbar_position = self.ui.folders.verticalScrollBar().value()
12 self.ui.folders.clear()
13 self.is_processing = False
14
15@@ -194,6 +198,7 @@
16 self.ui.folders.setIndexWidget(model_index, button)
17
18 self.ui.folders.expandAll()
19+ self.ui.folders.verticalScrollBar().setValue(scrollbar_position)
20
21 # Invalid name "on_folders_itemActivated", "on_folders_itemChanged"
22 # pylint: disable=C0103
23
24=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_folders.py'
25--- ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-02-22 14:58:25 +0000
26+++ ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-02-28 17:51:20 +0000
27@@ -234,6 +234,16 @@
28 child_index += 1
29 item = root.child(child_index)
30
31+ def test_process_info_preserves_position(self):
32+ """process_info should not scroll the list to the top."""
33+ self.ui.process_info(FAKE_VOLUMES_INFO)
34+ scrollbar = self.ui.ui.folders.verticalScrollBar()
35+ maximum = scrollbar.maximum()
36+ scrollbar.setValue(maximum)
37+ self.ui.process_info(FAKE_VOLUMES_INFO)
38+ self.assertEqual(self.ui.ui.folders.verticalScrollBar().value(),
39+ maximum)
40+
41 def test_clicking_on_row_opens_folder(self):
42 """The folder activated is opened."""
43 self.patch(gui.os.path, 'exists', lambda *a: True)

Subscribers

People subscribed via source and target branches