def setVariantValues(self, values): attrPath = self.getAttrPath() if not attrPath: return for i, value in enumerate(values): strValue = serializeAttrValue(value) cmds.pulseSetActionAttr(attrPath, strValue, v=i)
def dropMimeData(self, data, action, row, column, parentIndex): if not self.canDropMimeData(data, action, row, column, parentIndex): return False if action == QtCore.Qt.IgnoreAction: return True try: stepDataList = meta.decodeMetaData(str(data.data('text/plain'))) except Exception as e: LOG.error(e) return False print('dropData', stepDataList, data, action, row, column, parentIndex) beginRow = 0 parentPath = None if parentIndex.isValid(): parentStep = self.stepForIndex(parentIndex) if parentStep: if parentStep.canHaveChildren: # drop into step group beginRow = parentStep.numChildren() parentPath = parentStep.getFullPath() else: # drop next to step beginRow = parentIndex.row() parentPath = os.path.dirname(parentStep.getFullPath()) if not parentPath: parentPath = '' beginRow = self.rowCount(QtCore.QModelIndex()) if row != -1: beginRow = row cmds.undoInfo(openChunk=True, chunkName='Drag Pulse Actions') self.isMoveActionOpen = True cmds.evalDeferred(self._deferredMoveUndoClose) # create dropped steps count = len(stepDataList) for i in range(count): stepDataStr = serializeAttrValue(stepDataList[i]) newStepPath = cmds.pulseCreateStep( parentPath, beginRow + i, stepDataStr) if newStepPath: newStepPath = newStepPath[0] if action == QtCore.Qt.MoveAction: # create queue of renames to perform after source # steps have been removed targetName = stepDataList[i].get('name', '') self.dragRenameQueue.append((newStepPath, targetName)) return True
def redoIt(self): blueprintModel = getBlueprintModel() if blueprintModel: # TODO: fail if not changing anything # snapshot the whole action proxy, since it may change # significantly when modifying variant attrs self.oldStrData = serializeAttrValue( blueprintModel.getActionData(self.stepPath)) blueprintModel.setIsActionAttrVariant(self.attrPath, self.newValue)
def redoIt(self): blueprintModel = getBlueprintModel() if blueprintModel: # store old value as str self.oldStrValue = serializeAttrValue( blueprintModel.getActionAttr(self.attrPath, self.variantIndex)) # deserialize str value into objects value = deserializeAttrValue(self.newStrValue) blueprintModel.setActionAttr(self.attrPath, value, self.variantIndex)
def redoIt(self): blueprintModel = getBlueprintModel() if blueprintModel: # save the serialized step data before deleting step = blueprintModel.getStep(self.stepPath) if not step: raise RuntimeError("BuildStep not found: {0}".format( self.stepPath)) self.deletedStrData = serializeAttrValue(step.serialize()) self.deletedChildIndex = step.indexInParent() if not blueprintModel.deleteStep(self.stepPath): raise RuntimeError("Failed to delete BuildStep")
def setAttrValue(self, newValue): """ Set the current value of the attribute in this form. Performs partial validation and prevents setting the value if it's type is invalid. """ # value doesn't need to be valid as long # as it has the right type if self._isValueTypeValid(newValue): self.attrValue = newValue self._setFormValue(newValue) self.isValueValid = self._isValueValid(newValue) self._setUiValidState(self.isValueValid) # TODO: clean up relationship between preview value and actual value attrPath = self.getAttrPath() if not attrPath: return strValue = serializeAttrValue(newValue) cmds.pulseSetActionAttr(attrPath, strValue, v=self.variantIndex)