Add commands to go to the prev/next change in the list
When viewing a change, 'n' and 'p' will jump to the next and previous changes (respectively) from the most recent list of changes without pushing the current change on to the navigation history. This streamlines the process when reviewing many changes in sequence. Change-Id: I31d4b30cd8d7bd6f5c5c4376033e43421fbe6c5b
This commit is contained in:
parent
e6102553ea
commit
6678ff45b9
@ -146,10 +146,11 @@ class App(object):
|
||||
|
||||
self.popup(dialog)
|
||||
|
||||
def changeScreen(self, widget):
|
||||
def changeScreen(self, widget, push=True):
|
||||
self.log.debug("Changing screen to %s" % (widget,))
|
||||
self.status.update(title=widget.title)
|
||||
self.screens.append(self.loop.widget)
|
||||
if push:
|
||||
self.screens.append(self.loop.widget)
|
||||
self.loop.widget = widget
|
||||
|
||||
def backScreen(self, target_widget=None):
|
||||
|
@ -274,6 +274,8 @@ class ChangeView(urwid.WidgetWrap):
|
||||
<c> Checkout the most recent revision into the local repo.
|
||||
<d> Show the diff of the mont recent revision.
|
||||
<k> Toggle the hidden flag for the current change.
|
||||
<n> Go to the next change in the list.
|
||||
<p> Go to the previous change in the list.
|
||||
<r> Leave a review for the most recent revision.
|
||||
<u> Back to the list of changes.
|
||||
<v> Toggle the reviewed flag for the current change.
|
||||
@ -571,6 +573,19 @@ class ChangeView(urwid.WidgetWrap):
|
||||
widget = self.app.findChangeList()
|
||||
self.app.backScreen(widget)
|
||||
return None
|
||||
if r in ['n', 'p']:
|
||||
widget = self.app.findChangeList()
|
||||
if r == 'n':
|
||||
new_change_key = widget.getNextChangeKey(self.change_key)
|
||||
else:
|
||||
new_change_key = widget.getPrevChangeKey(self.change_key)
|
||||
if new_change_key:
|
||||
try:
|
||||
view = ChangeView(self.app, new_change_key)
|
||||
self.app.changeScreen(view, push=False)
|
||||
except gertty.view.DisplayError as e:
|
||||
self.app.error(e.message)
|
||||
return None
|
||||
if r == 'ctrl r':
|
||||
self.app.sync.submitTask(
|
||||
sync.SyncChangeTask(self.change_rest_id, priority=sync.HIGH_PRIORITY))
|
||||
|
@ -121,6 +121,22 @@ class ChangeListView(urwid.WidgetWrap):
|
||||
self.listbox.body.remove(row)
|
||||
del self.change_rows[key]
|
||||
|
||||
def getNextChangeKey(self, change_key):
|
||||
row = self.change_rows.get(change_key)
|
||||
i = self.listbox.body.index(row)
|
||||
if i+1 >= len(self.listbox.body):
|
||||
return None
|
||||
row = self.listbox.body[i+1]
|
||||
return row.change_key
|
||||
|
||||
def getPrevChangeKey(self, change_key):
|
||||
row = self.change_rows.get(change_key)
|
||||
i = self.listbox.body.index(row)
|
||||
if i <= 0:
|
||||
return None
|
||||
row = self.listbox.body[i-1]
|
||||
return row.change_key
|
||||
|
||||
def toggleReviewed(self, change_key):
|
||||
with self.app.db.getSession() as session:
|
||||
change = session.getChange(change_key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user