Allow non-None default for count

This commit is contained in:
Florian Bruhin 2014-01-30 07:08:45 +01:00
parent 85c44ed78c
commit b158cd78b5
3 changed files with 7 additions and 19 deletions

View File

@ -193,7 +193,7 @@ class QuteBrowser(QApplication):
handler = handlers[cmd] handler = handlers[cmd]
if self.sender().count: if count is not None and self.sender().count:
return handler(*args, count=count) return handler(*args, count=count)
else: else:
return handler(*args) return handler(*args)

View File

@ -61,10 +61,8 @@ class SearchParser(QObject):
self.flags = QWebPage.FindBackward self.flags = QWebPage.FindBackward
self.do_search.emit(self.text, self.flags) self.do_search.emit(self.text, self.flags)
def nextsearch(self, count=None): def nextsearch(self, count=1):
"""Continue the search to the ([count]th) next term.""" """Continue the search to the ([count]th) next term."""
if count is None:
count = 1
if self.text is not None: if self.text is not None:
for i in range(count): # pylint: disable=unused-variable for i in range(count): # pylint: disable=unused-variable
self.do_search.emit(self.text, self.flags) self.do_search.emit(self.text, self.flags)

View File

@ -139,27 +139,23 @@ class TabbedBrowser(TabWidget):
preview.paintRequested.connect(tab.print) preview.paintRequested.connect(tab.print)
preview.exec_() preview.exec_()
def cur_back(self, count=None): def cur_back(self, count=1):
"""Go back in the history of the current tab. """Go back in the history of the current tab.
Go back for 1 page if count is unset, else go back [count] pages. Go back for 1 page if count is unset, else go back [count] pages.
Command handler for :back. Command handler for :back.
""" """
# FIXME display warning if beginning of history # FIXME display warning if beginning of history
if count is None:
count = 1
for i in range(count): # pylint: disable=unused-variable for i in range(count): # pylint: disable=unused-variable
self.currentWidget().back() self.currentWidget().back()
def cur_forward(self, count=None): def cur_forward(self, count=1):
"""Go forward in the history of the current tab. """Go forward in the history of the current tab.
Go forward for 1 page if count is unset, else go forward [count] pages. Go forward for 1 page if count is unset, else go forward [count] pages.
Command handler for :forward. Command handler for :forward.
""" """
# FIXME display warning if end of history # FIXME display warning if end of history
if count is None:
count = 1
for i in range(count): # pylint: disable=unused-variable for i in range(count): # pylint: disable=unused-variable
self.currentWidget().forward() self.currentWidget().forward()
@ -171,13 +167,11 @@ class TabbedBrowser(TabWidget):
""" """
self.currentWidget().findText(text, flags) self.currentWidget().findText(text, flags)
def cur_scroll(self, dx, dy, count=None): def cur_scroll(self, dx, dy, count=1):
"""Scroll the current tab by count * dx/dy """Scroll the current tab by count * dx/dy
Command handler for :scroll. Command handler for :scroll.
""" """
if count is None:
count = 1
dx = int(count) * int(dx) dx = int(count) * int(dx)
dy = int(count) * int(dy) dy = int(count) * int(dy)
self.currentWidget().page().mainFrame().scroll(dx, dy) self.currentWidget().page().mainFrame().scroll(dx, dy)
@ -212,13 +206,11 @@ class TabbedBrowser(TabWidget):
return return
frame.setScrollBarValue(orientation, int(m * perc / 100)) frame.setScrollBarValue(orientation, int(m * perc / 100))
def switch_prev(self, count=None): def switch_prev(self, count=1):
"""Switch to the ([count]th) previous tab. """Switch to the ([count]th) previous tab.
Command handler for :tabprev. Command handler for :tabprev.
""" """
if count is None:
count = 1
idx = self.currentIndex() idx = self.currentIndex()
if idx - count >= 0: if idx - count >= 0:
self.setCurrentIndex(idx - count) self.setCurrentIndex(idx - count)
@ -226,13 +218,11 @@ class TabbedBrowser(TabWidget):
# FIXME # FIXME
pass pass
def switch_next(self, count=None): def switch_next(self, count=1):
"""Switch to the ([count]th) next tab. """Switch to the ([count]th) next tab.
Command handler for :tabnext. Command handler for :tabnext.
""" """
if count is None:
count = 1
idx = self.currentIndex() idx = self.currentIndex()
if idx + count < self.count(): if idx + count < self.count():
self.setCurrentIndex(idx + count) self.setCurrentIndex(idx + count)