mirror of
https://github.com/ankitects/anki.git
synced 2026-01-14 06:23:57 -05:00
Readd browser.model.getCard()
Actually, the new model has no truck with card objects, but since it may hold an invalid id, it takes responsibility for catching the exception.
This commit is contained in:
parent
88f39fe081
commit
a1ea88bc67
1 changed files with 8 additions and 1 deletions
|
|
@ -203,6 +203,13 @@ class DataModel(QAbstractTableModel):
|
|||
except:
|
||||
return CellRow.deleted(len(self.activeCols))
|
||||
|
||||
def getCard(self, index: QModelIndex) -> Optional[Card]:
|
||||
"""Try to return the indicated, possibly deleted card."""
|
||||
try:
|
||||
return self.col.getCard(self.get_id(index))
|
||||
except:
|
||||
return None
|
||||
|
||||
# Model interface
|
||||
######################################################################
|
||||
|
||||
|
|
@ -818,7 +825,7 @@ QTableView {{ gridline-color: {grid} }}
|
|||
show = self.model.cards and update == 1
|
||||
idx = self.form.tableView.selectionModel().currentIndex()
|
||||
if idx.isValid():
|
||||
self.card = self.col.getCard(self.model.get_id(idx))
|
||||
self.card = self.model.getCard(idx)
|
||||
show = show and self.card is not None
|
||||
self.form.splitter.widget(1).setVisible(bool(show))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue