diff --git a/engine/findprograms.py b/engine/findprograms.py index a5b769b..4c2685d 100644 --- a/engine/findprograms.py +++ b/engine/findprograms.py @@ -214,7 +214,6 @@ class SupportedProgramsDatabase(object): return None - def _build(self): self.executables = self.buildCache_grepExecutablePaths() self.desktopEntries = self.buildCache_DesktopEntries() @@ -226,6 +225,7 @@ class SupportedProgramsDatabase(object): self.progressHook(f"{fullPath}") entry = self._exeToDesktopEntry(exe) if entry: #Found match! + assert type(entry) is dict, type(entry) entry["agordejoFullPath"] = fullPath #We don't want .desktop syntax like "qmidiarp %F" entry["agordejoExec"] = exe diff --git a/qtgui/opensessioncontroller.py b/qtgui/opensessioncontroller.py index 125a843..bcb2712 100644 --- a/qtgui/opensessioncontroller.py +++ b/qtgui/opensessioncontroller.py @@ -142,8 +142,8 @@ class ClientTable(object): self.clientOverrideNamesCache = None #None or dict. Dict is never truly empty, it has at least empty categories. - self.sortByColumn = 0 #by name - self.sortAscending = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending + self.sortByColumnValue = 0 #by name + self.sortDescendingValue = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending self.clientsTreeWidget = self.mainWindow.ui.loadedSessionClients self.clientsTreeWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) @@ -172,7 +172,7 @@ class ClientTable(object): self.clientsTreeWidget.itemDoubleClicked.connect(self._reactSignal_itemDoubleClicked) #This is hide/show and NOT edit self.clientsTreeWidget.itemDelegate().closeEditor.connect(self._reactSignal_itemEditingFinished) self.clientsTreeWidget.model().layoutAboutToBeChanged.connect(self._reactSignal_rememberSorting) - self.clientsTreeWidget.model().layoutChanged.connect(self._reactSignal_restoreSorting) + #self.clientsTreeWidget.model().layoutChanged.connect(self._reactSignal_restoreSorting) #Convenience Signals to directly disable the client messages on gui instruction. #This is purely for speed and preventing the user from sending a signal while the session is shutting down self.mainWindow.ui.actionSessionAbort.triggered.connect(lambda: self._updateClientMenu(deactivate=True)) @@ -186,7 +186,7 @@ class ClientTable(object): api.callbacks.dataClientNamesChanged.append(self._reactCallback_dataClientNamesChanged) def _adjustColumnSize(self): - self.clientsTreeWidget.sortByColumn(self.sortByColumn, self.sortAscending) + self.clientsTreeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) for index in range(self.clientsTreeWidget.columnCount()): self.clientsTreeWidget.resizeColumnToContents(index) @@ -373,11 +373,13 @@ class ClientTable(object): ui.actionClientRename.setEnabled(True) def _reactSignal_rememberSorting(self, *args): - self.sortByColumn = self.clientsTreeWidget.header().sortIndicatorSection() - self.sortDescending = self.clientsTreeWidget.header().sortIndicatorOrder() + self.sortByColumnValue = self.clientsTreeWidget.header().sortIndicatorSection() + self.sortDescendingValue = self.clientsTreeWidget.header().sortIndicatorOrder() def _reactSignal_restoreSorting(self, *args): - self.clientsTreeWidget.sortByColumn(self.sortByColumn, self.sortDescending) + """Do not use as signal!!! Will lead to infinite recursion since Qt 5.12.2""" + #self.clientsTreeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) + raise RuntimeError() class LauncherProgram(QtWidgets.QTreeWidgetItem): """ @@ -441,8 +443,8 @@ class LauncherTable(object): self.mainWindow = mainWindow self.parent = parent - self.sortByColumn = 0 # by name - self.sortAscending = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending + self.sortByColumnValue = 0 # by name + self.sortDescendingValue = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending self.launcherWidget = self.mainWindow.ui.loadedSessionsLauncher self.launcherWidget.setIconSize(iconSize) @@ -467,7 +469,7 @@ class LauncherTable(object): def _adjustColumnSize(self): - self.launcherWidget.sortByColumn(self.sortByColumn, self.sortAscending) + self.launcherWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) for index in range(self.launcherWidget.columnCount()): self.launcherWidget.resizeColumnToContents(index) diff --git a/qtgui/sessiontreecontroller.py b/qtgui/sessiontreecontroller.py index cc5cd10..4f3c1d4 100644 --- a/qtgui/sessiontreecontroller.py +++ b/qtgui/sessiontreecontroller.py @@ -156,24 +156,22 @@ class SessionTreeController(object): #TODO: save sorting in user-wide qt application settings #We remember sorting via signals layoutAboutToBeChanged and restore via layoutChanged - self.sortByColumn = 0 #by name - self.sortDescending = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending + self.sortByColumnValue = 0 #by name + self.sortDescendingValue = 0 # Qt::SortOrder which is 0 for ascending and 1 for descending self.treeWidget.header().setSortIndicator(0,0) #Hack/Workaround. On startup it is not enough to set sorting. New items will be added in a random position. Maybe that is our async network adding. - #self.treeWidget.sortByColumn(self.sortByColumn, self.sortDescending) + #self.treeWidget.sortByColumn(self.sortByColumnValue, self.sortDescendingValue) api.callbacks.sessionsChanged.append(self._reactCallback_sessionsChanged) api.callbacks.sessionLocked.append(self._reactCallback_sessionLocked) api.callbacks.sessionFileChanged.append(self._reactCallback_sessionFileChanged) - self.treeWidget.itemDoubleClicked.connect(self._reactSignal_itemDoubleClicked) self.treeWidget.customContextMenuRequested.connect(self.contextMenu) self.treeWidget.model().layoutAboutToBeChanged.connect(self._reactSignal_rememberSorting) - self.treeWidget.model().layoutChanged.connect(self._reactSignal_restoreSorting) + #self.treeWidget.model().layoutChanged.connect(self._reactSignal_restoreSorting) self.mainWindow.ui.button_new_session.clicked.connect(self._reactSignal_newSession) self.mainWindow.ui.button_load_selected_session.clicked.connect(self._reactSignal_openSelected) - logger.info("Full View Session Chooser ready") def _reactCallback_sessionFileChanged(self, name:str, timestamp:str): @@ -197,7 +195,7 @@ class SessionTreeController(object): self.treeWidget.resizeColumnToContents(i) #Make the name column a few pixels wider self.treeWidget.setColumnWidth(0, self.treeWidget.columnWidth(0) + 25) - self.treeWidget.sortByColumn(self.sortByColumn, self.sortDescending) + self.treeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) def _addItemNested(self, sessionDict:dict): @@ -327,11 +325,13 @@ class SessionTreeController(object): api.sessionRename(nsmSessionName, widget.result) def _reactSignal_rememberSorting(self, *args): - self.sortByColumn = self.treeWidget.header().sortIndicatorSection() - self.sortDescending = self.treeWidget.header().sortIndicatorOrder() + self.sortByColumnValue = self.treeWidget.header().sortIndicatorSection() + self.sortDescendingValue = self.treeWidget.header().sortIndicatorOrder() def _reactSignal_restoreSorting(self, *args): - self.treeWidget.sortByColumn(self.sortByColumn, self.sortDescending) + """Do not use as signal!!! Will lead to infinite recursion since Qt 5.12.2""" + #self.treeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) + raise RuntimeError() def _reactSignal_nestedFlatChanged(self, checkStatus:bool): """#flat does not create directory items but changes the session name to dir/foo/bar""" @@ -342,4 +342,5 @@ class SessionTreeController(object): #And rebuild the items without fetching new data. if self._cachedSessionDicts: #not startup self._reactCallback_sessionsChanged(self._cachedSessionDicts) - self.treeWidget.sortByColumn(self.sortByColumn, self.sortDescending) + self.treeWidget.sortItems(self.sortByColumnValue, self.sortDescendingValue) +