diff -r a25f95af0a51 -r 1b728f26d1ae src/eric7/Project/Project.py --- a/src/eric7/Project/Project.py Tue Oct 24 11:45:39 2023 +0200 +++ b/src/eric7/Project/Project.py Wed Oct 25 14:30:33 2023 +0200 @@ -712,11 +712,11 @@ """ return list(self.__fileCategoriesRepository.keys()) - def getFileCategoryFilterString( + def getFileCategoryFilters( self, categories=None, withOthers=False, withAll=True ): """ - Public method to get a file selection string for the given categories. + Public method to get a list of file selection filters for the given categories. @param categories list of file type categories (defaults to None). A value of None means all categories except 'OTHERS'. @@ -727,8 +727,8 @@ @param withAll flag indicating to include a filter for 'All Files' (defaults to True) @type bool (optional) - @return file selection filter string - @rtype str + @return list of file selection filter strings + @rtype list of str """ if categories is None: categories = [c for c in self.__fileCategoriesRepository if c != "OTHERS"] @@ -749,11 +749,35 @@ " ".join(sorted(patterns[filetype])) ) ) - filterString = ";;".join(sorted(filters)) + filters = sorted(filters) if withAll: - filterString += ";;" + self.tr("All Files (*)") - - return filterString + filters.append(self.tr("All Files (*)")) + + return filters + + def getFileCategoryFilterString( + self, categories=None, withOthers=False, withAll=True + ): + """ + Public method to get a file selection string for the given categories. + + @param categories list of file type categories (defaults to None). + A value of None means all categories except 'OTHERS'. + @type list of str (optional) + @param withOthers flag indicating to include the 'OTHERS' category + (defaults to False) + @type bool (optional) + @param withAll flag indicating to include a filter for 'All Files' + (defaults to True) + @type bool (optional) + @return file selection filter string + @rtype str + """ + return ";;".join( + self.getFileCategoryFilters( + categ=categories, withOthers=withOthers, withAll=withAll + ) + ) def getFileCategoryString(self, category): """ @@ -1901,7 +1925,7 @@ """ from .AddFileDialog import AddFileDialog - if startdir is None: + if not startdir: startdir = self.ppath dlg = AddFileDialog(self, self.parent(), fileTypeFilter, startdir=startdir) @@ -2079,7 +2103,7 @@ """ from .AddDirectoryDialog import AddDirectoryDialog - if startdir is None: + if not startdir: startdir = self.ppath dlg = AddDirectoryDialog(self, fileTypeFilter, self.parent(), startdir=startdir)