|
|
@ -32,7 +32,38 @@ import engine.api as api |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TrackListWidget(QtWidgets.QListWidget): |
|
|
|
class TrackListWidget(QtWidgets.QWidget): |
|
|
|
"""Small container wrapper for a title, checkboxes etc.""" |
|
|
|
|
|
|
|
def __init__(self, mainWindow, parentSplitter): |
|
|
|
super().__init__(parentSplitter) |
|
|
|
|
|
|
|
self.mainWindow = mainWindow |
|
|
|
self.layout = QtWidgets.QVBoxLayout(self) |
|
|
|
|
|
|
|
self.trackLabel = QtWidgets.QLabel("Hello") |
|
|
|
self.showEverythingCheckBox = QtWidgets.QCheckBox(QtCore.QCoreApplication.translate("TrackListWidget", "Show Everything")) |
|
|
|
self.showEverythingCheckBox.setChecked(True) |
|
|
|
self.showEverythingCheckBox.toggled.connect(self.reactShowEverything) |
|
|
|
self.realTrackListWidget = _TrackListWidget(mainWindow, self) |
|
|
|
|
|
|
|
self.layout.addWidget(self.trackLabel) |
|
|
|
self.layout.addWidget(self.showEverythingCheckBox) |
|
|
|
self.layout.addWidget(self.realTrackListWidget, stretch=1) |
|
|
|
|
|
|
|
api.callbacks.setCursor.append(self.setCursor) |
|
|
|
|
|
|
|
|
|
|
|
def reactShowEverything(self, newState:bool): |
|
|
|
self.realTrackListWidget.showEverything(newState) |
|
|
|
|
|
|
|
def setCursor(self, c:dict): |
|
|
|
self.trackLabel.setText( "<b>{}-{}</b>".format(c["trackIndex"]+1, c["trackName"]) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _TrackListWidget(QtWidgets.QListWidget): |
|
|
|
"""The TrackListWidget holds all tracks as text-only variants with cursor access. |
|
|
|
It will show one track at a time, the current one. |
|
|
|
|
|
|
@ -45,24 +76,32 @@ class TrackListWidget(QtWidgets.QListWidget): |
|
|
|
We recreate the items on track change. |
|
|
|
""" |
|
|
|
|
|
|
|
def __init__(self, mainWindow, parentSplitter): |
|
|
|
def __init__(self, mainWindow, parentWidget): |
|
|
|
|
|
|
|
super().__init__(parentSplitter) |
|
|
|
super().__init__() |
|
|
|
self.mainWindow = mainWindow |
|
|
|
|
|
|
|
self._lastCurrentTrack = None |
|
|
|
self._lastCurrentTrackId = None |
|
|
|
self.tracks = {} # engineTrackId : engineExportData |
|
|
|
|
|
|
|
self.itemPressed.connect(self._react_itemPressed) |
|
|
|
|
|
|
|
self._showEverything = True |
|
|
|
|
|
|
|
api.callbacks.tracksChanged.append(self.syncTracks) |
|
|
|
api.callbacks.updateTrack.append(self.updateTrack) |
|
|
|
api.callbacks.setCursor.append(self.setCursor) |
|
|
|
|
|
|
|
|
|
|
|
def showEverything(self, state:bool): |
|
|
|
"""Can be called externally to filter out the most common items. |
|
|
|
The indexing and cursor will still work""" |
|
|
|
self._showEverything = state |
|
|
|
self.showTrack(self._lastCurrentTrackId) |
|
|
|
|
|
|
|
def setCursor(self, cursorExportObject): |
|
|
|
if not self._lastCurrentTrack == cursorExportObject["trackId"]: |
|
|
|
self._lastCurrentTrack == cursorExportObject["trackId"] |
|
|
|
if not self._lastCurrentTrackId == cursorExportObject["trackId"]: |
|
|
|
self._lastCurrentTrackId = cursorExportObject["trackId"] |
|
|
|
self.showTrack(cursorExportObject["trackId"]) |
|
|
|
|
|
|
|
self.blockSignals(True) |
|
|
@ -73,7 +112,8 @@ class TrackListWidget(QtWidgets.QListWidget): |
|
|
|
def _react_itemPressed(self, item): |
|
|
|
"""This is gui->api cursor setting |
|
|
|
It only happens when the mouse etc. actually pressed an item. |
|
|
|
This list cannot be activated by cursor keys etc. directly. """ |
|
|
|
This list cannot be activated by cursor keys etc. directly. |
|
|
|
""" |
|
|
|
|
|
|
|
api.toPosition(self.currentRow()) #currentRow is calculated after we already are on the item. |
|
|
|
|
|
|
@ -94,7 +134,7 @@ class TrackListWidget(QtWidgets.QListWidget): |
|
|
|
return |
|
|
|
|
|
|
|
self.tracks[trackId] = staticRepresentationList |
|
|
|
if trackId == self._lastCurrentTrack: |
|
|
|
if trackId == self._lastCurrentTrackId: |
|
|
|
self.showTrack(trackId) |
|
|
|
|
|
|
|
|
|
|
@ -106,6 +146,17 @@ class TrackListWidget(QtWidgets.QListWidget): |
|
|
|
self.clear() |
|
|
|
staticRepresentationList = self.tracks[trackId] |
|
|
|
count = 0 |
|
|
|
for staticItem in staticRepresentationList: |
|
|
|
self.addItem(staticItem["UIstring"]) |
|
|
|
|
|
|
|
filterTypes = set(("Chord", "Rest")) |
|
|
|
|
|
|
|
if self._showEverything: |
|
|
|
for staticItem in staticRepresentationList: |
|
|
|
self.addItem(staticItem["UIstring"]) |
|
|
|
else: #Hide Chords and Rests. The indexing and cursor will still work |
|
|
|
for staticItem in staticRepresentationList: |
|
|
|
item = QtWidgets.QListWidgetItem(staticItem["UIstring"]) |
|
|
|
self.addItem(item) |
|
|
|
if staticItem["type"] in filterTypes: |
|
|
|
item.setHidden(True) |
|
|
|
|
|
|
|
self.addItem("|") #Appending |
|
|
|