diff options
author | Łabędź <github@labedz.org> | 2012-12-13 20:32:18 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-12-13 22:03:36 +0100 |
commit | 1835d3649504389b773452bbb0bcf7469f53fdd9 (patch) | |
tree | bf64cacd2c2fd2971e4e5b82fd01cd0a7eca0139 /src/windows.py | |
parent | 0bf26e128a221aae0062d20054a0e15a6b0361f9 (diff) | |
download | poezio-1835d3649504389b773452bbb0bcf7469f53fdd9.tar.gz poezio-1835d3649504389b773452bbb0bcf7469f53fdd9.tar.bz2 poezio-1835d3649504389b773452bbb0bcf7469f53fdd9.tar.xz poezio-1835d3649504389b773452bbb0bcf7469f53fdd9.zip |
bugfix: count roster list length by real listed item and not count filtered items
bugfix: use cache table of roster (created on every refresh) to get selected row object,
fixing bad row selecting when jumping over group (was changing pos variable and
not selected_row while moving to next contact after group)
Diffstat (limited to 'src/windows.py')
-rw-r--r-- | src/windows.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/windows.py b/src/windows.py index 4cf358a0..5168f9c7 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1576,6 +1576,7 @@ class RosterWin(Win): self.start_pos = 1 # position of the start of the display self.roster_len = 0 self.selected_row = None + self.roster_cache = [] def move_cursor_down(self, number=1): """ @@ -1630,8 +1631,9 @@ class RosterWin(Win): We get the roster object """ log.debug('Refresh: %s',self.__class__.__name__) + self.roster_cache = [] with g_lock: - self.roster_len = len(roster) + self.roster_len = len(roster); while self.roster_len and self.pos >= self.roster_len: self.move_cursor_up() self._win.erase() @@ -1650,6 +1652,7 @@ class RosterWin(Win): self.selected_row = group if y >= self.start_pos: self.draw_group(y-self.start_pos+1, group, y-1==self.pos) + self.roster_cache.append(group) y += 1 if group.folded: continue @@ -1662,6 +1665,8 @@ class RosterWin(Win): break if y >= self.start_pos: self.draw_contact_line(y-self.start_pos+1, contact, y-1==self.pos) + log.debug('ammend: %s',contact.bare_jid) + self.roster_cache.append(contact) y += 1 if not contact.folded: for resource in contact.get_resources(): @@ -1671,6 +1676,7 @@ class RosterWin(Win): break if y >= self.start_pos: self.draw_resource_line(y-self.start_pos+1, resource, y-1==self.pos) + self.roster_cache.append(resource) y += 1 if y-self.start_pos+1 == self.height: break @@ -1777,7 +1783,12 @@ class RosterWin(Win): self.finish_line() def get_selected_row(self): - return self.selected_row + if self.pos >= len(self.roster_cache): + return self.selected_row + if len(self.roster_cache) > 0: + self.selected_row = self.roster_cache[self.pos] + return self.roster_cache[self.pos] + return None class ContactInfoWin(Win): def __init__(self): |