Build list in focusCid and specify exception

model.cards may be a protobuf sequence but focusCid needs list's index
method, so convert to list, but only if needed.
This commit is contained in:
RumovZ 2021-01-30 13:15:46 +01:00
parent 4745b55d27
commit 9e9d8b9c7a

View File

@ -190,7 +190,7 @@ class DataModel(QAbstractTableModel):
ctx = SearchContext(search=txt, browser=self.browser)
gui_hooks.browser_will_search(ctx)
if ctx.card_ids is None:
ctx.card_ids = list(self.col.find_cards(ctx.search, order=ctx.order))
ctx.card_ids = self.col.find_cards(ctx.search, order=ctx.order)
gui_hooks.browser_did_search(ctx)
self.cards = ctx.card_ids
except Exception as err:
@ -1829,8 +1829,8 @@ where id in %s"""
def focusCid(self, cid):
try:
row = self.model.cards.index(cid)
except:
row = list(self.model.cards).index(cid)
except ValueError:
return
self.form.tableView.clearSelection()
self.form.tableView.selectRow(row)