Skip to content

MarkdownItemDelegate

Qt Base Class: QStyledItemDelegate

Signature: QStyledItemDelegate(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
BaseMarkupDelegate
prettyqt.itemdelegates.htmlitemdelegate

⋔ Inheritance diagram

graph TD
  1473367003296["itemdelegates.MarkdownItemDelegate"]
  1473367009152["itemdelegates.BaseMarkupDelegate"]
  1473296354464["widgets.StyledItemDelegate"]
  1473296344704["widgets.AbstractItemDelegateMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473293727280["QtWidgets.QStyledItemDelegate"]
  1473293758512["QtWidgets.QAbstractItemDelegate"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473367009152 --> 1473367003296
  1473296354464 --> 1473367009152
  1473296344704 --> 1473296354464
  1473299815024 --> 1473296344704
  140713234304496 --> 1473299815024
  1473293727280 --> 1473296354464
  1473293758512 --> 1473293727280
  1473288842240 --> 1473293758512
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: BaseMarkupDelegate

Delegate do display Markdown text.

Source code in prettyqt\itemdelegates\htmlitemdelegate.py
class MarkdownItemDelegate(BaseMarkupDelegate):
    """Delegate do display Markdown text."""

    ID = "markdown"

    def __init__(self, *args, mode: str = "github", **kwargs):
        super().__init__(*args, **kwargs)
        self._mode = mode

    def set_text(self, text: str):
        Feat = self.doc.MarkdownFeature
        match self._mode:
            case "no_html":
                self.doc.setMarkdown(text, Feat.MarkdownNoHTML)
            case "commonmark":
                self.doc.setMarkdown(text, Feat.MarkdownDialectCommonMark)
            case "github" | "":
                self.doc.setMarkdown(text, Feat.MarkdownDialectGitHub)
            case _:
                raise ValueError(self._mode)

    def get_markup_mode(self, str):
        return self._mode

    def set_markup_mode(self, mode: str):
        self._mode = mode

    markup_mode = core.Property(
        str,
        get_markup_mode,
        set_markup_mode,
        doc="Which markdown dialect to use.",
    )

⌗ Property table

Qt Property Type Doc
objectName QString
markup_mode QString Which markdown dialect to use.

Delegate ID: markdown