allow to narrow down search by adding more words separated with space

This commit is contained in:
Milan Svoboda 2015-12-26 16:27:53 +01:00
parent e9bf5fc219
commit 8914404d59

View File

@ -27,7 +27,7 @@ from PyQt5.QtCore import QSortFilterProxyModel, QModelIndex, Qt
from qutebrowser.utils import log, qtutils, debug from qutebrowser.utils import log, qtutils, debug
from qutebrowser.completion.models import base as completion from qutebrowser.completion.models import base as completion
import re
class CompletionFilterModel(QSortFilterProxyModel): class CompletionFilterModel(QSortFilterProxyModel):
@ -69,6 +69,7 @@ class CompletionFilterModel(QSortFilterProxyModel):
""" """
with debug.log_time(log.completion, 'Setting filter pattern'): with debug.log_time(log.completion, 'Setting filter pattern'):
self.pattern = val self.pattern = val
self.patternRe = re.compile(val.casefold().replace(" ", ".*"));
self.invalidateFilter() self.invalidateFilter()
sortcol = 0 sortcol = 0
try: try:
@ -146,8 +147,11 @@ class CompletionFilterModel(QSortFilterProxyModel):
data = self.srcmodel.data(idx) data = self.srcmodel.data(idx)
if not data: if not data:
continue continue
elif self.pattern.casefold() in data.casefold(): else:
if self.patternRe.search(data.casefold()):
return True return True
else:
return False
return False return False
def intelligentLessThan(self, lindex, rindex): def intelligentLessThan(self, lindex, rindex):