diff --git a/qutebrowser/models/completionfilter.py b/qutebrowser/models/completionfilter.py index 4bf33ed42..58f1056af 100644 --- a/qutebrowser/models/completionfilter.py +++ b/qutebrowser/models/completionfilter.py @@ -67,6 +67,19 @@ class CompletionFilterModel(QSortFilterProxyModel): self.sort(sortcol) self.invalidate() + @property + def item_count(self): + """Get the count of non-toplevel items currently visible. + + Note this only iterates one level deep, as we only need root items + (categories) and children (items) in our model. + """ + count = 0 + for i in range(self.rowCount()): + cat = self.index(i, 0) + count += self.rowCount(cat) + return count + def first_item(self): """Return the first item in the model.""" for i in range(self.rowCount()): @@ -83,18 +96,6 @@ class CompletionFilterModel(QSortFilterProxyModel): return self.index(self.rowCount(cat) - 1, 0, cat) return QModelIndex() - def item_count(self): - """Get the count of non-toplevel items currently visible. - - Note this only iterates one level deep, as we only need root items - (categories) and children (items) in our model. - """ - count = 0 - for i in range(self.rowCount()): - cat = self.index(i, 0) - count += self.rowCount(cat) - return count - def mark_all_items(self, text): """Mark the given text in all visible items.""" for i in range(self.rowCount()): diff --git a/qutebrowser/widgets/_completion.py b/qutebrowser/widgets/_completion.py index 48ce6a6d2..6ee1c52c5 100644 --- a/qutebrowser/widgets/_completion.py +++ b/qutebrowser/widgets/_completion.py @@ -331,7 +331,7 @@ class CompletionView(QTreeView): logger.debug("pattern: {}".format(pattern)) self._model.pattern = pattern - if self._model.item_count() == 0: + if self._model.item_count == 0: self.hide() return @@ -373,7 +373,7 @@ class CompletionView(QTreeView): if indexes: data = self._model.data(indexes[0]) if data is not None: - if self._model.item_count() == 1 and config.get( + if self._model.item_count == 1 and config.get( 'completion', 'quick-complete'): # If we only have one item, we want to apply it immediately # and go on to the next part.