Fix browser_did_fetch_row hook

This commit is contained in:
RumovZ 2021-03-29 12:16:50 +02:00
parent 13a0e2c82f
commit 2c7940e247
2 changed files with 10 additions and 4 deletions

View file

@ -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

View file

@ -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