Skip to content

MkItemModelTable

Base classes

Name Children Inherits
MkTable
mknodes.basenodes.mktable
Class representing a formatted table.

⋔ Inheritance diagram

graph TD
  1473367161408["prettyqtmarkdown.MkItemModelTable"]
  1473287562688["mktable.MkTable"]
  1473287594896["mkbasetable.MkBaseTable"]
  1473287555856["mkcontainer.MkContainer"]
  1473287579280["mknode.MkNode"]
  1473287420192["node.Node"]
  140713234304496["builtins.object"]
  1473287562688 --> 1473367161408
  1473287594896 --> 1473287562688
  1473287555856 --> 1473287594896
  1473287579280 --> 1473287555856
  1473287420192 --> 1473287579280
  140713234304496 --> 1473287420192

🛈 DocStrings

Bases: MkTable

Table which can display Qt ItemModels.

The given ItemModel will get proxied with a ProxyModel which translates data from some of the ItemRoles to Markup styling, and afterwords converted to a Markup table.

Source code in prettyqt\prettyqtmarkdown\mkitemmodeltable.py
class MkItemModelTable(mknodes.MkTable):
    """Table which can display Qt ItemModels.

    The given ItemModel will get proxied with a ProxyModel which translates
    data from some of the ItemRoles to Markup styling, and afterwords converted
    to a Markup table.
    """

    def __init__(
        self,
        model: core.AbstractItemModelMixin,
        use_checkstate_role: bool = True,
        **kwargs: Any,
    ):
        """Constructor.

        Arguments:
            model: The ItemModel to display.
            use_checkstate_role: whether to display the CheckStateRole value if available.
            kwargs: Keyword arguments passed to get_table_data.
        """
        proxy = itemmodels.SliceToMarkdownProxyModel(None, source_model=model)
        data, h_header, _ = proxy.get_table_data(
            use_checkstate_role=use_checkstate_role, **kwargs
        )
        data = list(zip(*data))
        super().__init__(data, columns=h_header)

__init__(model: core.AbstractItemModelMixin, use_checkstate_role: bool = True, **kwargs: Any)

Constructor.

Parameters:

Name Type Description Default
model AbstractItemModelMixin

The ItemModel to display.

required
use_checkstate_role bool

whether to display the CheckStateRole value if available.

True
kwargs Any

Keyword arguments passed to get_table_data.

{}
Source code in prettyqt\prettyqtmarkdown\mkitemmodeltable.py
def __init__(
    self,
    model: core.AbstractItemModelMixin,
    use_checkstate_role: bool = True,
    **kwargs: Any,
):
    """Constructor.

    Arguments:
        model: The ItemModel to display.
        use_checkstate_role: whether to display the CheckStateRole value if available.
        kwargs: Keyword arguments passed to get_table_data.
    """
    proxy = itemmodels.SliceToMarkdownProxyModel(None, source_model=model)
    data, h_header, _ = proxy.get_table_data(
        use_checkstate_role=use_checkstate_role, **kwargs
    )
    data = list(zip(*data))
    super().__init__(data, columns=h_header)