Bases: QAbstractListModel
, Generic[T]
Methods:
Attributes:
Source code
| def __init__(self, init_seq: Sequence[T], to_title: bool = True) -> None:
super().__init__()
self.items = list(init_seq)
self.to_title = to_title
|
content_type instance-attribute
to_title instance-attribute
to_title: bool = to_title
data
data(index: QModelIndex, role: int = UserRole) -> Any
Source code
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 | def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.UserRole) -> Any:
if (not index.isValid() or index.row() >= len(self.items)):
return None
if role == Qt.ItemDataRole.DisplayRole:
value = self.items[index.row()]
str_value = self._displayValue(value)
if self.content_type is str and self.to_title:
return str_value.title()
return str_value
if role == Qt.ItemDataRole.UserRole:
return self.items[index.row()]
return None
|
index_of
Source code
| def index_of(self, item: T) -> int:
return self.items.index(item)
|
rowCount
rowCount(parent: QModelIndex = QModelIndex()) -> int
Source code
| def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
return len(self.items)
|