Replace QUrl::url by QUrl::toString.

This commit is contained in:
Florian Bruhin 2014-02-10 18:49:25 +01:00
parent 094640b39b
commit 6cf85ff52e
2 changed files with 14 additions and 13 deletions

View File

@ -21,7 +21,7 @@ def urlstring(url):
qurl -- URL as string or QUrl. qurl -- URL as string or QUrl.
""" """
return url.url() if isinstance(url, QUrl) else url return url.toString() if isinstance(url, QUrl) else url
def fuzzy_url(url): def fuzzy_url(url):
@ -42,8 +42,8 @@ def fuzzy_url(url):
newurl = _get_search_url(urlstr) newurl = _get_search_url(urlstr)
except ValueError: # invalid search engine except ValueError: # invalid search engine
newurl = QUrl.fromUserInput(urlstr) newurl = QUrl.fromUserInput(urlstr)
logging.debug('Converting fuzzy term {} to url -> {}'.format(urlstr, logging.debug('Converting fuzzy term {} to url -> {}'.format(
newurl.url())) urlstr, urlstring(newurl)))
return newurl return newurl
@ -75,14 +75,15 @@ def is_about_url(url):
def is_url(url): def is_url(url):
"""Return True if url (QUrl) seems to be a valid URL.""" """Return True if url (QUrl) seems to be a valid URL."""
logging.debug('Checking if "{}" is an URL'.format(url.url())) urlstr = urlstring(url)
if ' ' in urlstring(url): logging.debug('Checking if "{}" is an URL'.format(urlstr))
if ' ' in urlstr:
# An URL will never contain a space # An URL will never contain a space
logging.debug('Contains space -> no url') logging.debug('Contains space -> no url')
return False return False
elif config.config.getboolean('general', 'addressbar_dns_lookup'): elif config.config.getboolean('general', 'addressbar_dns_lookup'):
logging.debug('Checking via DNS') logging.debug('Checking via DNS')
return _is_url_dns(QUrl.fromUserInput(urlstring(url))) return _is_url_dns(QUrl.fromUserInput(urlstr))
else: else:
logging.debug('Checking via naive check') logging.debug('Checking via naive check')
return _is_url_naive(url) return _is_url_naive(url)

View File

@ -84,7 +84,7 @@ class TabbedBrowser(TabWidget):
url = urlutils.qurl(url) url = urlutils.qurl(url)
tab = BrowserTab(self) tab = BrowserTab(self)
tab.openurl(url) tab.openurl(url)
self.addTab(tab, url.url()) self.addTab(tab, urlutils.urlstring(url))
self.setCurrentWidget(tab) self.setCurrentWidget(tab)
tab.loadProgress.connect(self._filter_factory(self.cur_progress)) tab.loadProgress.connect(self._filter_factory(self.cur_progress))
tab.loadFinished.connect(self._filter_factory(self.cur_load_finished)) tab.loadFinished.connect(self._filter_factory(self.cur_load_finished))
@ -100,7 +100,7 @@ class TabbedBrowser(TabWidget):
def tabopencur(self): def tabopencur(self):
"""Set the statusbar to :tabopen and the current URL.""" """Set the statusbar to :tabopen and the current URL."""
url = self.currentWidget().url().toString() url = urlutils.urlstring(self.currentWidget().url())
self.set_cmd_text.emit(':tabopen ' + url) self.set_cmd_text.emit(':tabopen ' + url)
def openurl(self, url, count=None): def openurl(self, url, count=None):
@ -116,7 +116,7 @@ class TabbedBrowser(TabWidget):
def opencur(self): def opencur(self):
"""Set the statusbar to :open and the current URL.""" """Set the statusbar to :open and the current URL."""
url = self.currentWidget().url().toString() url = urlutils.urlstring(self.currentWidget().url())
self.set_cmd_text.emit(':open ' + url) self.set_cmd_text.emit(':open ' + url)
def undo_close(self): def undo_close(self):
@ -298,7 +298,7 @@ class TabbedBrowser(TabWidget):
""" """
clip = QApplication.clipboard() clip = QApplication.clipboard()
url = self.currentWidget().url().toString() url = urlutils.urlstring(self.currentWidget().url())
mode = QClipboard.Selection if sel else QClipboard.Clipboard mode = QClipboard.Selection if sel else QClipboard.Clipboard
clip.setText(url, mode) clip.setText(url, mode)
# FIXME provide visual feedback # FIXME provide visual feedback
@ -478,11 +478,11 @@ class BrowserTab(QWebView):
""" """
u = urlutils.fuzzy_url(url) u = urlutils.fuzzy_url(url)
logging.debug('New title: {}'.format(u.url())) logging.debug('New title: {}'.format(urlutils.urlstring(u)))
self.titleChanged.emit(u.url()) self.titleChanged.emit(urlutils.urlstring(u))
if urlutils.is_about_url(u): if urlutils.is_about_url(u):
try: try:
content = about.handle(u.toString()) content = about.handle(urlutils.urlstring(u))
except AttributeError: except AttributeError:
return self.load(u) return self.load(u)
else: else: