jvconnected.ui.models.midi

class jvconnected.ui.models.midi.MidiPortModel(*args, **kwargs)[source]

Bases: GenericQObject

Qt Bridge to jvconnected.interfaces.midi.BasePort

parent_model

The parent MidiPortsModel container

Property name: str

The port name

Property index: int

The port index

Property isActive: bool

Current state of the port

async Slot setIsActive(value: bool)[source]

Set the port state

class jvconnected.ui.models.midi.MidiPortsModel(*args)[source]

Bases: GenericQObject

Base container for MidiPortModel instances

Signal portAdded(port: jvconnected.ui.models.midi.MidiPortModel)

Fired when a new port is added

Signal portRemoved(port: jvconnected.ui.models.midi.MidiPortModel)

Fired when an existing port is removed

Signal portsUpdated()

Fired when any change is made in the container

Property engine: jvconnected.ui.models.engine.EngineModel

The EngineModel in use

Property count: int

Number of ports

async Slot setPortActive(name: str, value: bool)[source]

Enable or disable the port with the given name

Slot getByName(name: str) MidiPortModel[source]

Lookup a port by name

Slot getByIndex(ix: int) MidiPortModel[source]

Lookup a port by index

class jvconnected.ui.models.midi.InportsModel(*args)[source]

Bases: MidiPortsModel

Container for input ports as MidiPortModel instances

class jvconnected.ui.models.midi.OutportsModel(*args)[source]

Bases: MidiPortsModel

Container for input ports as MidiPortModel instances

class jvconnected.ui.models.midi.DeviceMapModel(*args, **kwargs)[source]

Bases: GenericQObject

Representation of a single device/channel map within DeviceMapsModel

Signal dataChanged(deviceId: str, attr: str)

Emitted on property changes

Parameters
  • deviceId – The deviceId of the instance emitting the signal

  • attr – The property name that changed

midi_io

The active MidiIO instance

Property deviceId: str

The device_id associated with this instance

Property deviceName: str

The display_name of the device

Property isMapped: bool

True if the device is mapped to a Midi channel

Property isOnline: bool

True if the device is currently online

Property channel: int

If edited is True, the midi channel to assign to the device. Otherwise the channel currently assigned

Allowed values are from 0 to 15 and -1 is used to indicate no assignment (where isMapped is False)

Property deviceIndex: int

The device_index

Property edited: bool

True if the channel has been edited by the user

Slot reset()[source]

Reset the channel to its original value

get_current_channel() int[source]

Get the midi channel currently assigned within midi_io. -1 is returned if there is not assigned channel

class jvconnected.ui.models.midi.SortFilterProxyModel[source]

Bases: QSortFilterProxyModel

Sortable proxy model for DeviceMapsModel

class jvconnected.ui.models.midi.DeviceMapsModel(*args)[source]

Bases: QAbstractTableModel

A table model used to interface with MidiIO device mapping

DeviceMapsModel instances are created for each device within jvconnected.config.Config.devices and their channel values are read from MidiIO.

Changes to the channel assignments are stored temporarily until applied or reset

role_attrs

DeviceMapModel property names used to populate the table columns

role_names

PySide2.QtCore.Qt.UserRole mapped to each property defined in role_attrs

This is convoluted, weird, cumbersome and many other adjectives, but it seems to be the only way to make PySide2.QtCore.QAbstractTableModel act like a table. No clue why “roles” are necessary to access columns since that’s all a table is supposed to be ¯\_(ツ)_/¯

midi_io

The MidiIO instance within the engine

Property engine: jvconnected.ui.models.engine.EngineModel

The EngineModel in use

Property proxyModel: jvconnected.ui.models.midi.SortFilterProxyModel

An attached SortFilterProxyModel instance

Property sortColumn: int

The current sort column (index of the current role_name)

Slot setSorting(role_name: str, order: <class 'PySide2.QtCore.Qt.SortOrder'>)[source]

Sort the proxyModel by the given role_name

Slot incrementChannel(device_id: str) int[source]

Increment the channel for the given device_id by at least one.

Existing channel mappings are skipped and if the channel number would be out of range, no changes are made.

Slot decrementChannel(device_id: str) int[source]

Decrease the channel for the given device_id by at least one.

Existing channel mappings are skipped and if the channel number would be out of range, no changes are made.

This only affects the temporary value in the model.

Slot unassignChannel(device_id: str)[source]

Unassign the channel for the given device

This only affects the temporary value in the model.

Slot resetChannel(device_id: str)[source]

Reset the channel for the given device

This only affects the temporary value in the model.

async Slot apply()[source]

Apply any changes made to the DeviceMapModel.channel mappings

Remaps the necessary device/channel mappings in midi_io

Slot reset()[source]

Reset all edited channels back to their original states

roleNames(self) Dict[int, PySide2.QtCore.QByteArray][source]
columnCount(self, parent: PySide2.QtCore.QModelIndex = Invalid(PySide2.QtCore.QModelIndex)) int[source]
rowCount(self, parent: PySide2.QtCore.QModelIndex = Invalid(PySide2.QtCore.QModelIndex)) int[source]
flags(self, index: PySide2.QtCore.QModelIndex) PySide2.QtCore.Qt.ItemFlags[source]
data(self, index: PySide2.QtCore.QModelIndex, role: int = PySide2.QtCore.Qt.ItemDataRole.DisplayRole) Any[source]