Rename widget to tab in some places

This also fixes the cur_url access.
This commit is contained in:
Florian Bruhin 2016-07-08 10:08:44 +02:00
parent b8086d1d13
commit 09f4c2199e

View File

@ -107,17 +107,17 @@ class TabWidget(QTabWidget):
def get_tab_fields(self, idx):
"""Get the tab field data."""
widget = self.widget(idx)
tab = self.widget(idx)
page_title = self.page_title(idx)
fields = {}
fields['id'] = widget.tab_id
fields['id'] = tab.tab_id
fields['title'] = page_title
fields['title_sep'] = ' - ' if page_title else ''
fields['perc_raw'] = widget.progress
fields['perc_raw'] = tab.progress()
if widget.load_status == usertypes.LoadStatus.loading:
fields['perc'] = '[{}%] '.format(widget.progress)
if tab.load_status() == usertypes.LoadStatus.loading:
fields['perc'] = '[{}%] '.format(tab.progress())
else:
fields['perc'] = ''
@ -126,7 +126,7 @@ class TabWidget(QTabWidget):
except qtutils.QtValueError:
fields['host'] = ''
y = widget.scroll.pos_perc()[1]
y = tab.scroll.pos_perc()[1]
if y is None:
scroll_pos = '???'
elif y <= 0:
@ -225,11 +225,11 @@ class TabWidget(QTabWidget):
Return:
The tab URL as QUrl.
"""
widget = self.widget(idx)
if widget is None:
tab = self.widget(idx)
if tab is None:
url = QUrl()
else:
url = widget.cur_url
url = tab.url()
# It's possible for url to be invalid, but the caller will handle that.
qtutils.ensure_valid(url)
return url