Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix / Update File List Form on Folder Double Clicked #131

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions python/tk_multi_workfiles/browser_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def __init__(self, label, tab_index):
) # file, env, pnt
entity_type_focus_changed = QtCore.Signal(object) # entity type
step_filter_changed = QtCore.Signal(list) # SG filter
folder_double_clicked = QtCore.Signal(object) # folder

task_double_clicked = QtCore.Signal(object) # My tasks task double clicked

Expand Down Expand Up @@ -250,6 +251,7 @@ def set_models(self, my_tasks_model, entity_models, file_model):
step_entity_filter=step_entity_filter,
)
entity_form.entity_selected.connect(self._on_entity_selected)
self.folder_double_clicked.connect(entity_form.select_folder_entity)
self._ui.task_browser_tabs.addTab(entity_form, caption)
entity_form.create_new_task.connect(self.create_new_task)
self._entity_tree_forms.append(entity_form)
Expand Down Expand Up @@ -333,6 +335,7 @@ def _add_file_list_form(
file_form.set_model(self._file_model)
file_form.file_selected.connect(self._on_file_selected)
file_form.file_double_clicked.connect(self.file_double_clicked)
file_form.folder_double_clicked.connect(self.folder_double_clicked)
file_form.file_context_menu_requested.connect(
self._on_file_context_menu_requested
)
Expand Down
4 changes: 4 additions & 0 deletions python/tk_multi_workfiles/entity_tree/entity_tree_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ def ensure_data_for_context(self, context):
"""
self.entity_model.ensure_data_for_context(context)

def select_folder_entity(self, folder):
self._reset_selection()
self.select_entity(folder["type"], folder["id"])

def select_entity(self, entity_type, entity_id):
"""
Select the specified entity in the tree.
Expand Down
8 changes: 6 additions & 2 deletions python/tk_multi_workfiles/file_list/file_list_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class FileListForm(QtGui.QWidget):
# Signal emitted whenever a file is double-clicked
file_double_clicked = QtCore.Signal(object, object) # file, env

# Signal emitted whenever a folder is double-clicked
folder_double_clicked = QtCore.Signal(object) # folder

# Signal emitted whenever a context menu is required for a file
file_context_menu_requested = QtCore.Signal(
object, object, QtCore.QPoint
Expand Down Expand Up @@ -605,8 +608,9 @@ def _on_item_double_clicked(self, idx):
item_type = get_model_data(idx, FileModel.NODE_TYPE_ROLE)
if item_type == FileModel.FOLDER_NODE_TYPE:
# selection is a folder/child so move into it
# TODO
pass
selected_item = get_model_data(idx, FileModel.FOLDER_ENTITY_ROLE)
env_details = get_model_data(idx, FileModel.WORK_AREA_ROLE)
self.folder_double_clicked.emit(selected_item)
elif item_type == FileModel.FILE_NODE_TYPE:
# this is a file so perform the default action for the file
selected_file = get_model_data(idx, FileModel.FILE_ITEM_ROLE)
Expand Down
29 changes: 29 additions & 0 deletions python/tk_multi_workfiles/file_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __repr__(self):
WORK_AREA_ROLE = _BASE_ROLE + 3 # WorkArea data
SEARCH_STATUS_ROLE = _BASE_ROLE + 4 # search status data
SEARCH_MSG_ROLE = _BASE_ROLE + 5 # search message data
FOLDER_ENTITY_ROLE = _BASE_ROLE + 6 # FolderEntity data

class _BaseModelItem(QtGui.QStandardItem):
"""
Expand Down Expand Up @@ -198,6 +199,34 @@ def __init__(self, name, entity):
)
self._entity = entity

def data(self, role):
"""
Return the data from the item for the specified role.

:param role: The role to return data for.
:returns: Data for the specified role
"""
if role == FileModel.FOLDER_ENTITY_ROLE:
return self._entity
else:
return FileModel._BaseModelItem.data(self, role)

def setData(self, value, role):
"""
Set the data on the item for the specified role

:param value: The value to set the data with
:param role: The role to set the data for
"""
if role == QtCore.Qt.DisplayRole:
# do nothing as it can't be set!
pass
elif role == FileModel.FOLDER_ENTITY_ROLE:
self._entity = value
else:
# call the base implementation:
FileModel._BaseModelItem.setData(self, value, role)

@property
def entity(self):
"""
Expand Down