completion: get rid of custom_filter (see #545)

This commit is contained in:
Jakub Klinkovský 2016-07-15 19:05:52 +02:00
parent d079caafa8
commit caf5937585
2 changed files with 11 additions and 24 deletions

View File

@ -133,13 +133,3 @@ class BaseCompletionModel(QStandardItemModel):
Override QAbstractItemModel::sort.
"""
raise NotImplementedError
def custom_filter(self, pattern, row, parent):
"""Custom filter.
Args:
pattern: The current filter pattern.
row: The row to accept or reject in the filter.
parent: The parent item QModelIndex.
"""
raise NotImplementedError

View File

@ -140,20 +140,17 @@ class CompletionFilterModel(QSortFilterProxyModel):
if parent == QModelIndex() or not self.pattern:
return True
try:
return self.srcmodel.custom_filter(self.pattern, row, parent)
except NotImplementedError:
for col in self.srcmodel.columns_to_filter:
idx = self.srcmodel.index(row, col, parent)
if not idx.isValid():
# No entries in parent model
continue
data = self.srcmodel.data(idx)
if not data:
continue
elif self.pattern_re.search(data):
return True
return False
for col in self.srcmodel.columns_to_filter:
idx = self.srcmodel.index(row, col, parent)
if not idx.isValid():
# No entries in parent model
continue
data = self.srcmodel.data(idx)
if not data:
continue
elif self.pattern_re.search(data):
return True
return False
def intelligentLessThan(self, lindex, rindex):
"""Custom sorting implementation.