Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def set_check_state_for_all_plugins(self, plugin, state):
:param plugin: Plugin for which tasks should be manipulated
:param state: checkstate to set.
"""
logger.debug("Setting state %d for all plugin %s" % (state, plugin))
logger.debug("Setting state %s for all plugin %s" % (state, plugin))

def _check_r(parent):
for child_index in range(parent.childCount()):
Expand Down
43 changes: 43 additions & 0 deletions tests/test_tree_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,49 @@


class TestPublishTreeWidget(PublishApiTestBase):
def test_all_check_state(self):
"""
If we have a bunch of active tasks followed by a bunch of inactive tasks, the addition
of the inactive tasks does not trigger an update of the parent's checkbox (because the update
relies on the checkbox.state_changed and the default is unchecked, so inactive tasks do not
trigger a state change). Test that we are forcing a recalculation to keep the parent's check_state
correct in all situations
"""
tree = self.manager.tree
context = self.manager.context
local_plugin, remote_plugin = self.manager._load_publish_plugins(context)

item = tree.root_item.create_item("item.parent", "Parent", "Parent")
item.add_task(local_plugin).active = True
item.add_task(remote_plugin).active = False
item = item.create_item("item.child", "Child", "Child")
item.add_task(local_plugin)
item.add_task(remote_plugin)
item = item.create_item("item.grandchild", "Grand Child", "Grand Child")
item.add_task(local_plugin)
item.add_task(remote_plugin)

tree_widget = self.PublishTreeWidget(None)
tree_widget.set_publish_manager(self.manager)
tree_widget.build_tree()

from sgtk.platform.qt import QtCore, QtGui

def iter_check_states(plugin):
for it in QtGui.QTreeWidgetItemIterator(tree_widget):
tree_item = it.value()
task = tree_item.get_publish_instance()
if isinstance(task, self.api.PublishTask) and task.plugin == plugin:
yield tree_item.check_state

tree_widget.set_check_state_for_all_plugins(local_plugin, QtCore.Qt.Checked)
for check_state in iter_check_states(local_plugin):
assert check_state == QtCore.Qt.Checked

tree_widget.set_check_state_for_all_plugins(remote_plugin, QtCore.Qt.Unchecked)
for check_state in iter_check_states(remote_plugin):
assert check_state == QtCore.Qt.Unchecked

def test_parent_partially_checked(self):
"""
If we have a bunch of active tasks followed by a bunch of inactive tasks, the addition
Expand Down