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