mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
fixed drop of multiple files for single file item input
This commit is contained in:
parent
7a6602a4d5
commit
b2b4b3cb9c
1 changed files with 15 additions and 0 deletions
|
|
@ -205,6 +205,18 @@ class FilesProxyModel(QtCore.QSortFilterProxyModel):
|
|||
return True
|
||||
return False
|
||||
|
||||
def filter_valid_files(self, filepaths):
|
||||
filtered_paths = []
|
||||
for filepath in filepaths:
|
||||
if os.path.isfile(filepath):
|
||||
_, ext = os.path.splitext(filepath)
|
||||
if ext in self._allowed_extensions:
|
||||
filtered_paths.append(filepath)
|
||||
|
||||
elif self._allow_folders:
|
||||
filtered_paths.append(filepath)
|
||||
return filtered_paths
|
||||
|
||||
def filterAcceptsRow(self, row, parent_index):
|
||||
# Skip filtering if multivalue is set
|
||||
if self._multivalue:
|
||||
|
|
@ -617,6 +629,9 @@ class FilesWidget(QtWidgets.QFrame):
|
|||
filepath = url.toLocalFile()
|
||||
if os.path.exists(filepath):
|
||||
filepaths.append(filepath)
|
||||
|
||||
# Filter filepaths before passing it to model
|
||||
filepaths = self._files_proxy_model.filter_valid_files(filepaths)
|
||||
if filepaths:
|
||||
self._add_filepaths(filepaths)
|
||||
event.accept()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue