Merge pull request #4096 from pypeclub/bugfix/extension_case_insensitive

Files Widget: Ignore case sensitivity of extensions
This commit is contained in:
Jakub Trllo 2022-11-15 13:15:45 +01:00 committed by GitHub
commit ffac58e2c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -541,6 +541,13 @@ class FileDefItem(object):
return ext
return None
@property
def lower_ext(self):
ext = self.ext
if ext is not None:
return ext.lower()
return ext
@property
def is_dir(self):
if self.is_empty:

View file

@ -349,7 +349,7 @@ class FilesModel(QtGui.QStandardItemModel):
item.setData(file_item.filenames, FILENAMES_ROLE)
item.setData(file_item.directory, DIRPATH_ROLE)
item.setData(icon_pixmap, ITEM_ICON_ROLE)
item.setData(file_item.ext, EXT_ROLE)
item.setData(file_item.lower_ext, EXT_ROLE)
item.setData(file_item.is_dir, IS_DIR_ROLE)
item.setData(file_item.is_sequence, IS_SEQUENCE_ROLE)
@ -463,7 +463,7 @@ class FilesProxyModel(QtCore.QSortFilterProxyModel):
for filepath in filepaths:
if os.path.isfile(filepath):
_, ext = os.path.splitext(filepath)
if ext in self._allowed_extensions:
if ext.lower() in self._allowed_extensions:
return True
elif self._allow_folders:
@ -475,7 +475,7 @@ class FilesProxyModel(QtCore.QSortFilterProxyModel):
for filepath in filepaths:
if os.path.isfile(filepath):
_, ext = os.path.splitext(filepath)
if ext in self._allowed_extensions:
if ext.lower() in self._allowed_extensions:
filtered_paths.append(filepath)
elif self._allow_folders: