Fix lint
This commit is contained in:
parent
fe4f32606d
commit
34b24aafa8
@ -280,7 +280,7 @@ class CommandDispatcher:
|
||||
|
||||
@cmdutils.register(instance='command-dispatcher', name='open',
|
||||
maxsplit=0, scope='window',
|
||||
completion=[usertypes.Completion.url_history_and_quickmarks])
|
||||
completion=[usertypes.Completion.url])
|
||||
def openurl(self, url=None, bg=False, tab=False, window=False,
|
||||
count: {'special': 'count'}=None):
|
||||
"""Open a URL in the current/[count]th tab.
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""Simple history which gets written to disk."""
|
||||
|
||||
import time
|
||||
import itertools
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal
|
||||
from PyQt5.QtWebKit import QWebHistoryInterface
|
||||
@ -98,8 +99,8 @@ class WebHistory(QWebHistoryInterface):
|
||||
return self._new_history[key]
|
||||
|
||||
def __iter__(self):
|
||||
import itertools
|
||||
return itertools.chain(self._old_urls.values(), iter(self._new_history))
|
||||
return itertools.chain(self._old_urls.values(),
|
||||
iter(self._new_history))
|
||||
|
||||
def get_recent(self):
|
||||
"""Get the most recent history entries."""
|
||||
|
@ -85,8 +85,8 @@ class Completer(QObject):
|
||||
models.CommandCompletionModel(self), self)
|
||||
self._models[usertypes.Completion.helptopic] = CFM(
|
||||
models.HelpCompletionModel(self), self)
|
||||
self._models[usertypes.Completion.url_history_and_quickmarks] = CFM(
|
||||
models.UrlCompletionModel('url', self), self,
|
||||
self._models[usertypes.Completion.url] = CFM(
|
||||
models.UrlCompletionModel(self), self,
|
||||
dumb_sort=Qt.DescendingOrder)
|
||||
|
||||
def _init_setting_completions(self):
|
||||
|
@ -217,10 +217,13 @@ class HelpCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
class UrlCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
"""A CompletionModel which combines both quickmarks and web history
|
||||
URLs. Used for the `open` command."""
|
||||
"""A model which combines quickmarks and web history URLs.
|
||||
|
||||
def __init__(self, match_field='url', parent=None):
|
||||
Used for the `open` command."""
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._quickcat = self.new_category("Quickmarks")
|
||||
@ -230,8 +233,8 @@ class UrlCompletionModel(base.BaseCompletionModel):
|
||||
WebHistoryCompletionModel.fill_model(self, cat=self._histcat)
|
||||
QuickmarkCompletionModel.fill_model(self, cat=self._quickcat)
|
||||
|
||||
self._histstore.item_added.connect(lambda e:
|
||||
WebHistoryCompletionModel.history_changed(
|
||||
self._histstore.item_added.connect(
|
||||
lambda e: WebHistoryCompletionModel.history_changed(
|
||||
self, e, self._histcat))
|
||||
|
||||
|
||||
@ -241,7 +244,7 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
# pylint: disable=abstract-method
|
||||
|
||||
def __init__(self, match_field='url', parent=None):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self._histcat = self.new_category("History")
|
||||
@ -249,11 +252,12 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
self.fill_model(self, self._histcat, self._histstore)
|
||||
|
||||
self._histstore.item_added.connect(lambda e:
|
||||
self.history_changed(e, self._histcat))
|
||||
self._histstore.item_added.connect(
|
||||
lambda e: self.history_changed(e, self._histcat))
|
||||
|
||||
@staticmethod
|
||||
def fill_model(model, cat=None, histstore=None):
|
||||
"""Fill the given model/category with the given history."""
|
||||
if not histstore:
|
||||
histstore = objreg.get('web-history')
|
||||
if not cat:
|
||||
@ -264,6 +268,7 @@ class WebHistoryCompletionModel(base.BaseCompletionModel):
|
||||
model.new_item(cat, entry.url, "", str(atime), sort=atime)
|
||||
|
||||
def history_changed(self, entry, cat):
|
||||
"""Slot called when a new history item was added."""
|
||||
if entry.url:
|
||||
atime = int(entry.atime)
|
||||
self.new_item(cat, entry.url, "", str(atime), sort=atime)
|
||||
@ -277,10 +282,11 @@ class QuickmarkCompletionModel(base.BaseCompletionModel):
|
||||
|
||||
def __init__(self, match_field='url', parent=None):
|
||||
super().__init__(parent)
|
||||
self.fill_model(self, match_field, parent)
|
||||
self.fill_model(self, match_field)
|
||||
|
||||
@staticmethod
|
||||
def fill_model(model, match_field='url', parent=None, cat=None):
|
||||
def fill_model(model, match_field='url', cat=None):
|
||||
"""Fill the given model/category with quickmarks."""
|
||||
if not cat:
|
||||
cat = model.new_category("Quickmarks")
|
||||
quickmarks = objreg.get('quickmark-manager').marks.items()
|
||||
|
@ -237,8 +237,7 @@ KeyMode = enum('KeyMode', ['normal', 'hint', 'command', 'yesno', 'prompt',
|
||||
# Available command completions
|
||||
Completion = enum('Completion', ['command', 'section', 'option', 'value',
|
||||
'helptopic', 'quickmark_by_url',
|
||||
'quickmark_by_name',
|
||||
'url_history_and_quickmarks', 'sessions'])
|
||||
'quickmark_by_name', 'url', 'sessions'])
|
||||
|
||||
|
||||
class Question(QObject):
|
||||
|
Loading…
Reference in New Issue
Block a user