ensure first result is shown when search is started

This commit is contained in:
Kovid Goyal 2022-06-19 14:23:45 +05:30
parent 27153f6580
commit 60dcd01a3f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -319,7 +319,7 @@ class ResultsModel(QAbstractItemModel):
def flags(self, index):
item = self.index_to_entry(index)
if item is None:
return 0
return Qt.ItemFlag.NoItemFlags
if isinstance(item, Results):
return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable
return Qt.ItemFlag.ItemIsSelectable | Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemNeverHasChildren
@ -393,6 +393,7 @@ class ResultsView(QTreeView):
with BusyCursor():
self.m.search(*a, restrict_to_book_ids=restrict, use_stemming=gprefs['fts_library_use_stemmer'])
self.expandAll()
self.setCurrentIndex(self.m.index(0, 0))
def show_context_menu(self, pos):
index = self.indexAt(pos)