parameters: (self, data, action, row, column, parentIndex)
return_statement: return False
docstring: Handle the data supplied by a drag and drop operation that ended with
          the given action.
docstring_summary: Handle the data supplied by a drag and drop operation that ended with
          the given action.
docstring_tokens: Handle the data supplied by a drag and drop operation that ended with the given action .
function: def dropMimeData(self, data, action, row, column, parentIndex):
          """
          Handle the data supplied by a drag and drop operation that ended with
          the given action.
          """
          if action == QtCore.Qt.IgnoreAction:
              return True
  
          # Index/Item to drop at. We can't use row/column because it looks like
          # it's a random value. Qt passes each time different value and it's not
          # possible to know what the user droped at. Another options is getting
          # selection.
          # We can get the Index at the dropped position
          indices = [self.treeView().dropIndex]
          if not indices or len(indices) != 1:
              # We can't drop to several items.
              return False
  
          # Index/Item to drop at.
          index = indices[0]
          item = index.internalPointer()
  
          if data.hasFormat(TreeModel.MIME_TYPE):
              # It's expression item
              expression = data.data(self.MIME_TYPE).data()
  
              if not expression:
                  return False
  
              # Trying to find it in the current origin
              originItem = item.getOriginItem()
              # Find the expression item
              expressionItem = originItem.find(path=expression, skipAlembic=True)
  
              if expressionItem:
                  if expressionItem.parent() == item.parent():
                      # We only need to reorder in case of parents are equals.
                      # Expression and Item are in the same tree parent.
                      if item.getType() != TreeItem.TYPE_EXPGROUP:
                          self.reOrderExpression(expressionItem, row)
                          return True
  
                  if expressionItem.parent().getType() == TreeItem.TYPE_EXPGROUP:
                      if expressionItem.parent() == item:
                          # Don't do anything if the expression is dropped to the
                          # group it already belongs to.
                          return False
  
                      if item.getType() == TreeItem.TYPE_EXPGROUP:
                          # When drop Item is a different group than the parent.
                          # Change Group of the expression
                          self.groupExpressions(
                              [self.indexFromItem(expressionItem)], index)
                          return True
  
                      if item.getType() == TreeItem.TYPE_ORIGIN:
                          # When expression dropped at Origin and belongs to a Group,
                          # Then ungroup.
                          self.unGroupExpressions([self.indexFromItem(expressionItem)])
                          return True
  
                      if item.parent().getType() == TreeItem.TYPE_ORIGIN:
                          # When Dropped on an expression outside of the group.
                          # Ungroup and reoder the list according to the drop index.
                          self.unGroupExpressions([self.indexFromItem(expressionItem)])
                          self.reOrderExpression(expressionItem, row)
                          return True
  
                  if item.getType() == TreeItem.TYPE_EXPRESSION:
                      if item.parent().getType() == TreeItem.TYPE_EXPGROUP:
                          # We allow drop an expression directly inbetween grouped expressions.
                          # This will Group and reorder
                          self.groupExpressions(
                              [self.indexFromItem(expressionItem)], self.indexFromItem(item.parent()))
                          self.reOrderExpression(expressionItem, row)
                          return True
  
                  if item.getType() == TreeItem.TYPE_EXPGROUP:
                      # When expressions are dropped on a Group.
                      # group
                      self.groupExpressions(
                          [self.indexFromItem(expressionItem)], index)
                      return True
  
              else:
                  # If wrong Origin don't do anything
                  # This will avoid creating a new expression in other walterStandin on Drag&Drop
                  return False
  
              return True
  
          elif data.hasFormat('application/x-maya-data') and data.hasText():
              # Get item
              originItem = item.getOriginItem()
  
              if item.getType() == TreeItem.TYPE_EXPGROUP:
                  itemsToSet = [item.child(i) for i in range(item.childCount())]
              else:
                  itemsToSet = [item]
  
              originName = originItem.getName()
              layer = self.treeView().getLayer()
  
              # Dropped maya object. We need to create an override.
              mayaObject = data.text()
              overrides = self.traverser.produceOverrides(mayaObject)
  
              for override, overrideType in overrides:
                  # Set tree view first
                  self.setData(index, override, TreeModel.dataType(overrideType))
  
                  # Set override for all the necessary objects
                  for i in itemsToSet:
                      self.traverser.setOverride(
                          originName,
                          layer,
                          i.alembicObject or i.expression,
                          override,
                          overrideType)
  
              return True
  
          return False
function_tokens: def dropMimeData ( self , data , action , row , column , parentIndex ) : if action == QtCore . Qt . IgnoreAction : return True # Index/Item to drop at. We can't use row/column because it looks like # it's a random value. Qt passes each time different value and it's not # possible to know what the user droped at. Another options is getting # selection. # We can get the Index at the dropped position indices = [ self . treeView ( ) . dropIndex ] if not indices or len ( indices ) != 1 : # We can't drop to several items. return False # Index/Item to drop at. index = indices [ 0 ] item = index . internalPointer ( ) if data . hasFormat ( TreeModel . MIME_TYPE ) : # It's expression item expression = data . data ( self . MIME_TYPE ) . data ( ) if not expression : return False # Trying to find it in the current origin originItem = item . getOriginItem ( ) # Find the expression item expressionItem = originItem . find ( path = expression , skipAlembic = True ) if expressionItem : if expressionItem . parent ( ) == item . parent ( ) : # We only need to reorder in case of parents are equals. # Expression and Item are in the same tree parent. if item . getType ( ) != TreeItem . TYPE_EXPGROUP : self . reOrderExpression ( expressionItem , row ) return True if expressionItem . parent ( ) . getType ( ) == TreeItem . TYPE_EXPGROUP : if expressionItem . parent ( ) == item : # Don't do anything if the expression is dropped to the # group it already belongs to. return False if item . getType ( ) == TreeItem . TYPE_EXPGROUP : # When drop Item is a different group than the parent. # Change Group of the expression self . groupExpressions ( [ self . indexFromItem ( expressionItem ) ] , index ) return True if item . getType ( ) == TreeItem . TYPE_ORIGIN : # When expression dropped at Origin and belongs to a Group, # Then ungroup. self . unGroupExpressions ( [ self . indexFromItem ( expressionItem ) ] ) return True if item . parent ( ) . getType ( ) == TreeItem . TYPE_ORIGIN : # When Dropped on an expression outside of the group. # Ungroup and reoder the list according to the drop index. self . unGroupExpressions ( [ self . indexFromItem ( expressionItem ) ] ) self . reOrderExpression ( expressionItem , row ) return True if item . getType ( ) == TreeItem . TYPE_EXPRESSION : if item . parent ( ) . getType ( ) == TreeItem . TYPE_EXPGROUP : # We allow drop an expression directly inbetween grouped expressions. # This will Group and reorder self . groupExpressions ( [ self . indexFromItem ( expressionItem ) ] , self . indexFromItem ( item . parent ( ) ) ) self . reOrderExpression ( expressionItem , row ) return True if item . getType ( ) == TreeItem . TYPE_EXPGROUP : # When expressions are dropped on a Group. # group self . groupExpressions ( [ self . indexFromItem ( expressionItem ) ] , index ) return True else : # If wrong Origin don't do anything # This will avoid creating a new expression in other walterStandin on Drag&Drop return False return True elif data . hasFormat ( 'application/x-maya-data' ) and data . hasText ( ) : # Get item originItem = item . getOriginItem ( ) if item . getType ( ) == TreeItem . TYPE_EXPGROUP : itemsToSet = [ item . child ( i ) for i in range ( item . childCount ( ) ) ] else : itemsToSet = [ item ] originName = originItem . getName ( ) layer = self . treeView ( ) . getLayer ( ) # Dropped maya object. We need to create an override. mayaObject = data . text ( ) overrides = self . traverser . produceOverrides ( mayaObject ) for override , overrideType in overrides : # Set tree view first self . setData ( index , override , TreeModel . dataType ( overrideType ) ) # Set override for all the necessary objects for i in itemsToSet : self . traverser . setOverride ( originName , layer , i . alembicObject or i . expression , override , overrideType ) return True return False