mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix browser_did_fetch_row hook
This commit is contained in:
parent
13a0e2c82f
commit
2c7940e247
2 changed files with 10 additions and 4 deletions
|
@ -892,7 +892,7 @@ class DataModel(QAbstractTableModel):
|
||||||
self._rows[item] = self._fetch_row_from_backend(item)
|
self._rows[item] = self._fetch_row_from_backend(item)
|
||||||
return self._rows[item]
|
return self._rows[item]
|
||||||
|
|
||||||
def _fetch_row_from_backend(self, item: int) -> CellRow:
|
def _fetch_row_from_backend(self, item: ItemId) -> CellRow:
|
||||||
try:
|
try:
|
||||||
row = CellRow(*self.col.browser_row_for_id(item))
|
row = CellRow(*self.col.browser_row_for_id(item))
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
|
@ -900,8 +900,9 @@ class DataModel(QAbstractTableModel):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return CellRow.generic(self.len_columns(), str(e))
|
return CellRow.generic(self.len_columns(), str(e))
|
||||||
|
|
||||||
# fixme: hook needs state
|
gui_hooks.browser_did_fetch_row(
|
||||||
gui_hooks.browser_did_fetch_row(item, row, self._state.active_columns)
|
item, not self._state.is_card_state(), row, self._state.active_columns
|
||||||
|
)
|
||||||
return row
|
return row
|
||||||
|
|
||||||
# Reset
|
# Reset
|
||||||
|
|
|
@ -406,7 +406,12 @@ hooks = [
|
||||||
),
|
),
|
||||||
Hook(
|
Hook(
|
||||||
name="browser_did_fetch_row",
|
name="browser_did_fetch_row",
|
||||||
args=["card_id: int", "row: aqt.table.CellRow", "columns: Sequence[str]"],
|
args=[
|
||||||
|
"card_or_note_id: aqt.table.ItemId",
|
||||||
|
"is_note: bool",
|
||||||
|
"row: aqt.table.CellRow",
|
||||||
|
"columns: Sequence[str]",
|
||||||
|
],
|
||||||
doc="""Allows you to add or modify content to a row in the browser.
|
doc="""Allows you to add or modify content to a row in the browser.
|
||||||
|
|
||||||
You can mutate the row object to change what is displayed. Any columns the
|
You can mutate the row object to change what is displayed. Any columns the
|
||||||
|
|
Loading…
Reference in a new issue