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. Override QAbstractItemModel::sort.
""" """
raise NotImplementedError 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: if parent == QModelIndex() or not self.pattern:
return True return True
try: for col in self.srcmodel.columns_to_filter:
return self.srcmodel.custom_filter(self.pattern, row, parent) idx = self.srcmodel.index(row, col, parent)
except NotImplementedError: if not idx.isValid():
for col in self.srcmodel.columns_to_filter: # No entries in parent model
idx = self.srcmodel.index(row, col, parent) continue
if not idx.isValid(): data = self.srcmodel.data(idx)
# No entries in parent model if not data:
continue continue
data = self.srcmodel.data(idx) elif self.pattern_re.search(data):
if not data: return True
continue return False
elif self.pattern_re.search(data):
return True
return False
def intelligentLessThan(self, lindex, rindex): def intelligentLessThan(self, lindex, rindex):
"""Custom sorting implementation. """Custom sorting implementation.