summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁabędź <github@labedz.org>2012-12-13 20:32:18 +0100
committermathieui <mathieui@mathieui.net>2012-12-13 22:03:36 +0100
commit1835d3649504389b773452bbb0bcf7469f53fdd9 (patch)
treebf64cacd2c2fd2971e4e5b82fd01cd0a7eca0139
parent0bf26e128a221aae0062d20054a0e15a6b0361f9 (diff)
downloadpoezio-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)
-rw-r--r--src/tabs.py5
-rw-r--r--src/windows.py15
2 files changed, 17 insertions, 3 deletions
diff --git a/src/tabs.py b/src/tabs.py
index 0d99e19c..f8a6ecac 100644
--- a/src/tabs.py
+++ b/src/tabs.py
@@ -2559,25 +2559,28 @@ class RosterInfoTab(Tab):
while not isinstance(self.roster_win.get_selected_row(), Contact):
if not self.roster_win.move_cursor_up():
break
+ self.roster_win.refresh(roster)
def move_cursor_to_next_contact(self):
self.roster_win.move_cursor_down()
- self.roster_win.refresh(roster)
while not isinstance(self.roster_win.get_selected_row(), Contact):
if not self.roster_win.move_cursor_down():
break
+ self.roster_win.refresh(roster)
def move_cursor_to_prev_group(self):
self.roster_win.move_cursor_up()
while not isinstance(self.roster_win.get_selected_row(), RosterGroup):
if not self.roster_win.move_cursor_up():
break
+ self.roster_win.refresh(roster)
def move_cursor_to_next_group(self):
self.roster_win.move_cursor_down()
while not isinstance(self.roster_win.get_selected_row(), RosterGroup):
if not self.roster_win.move_cursor_down():
break
+ self.roster_win.refresh(roster)
def on_scroll_down(self):
return self.roster_win.move_cursor_down(self.height // 2)
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):