Bases: Generic[T]
, QAbstractListModel
, QYAMLObject
Methods:
Attributes:
Source code
| def __init__(self, main: MainWindow, local_storage: dict[str, T] | None = None) -> None:
self.setValue(main, local_storage)
|
out_type instance-attribute
vs_type instance-attribute
vs_type: type[VideoOutputTuple] | type[AudioNode]
append
Source code
| def append(self, item: T) -> int:
index = len(self.items)
self.beginInsertRows(QModelIndex(), index, index)
self.items.append(item)
self.endInsertRows()
return len(self.items) - 1
|
clear
Source code
| def clear(self) -> None:
self.clear_outputs()
self.beginRemoveRows(QModelIndex(), 0, len(self.items))
self.items.clear()
self._items.clear()
self.endRemoveRows()
|
clear_outputs
Source code
| def clear_outputs(self) -> None:
for output in (*self.items, *self._items):
output.clear()
|
data
data(index: QModelIndex, role: int = UserRole) -> Any
Source code
95
96
97
98
99
100
101
102
103
104
105
106
107 | def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.UserRole) -> Any:
if not index.isValid():
return None
if index.row() >= len(self.items):
return None
if role == Qt.ItemDataRole.DisplayRole:
return self.items[index.row()].name
if role == Qt.ItemDataRole.EditRole:
return self.items[index.row()].name
if role == Qt.ItemDataRole.UserRole:
return self.items[index.row()]
return None
|
flags
flags(index: QModelIndex) -> ItemFlag
Source code
| def flags(self, index: QModelIndex) -> Qt.ItemFlag:
if not index.isValid():
return Qt.ItemFlag.ItemIsEnabled
return super().flags(index) | Qt.ItemFlag.ItemIsEditable
|
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)
|
setData
setData(index: QModelIndex, value: Any, role: int = EditRole) -> bool
Source code
118
119
120
121
122
123
124
125
126
127
128
129 | def setData(self, index: QModelIndex, value: Any, role: int = Qt.ItemDataRole.EditRole) -> bool:
if not index.isValid():
return False
if not role == Qt.ItemDataRole.EditRole:
return False
if not isinstance(value, str):
return False
self.items[index.row()].name = value
self.dataChanged.emit(index, index, [role])
return True
|
setValue
Source code
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 | def setValue(self, main: MainWindow, local_storage: dict[str, T] | None = None) -> None:
super().__init__()
self.items = []
self.main = main
local_storage, newstorage = (local_storage, False) if local_storage is not None else ({}, True)
if main.storage_not_found:
newstorage = False
outputs = OrderedDict(sorted(vs.get_outputs().items()))
for i, vs_output in outputs.items():
if not isinstance(vs_output, self.vs_type):
continue
try:
output = local_storage[str(i)]
output.setValue(vs_output, i, newstorage) # type: ignore
except KeyError:
output = self.out_type(vs_output, i, newstorage) # type: ignore
self.items.append(output)
self._items = list(self.items)
|