Skip to content

outputs

Classes:

T module-attribute

AudioOutputs

AudioOutputs(main: MainWindow, local_storage: dict[str, T] | None = None)

Bases: Outputs[AudioOutput]

Methods:

Attributes:

Source code in vspreview/models/outputs.py
34
35
def __init__(self, main: MainWindow, local_storage: dict[str, T] | None = None) -> None:
    self.setValue(main, local_storage)

items instance-attribute

items: list[T]

main instance-attribute

main: MainWindow

out_type class-attribute instance-attribute

out_type = AudioOutput

vs_type class-attribute instance-attribute

vs_type = AudioNode

append

append(item: T) -> int
Source code in vspreview/models/outputs.py
80
81
82
83
84
85
86
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

clear() -> None
Source code in vspreview/models/outputs.py
88
89
90
91
92
93
def clear(self) -> None:
    self.clear_outputs()
    self.beginRemoveRows(QModelIndex(), 0, len(self.items))
    self.items.clear()
    self._items.clear()
    self.endRemoveRows()

clear_outputs

clear_outputs() -> None
Source code in vspreview/models/outputs.py
64
65
66
def clear_outputs(self) -> None:
    for output in (*self.items, *self._items):
        output.clear()

data

data(index: QModelIndex, role: int = UserRole) -> Any
Source code in vspreview/models/outputs.py
 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 in vspreview/models/outputs.py
112
113
114
115
116
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
    if not index.isValid():
        return Qt.ItemFlag.ItemIsEnabled

    return super().flags(index) | Qt.ItemFlag.ItemIsEditable

index_of

index_of(item: T) -> int
Source code in vspreview/models/outputs.py
74
75
def index_of(self, item: T) -> int:
    return self.items.index(item)

rowCount

rowCount(parent: QModelIndex = QModelIndex()) -> int
Source code in vspreview/models/outputs.py
109
110
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
    return len(self.items)

setData

setData(index: QModelIndex, value: Any, role: int = EditRole) -> bool
Source code in vspreview/models/outputs.py
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

setValue(main: MainWindow, local_storage: dict[str, T] | None = None) -> None
Source code in vspreview/models/outputs.py
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)

Outputs

Outputs(main: MainWindow, local_storage: dict[str, T] | None = None)

Bases: Generic[T], QAbstractListModel, QYAMLObject

Methods:

Attributes:

Source code in vspreview/models/outputs.py
34
35
def __init__(self, main: MainWindow, local_storage: dict[str, T] | None = None) -> None:
    self.setValue(main, local_storage)

items instance-attribute

items: list[T]

main instance-attribute

main: MainWindow

out_type instance-attribute

out_type: type[T]

vs_type instance-attribute

vs_type: type[VideoOutputTuple] | type[AudioNode]

append

append(item: T) -> int
Source code in vspreview/models/outputs.py
80
81
82
83
84
85
86
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

clear() -> None
Source code in vspreview/models/outputs.py
88
89
90
91
92
93
def clear(self) -> None:
    self.clear_outputs()
    self.beginRemoveRows(QModelIndex(), 0, len(self.items))
    self.items.clear()
    self._items.clear()
    self.endRemoveRows()

clear_outputs

clear_outputs() -> None
Source code in vspreview/models/outputs.py
64
65
66
def clear_outputs(self) -> None:
    for output in (*self.items, *self._items):
        output.clear()

data

data(index: QModelIndex, role: int = UserRole) -> Any
Source code in vspreview/models/outputs.py
 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 in vspreview/models/outputs.py
112
113
114
115
116
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
    if not index.isValid():
        return Qt.ItemFlag.ItemIsEnabled

    return super().flags(index) | Qt.ItemFlag.ItemIsEditable

index_of

index_of(item: T) -> int
Source code in vspreview/models/outputs.py
74
75
def index_of(self, item: T) -> int:
    return self.items.index(item)

rowCount

rowCount(parent: QModelIndex = QModelIndex()) -> int
Source code in vspreview/models/outputs.py
109
110
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
    return len(self.items)

setData

setData(index: QModelIndex, value: Any, role: int = EditRole) -> bool
Source code in vspreview/models/outputs.py
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

setValue(main: MainWindow, local_storage: dict[str, T] | None = None) -> None
Source code in vspreview/models/outputs.py
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)

VideoOutputs

VideoOutputs(main: MainWindow, local_storage: dict[str, T] | None = None)

Bases: Outputs[VideoOutput]

Methods:

Attributes:

Source code in vspreview/models/outputs.py
34
35
def __init__(self, main: MainWindow, local_storage: dict[str, T] | None = None) -> None:
    self.setValue(main, local_storage)

items instance-attribute

items: list[T]

main instance-attribute

main: MainWindow

out_type class-attribute instance-attribute

out_type = VideoOutput

vs_type class-attribute instance-attribute

vs_type = VideoOutputTuple

append

append(item: T) -> int
Source code in vspreview/models/outputs.py
80
81
82
83
84
85
86
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

clear() -> None
Source code in vspreview/models/outputs.py
88
89
90
91
92
93
def clear(self) -> None:
    self.clear_outputs()
    self.beginRemoveRows(QModelIndex(), 0, len(self.items))
    self.items.clear()
    self._items.clear()
    self.endRemoveRows()

clear_outputs

clear_outputs() -> None
Source code in vspreview/models/outputs.py
64
65
66
def clear_outputs(self) -> None:
    for output in (*self.items, *self._items):
        output.clear()

data

data(index: QModelIndex, role: int = UserRole) -> Any
Source code in vspreview/models/outputs.py
 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 in vspreview/models/outputs.py
112
113
114
115
116
def flags(self, index: QModelIndex) -> Qt.ItemFlag:
    if not index.isValid():
        return Qt.ItemFlag.ItemIsEnabled

    return super().flags(index) | Qt.ItemFlag.ItemIsEditable

index_of

index_of(item: T) -> int
Source code in vspreview/models/outputs.py
74
75
def index_of(self, item: T) -> int:
    return self.items.index(item)

rowCount

rowCount(parent: QModelIndex = QModelIndex()) -> int
Source code in vspreview/models/outputs.py
109
110
def rowCount(self, parent: QModelIndex = QModelIndex()) -> int:
    return len(self.items)

setData

setData(index: QModelIndex, value: Any, role: int = EditRole) -> bool
Source code in vspreview/models/outputs.py
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

setValue(main: MainWindow, local_storage: dict[str, T] | None = None) -> None
Source code in vspreview/models/outputs.py
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)