Switch deleteOnIdle to a lower timer level and use a python loop to clean up instead of the qtimer itself in freewheeling mode. This hopefully improves performance
@ -48,9 +48,9 @@ class GuiScore(QtWidgets.QGraphicsScene):
self.tracks={}#trackId:guiTrack, #if we don't save the instances here in Python space Qt will loose them and they will not be displayed without any error message.
self.deleteOnIdleStack=[]# a stack that holds hidden items that need to be deleted. Hiding is much faster than deleting so we use that for the blocking function. Since we always recreate items and never re-use this is ok as a list. no need for a set.
self.deleteOnIdleStack=set()# a stack that holds hidden items that need to be deleted. Hiding is much faster than deleting so we use that for the blocking function.
self._deleteOnIdleLoop=QtCore.QTimer()
self._deleteOnIdleLoop.start(0)#0 means "if there is time"
self._deleteOnIdleLoop.start(100)#0 means "if there is time"
@ -65,7 +65,8 @@ class ScoreView(QtWidgets.QGraphicsView):
api.callbacks.setCursor.append(self.centerOnCursor)#returns a dict
api.callbacks.updateBlockTrack.append(self.updateMode)# We need this after every update because the track is redrawn after each update and we don't know what to show
self._lastSavedMode=None#CC, Blocks, Notes. for self.updateMode
api.callbacks.updateBlockTrack.append(self.updateModeSingleTrackRedraw)# We need this after every update because the track is redrawn after each update and we don't know what mode-components to show
style="""
QScrollBar:horizontal{
@ -86,6 +87,8 @@ class ScoreView(QtWidgets.QGraphicsView):
"""
self.setStyleSheet(style)
defwheelEvent(self,event):
ifQtWidgets.QApplication.keyboardModifiers()in(QtCore.Qt.ControlModifier,QtCore.Qt.ControlModifier|QtCore.Qt.ShiftModifier):#a workaround for a qt bug. see score.wheelEvent docstring.
event.ignore()#do not send to scene, but tell the mainWindow to use it.
@ -103,6 +106,7 @@ class ScoreView(QtWidgets.QGraphicsView):
#we register a callback in self init that checks constantsAndConfigs.followPlayhead
defstretchXCoordinates(self,factor):
"""Cumulative factor, multiplication"""
self.scoreScene.stretchXCoordinates(factor)
self.centerOnCursor(None)
@ -134,6 +138,14 @@ class ScoreView(QtWidgets.QGraphicsView):
@ -179,22 +196,37 @@ class ScoreView(QtWidgets.QGraphicsView):
#no modechange in the track editor
return
calledByMenu=args==(True,)# and not by track update or manually on e.g. program start to only show the right portions of the scene
ifself.mainWindow.ui.actionCC_Mode.isChecked():
ifcalledByMenuandself._lastSavedMode=="block":
self.stretchXCoordinates(4.0)#return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling
self.stretchXCoordinates(4.0)#return from half sized mode. If we do not come from block mode this is not needed. CC and Note mode have the same scaling