aqt.browser.table.model
=======================

.. py:module:: aqt.browser.table.model


Classes
-------

.. autoapisummary::

   aqt.browser.table.model.DataModel


Functions
---------

.. autoapisummary::

   aqt.browser.table.model.addon_column_fillin


Module Contents
---------------

.. py:class:: DataModel(parent: QObject, col: anki.collection.Collection, state: aqt.browser.table.state.ItemState, row_state_will_change_callback: aqt.qt.Callable, row_state_changed_callback: aqt.qt.Callable)

   Bases: :py:obj:`QAbstractTableModel`


   Data manager for the browser table.

   _items -- The card or note ids currently hold and corresponding to the
             table's rows.
   _rows -- The cached data objects to render items to rows.
   columns -- The data objects of all available columns, used to define the display
              of active columns and list all toggleable columns to the user.
   _block_updates -- If True, serve stale content to avoid hitting the DB.
   _stale_cutoff -- A threshold to decide whether a cached row has gone stale.


   .. py:attribute:: col
      :type:  anki.collection.Collection


   .. py:attribute:: columns
      :type:  dict[str, aqt.browser.table.Column]


   .. py:method:: get_cell(index: QModelIndex) -> aqt.browser.table.Cell


   .. py:method:: get_row(index: QModelIndex) -> aqt.browser.table.CellRow


   .. py:method:: get_cached_row(index: QModelIndex) -> aqt.browser.table.CellRow | None

      Get row if it is cached, regardless of staleness.



   .. py:method:: mark_cache_stale() -> None


   .. py:method:: reset() -> None


   .. py:method:: begin_reset() -> None


   .. py:method:: end_reset() -> None


   .. py:method:: begin_blocking() -> None


   .. py:method:: end_blocking() -> None


   .. py:method:: redraw_cells() -> None

      Update cell contents, without changing search count/columns/sorting.



   .. py:method:: is_empty() -> bool


   .. py:method:: len_rows() -> int


   .. py:method:: len_columns() -> int


   .. py:method:: get_item(index: QModelIndex) -> aqt.browser.table.ItemId


   .. py:method:: get_items(indices: list[QModelIndex]) -> collections.abc.Sequence[aqt.browser.table.ItemId]


   .. py:method:: get_card_ids(indices: list[QModelIndex]) -> collections.abc.Sequence[anki.cards.CardId]


   .. py:method:: get_note_ids(indices: list[QModelIndex]) -> collections.abc.Sequence[anki.notes.NoteId]


   .. py:method:: get_note_id(index: QModelIndex) -> anki.notes.NoteId | None


   .. py:method:: get_item_row(item: aqt.browser.table.ItemId) -> int | None


   .. py:method:: get_item_rows(items: collections.abc.Sequence[aqt.browser.table.ItemId]) -> list[int]


   .. py:method:: get_card_row(card_id: anki.cards.CardId) -> int | None


   .. py:method:: get_card(index: QModelIndex) -> anki.cards.Card | None

      Try to return the indicated, possibly deleted card.



   .. py:method:: get_note(index: QModelIndex) -> anki.notes.Note | None

      Try to return the indicated, possibly deleted note.



   .. py:method:: toggle_state(context: aqt.browser.table.SearchContext) -> aqt.browser.table.state.ItemState


   .. py:method:: search(context: aqt.browser.table.SearchContext) -> None


   .. py:method:: reverse() -> None


   .. py:method:: column_at(index: QModelIndex) -> aqt.browser.table.Column


   .. py:method:: column_at_section(section: int) -> aqt.browser.table.Column

      Returns the column object corresponding to the active column at index or the default
      column object if no data is associated with the active column.



   .. py:method:: active_column_index(column: str) -> int | None


   .. py:method:: toggle_column(column: str) -> None


   .. py:method:: rowCount(parent: QModelIndex = QModelIndex()) -> int


   .. py:method:: columnCount(parent: QModelIndex = QModelIndex()) -> int


   .. py:method:: data(index: QModelIndex = QModelIndex(), role: int = 0) -> anki.consts.Any


   .. py:method:: headerData(section: int, orientation: Qt.Orientation, role: int = 0) -> str | None


   .. py:method:: flags(index: QModelIndex) -> Qt.ItemFlag


.. py:function:: addon_column_fillin(key: str) -> aqt.browser.table.Column

   Return a column with generic fields and a label indicating to the user that this column was
   added by an add-on.


