mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Some debugging for the History stack
This commit is contained in:
parent
1c7a90f21e
commit
0d42146e79
@ -102,7 +102,7 @@ class Metadata(QWebView): # {{{
|
||||
|
||||
class History(list): # {{{
|
||||
|
||||
def __init__(self, action_back, action_forward):
|
||||
def __init__(self, action_back=None, action_forward=None):
|
||||
self.action_back = action_back
|
||||
self.action_forward = action_forward
|
||||
super(History, self).__init__(self)
|
||||
@ -112,7 +112,9 @@ class History(list): # {{{
|
||||
self.set_actions()
|
||||
|
||||
def set_actions(self):
|
||||
if self.action_back is not None:
|
||||
self.action_back.setDisabled(self.back_pos is None)
|
||||
if self.action_forward is not None:
|
||||
self.action_forward.setDisabled(self.forward_pos is None)
|
||||
|
||||
def back(self, from_pos):
|
||||
@ -153,6 +155,21 @@ class History(list): # {{{
|
||||
# There can be no forward
|
||||
self.forward_pos = None
|
||||
self.set_actions()
|
||||
|
||||
def __str__(self):
|
||||
return 'History: Items=%s back_pos=%s insert_pos=%s forward_pos=%s' % (tuple(self), self.back_pos, self.insert_pos, self.forward_pos)
|
||||
|
||||
def test_history():
|
||||
h = History()
|
||||
for i in xrange(4):
|
||||
h.add(i)
|
||||
for i in reversed(xrange(4)):
|
||||
h.back(i)
|
||||
print (h)
|
||||
h.forward(0)
|
||||
print (h)
|
||||
h.add(1)
|
||||
print (h)
|
||||
# }}}
|
||||
|
||||
class Main(MainWindow):
|
||||
|
Loading…
x
Reference in New Issue
Block a user