Skip to content

Commit

Permalink
create tasks for selected assets
Browse files Browse the repository at this point in the history
  • Loading branch information
movalex committed Jul 3, 2023
1 parent fe58cb3 commit 109a396
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions openpype/tools/project_manager/project_manager/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,29 @@ def _collapse_items(self, indexes):
row, 0, index
))

def _create_tasks(self, indexes):
"""Create task for each selected asset
Args:
indexes (list): List of QModelIndex where task should be created.
"""
item_ids = set()
process_queue = Queue()
for index in indexes:
if index.column() == 0:
process_queue.put(index)

while not process_queue.empty():
index = process_queue.get()
item_id = index.data(IDENTIFIER_ROLE)
if item_id in item_ids:
continue
item_ids.add(item_id)

new_index = self.add_task(parent_index=index)
if new_index is None:
break

def _show_message(self, message):
"""Show message to user."""
self._parent.show_message(message)
Expand Down Expand Up @@ -590,6 +613,13 @@ def _on_context_menu(self, point):
)
actions.append(add_task_action)

add_create_tasks = False
if len(item_ids) > 1:
item = items_by_id[item_ids[0]]
item_type = item.data(ITEM_TYPE_ROLE)
if item_type == "asset":
add_create_tasks = True

# Remove delete tag on items
removed_item_ids = []
show_delete_items = False
Expand Down Expand Up @@ -638,6 +668,16 @@ def _on_context_menu(self, point):
actions.append(expand_action)
actions.append(collapse_action)

if add_create_tasks:
create_tasks = QtWidgets.QAction(
"Create Tasks for Selected",
context_menu
)
create_tasks.triggered.connect(
lambda: self._create_tasks(indexes)
)
actions.append(create_tasks)

if not actions:
return

Expand Down

0 comments on commit 109a396

Please sign in to comment.