def __dragMove( self, listing, event ) :

		if self.__dragItem is None :
			return False

		# update our layout structure to reflect the drag
		#################################################

		# find newParent and newIndex - variables specifying
		# the new location for the dragged item.
		targetPath = self.__pathListing.pathAt( event.line.p0 )
		if targetPath is not None :
			targetItem = targetPath.item()
			if targetItem is not None :
				if isinstance( targetItem, _SectionLayoutItem ) and self.__pathListing.getPathExpanded( targetPath ) and targetItem.parent() is self.__dragItem.parent() :
					newParent = targetItem
					newIndex = 0
				else :
					newParent = targetItem.parent()
					newIndex = newParent.index( targetItem )
			else :
				# target is a placeholder added into an empty
				# section by __LayoutPath._children().
				newParent = targetPath.copy().truncateUntilValid().item()
				newIndex = 0
		else :
			# drag has gone above or below all listed items
			newParent = self.__pathListing.getPath().rootItem()
			newIndex = 0 if event.line.p0.y < 1 else len( newParent )

		# skip any attempted circular reparenting

		if newParent is self.__dragItem or self.__dragItem.isAncestorOf( newParent ) :
			return True

		# disallow drags that would place a plug below a section

		firstNonPlugIndex = next(
			( x[0] for x in enumerate( newParent ) if not isinstance( x[1], _PlugLayoutItem ) ),
			len( newParent )
		)
		if self.__dragItem.parent() is newParent and newParent.index( self.__dragItem ) < firstNonPlugIndex :
			firstNonPlugIndex -= 1

		if isinstance( self.__dragItem, _PlugLayoutItem ) :
			if newIndex > firstNonPlugIndex :
				return True
		else :
			if newIndex < firstNonPlugIndex :
				newIndex = max( newIndex, firstNonPlugIndex )

		self.__dragItem.parent().remove( self.__dragItem )
		newParent.insert( newIndex, self.__dragItem )

		# let the listing know we've been monkeying behind the scenes.
		# we need to update the selection, because when we reparented
		# the drag item its path will have changed.
		##############################################################

		self.__pathListing.getPath().pathChangedSignal()( self.__pathListing.getPath() )

		selection = self.__pathListing.getPath().copy()
		selection[:] = self.__dragItem.fullName().split( "." )
		self.__pathListing.setSelectedPaths( [ selection ], scrollToFirst = False, expandNonLeaf = False )

		return True
dataset/ETHPy150Open ImageEngine/gaffer/python/GafferUI/UIEditor.py/_PlugListing.__dragMove/original