mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04: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
af90bbf879
commit
a27308dc9c
1 changed files with 8 additions and 1 deletions
|
@ -203,6 +203,13 @@ class DataModel(QAbstractTableModel):
|
||||||
except:
|
except:
|
||||||
return CellRow.deleted(len(self.activeCols))
|
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
|
# Model interface
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -818,7 +825,7 @@ QTableView {{ gridline-color: {grid} }}
|
||||||
show = self.model.cards and update == 1
|
show = self.model.cards and update == 1
|
||||||
idx = self.form.tableView.selectionModel().currentIndex()
|
idx = self.form.tableView.selectionModel().currentIndex()
|
||||||
if idx.isValid():
|
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
|
show = show and self.card is not None
|
||||||
self.form.splitter.widget(1).setVisible(bool(show))
|
self.form.splitter.widget(1).setVisible(bool(show))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue