Exemplo n.º 1
1
	def __init__(
		self,
		path,
		columns = defaultFileSystemColumns,
		allowMultipleSelection = False,
		displayMode = DisplayMode.List,
		**kw
	) :

		GafferUI.Widget.__init__( self, _TreeView(), **kw )

		self._qtWidget().setAlternatingRowColors( True )
		self._qtWidget().setUniformRowHeights( True )
		self._qtWidget().setEditTriggers( QtWidgets.QTreeView.NoEditTriggers )
		self._qtWidget().activated.connect( Gaffer.WeakMethod( self.__activated ) )

		if Qt.__binding__ in ( "PySide2", "PyQt5" ) :
			self._qtWidget().header().setSectionsMovable( False )
		else :
			self._qtWidget().header().setMovable( False )

		self._qtWidget().header().setSortIndicator( 0, QtCore.Qt.AscendingOrder )
		self._qtWidget().setSortingEnabled( True )

		self._qtWidget().expansionChanged.connect( Gaffer.WeakMethod( self.__expansionChanged ) )

		# install an empty model, so we an construct our selection model
		# around it. we'll update the model contents shortly in setPath().
		_GafferUI._pathListingWidgetUpdateModel( GafferUI._qtAddress( self._qtWidget() ), None )
		_GafferUI._pathListingWidgetSetColumns( GafferUI._qtAddress( self._qtWidget() ), columns )

		self.__selectionModel = QtCore.QItemSelectionModel( self._qtWidget().model() )
		self._qtWidget().setSelectionModel( self.__selectionModel )
		self.__selectionChangedSlot = Gaffer.WeakMethod( self.__selectionChanged )
		self._qtWidget().selectionModel().selectionChanged.connect( self.__selectionChangedSlot )
		if allowMultipleSelection :
			self._qtWidget().setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection )

		self.__pathSelectedSignal = GafferUI.WidgetSignal()
		self.__selectionChangedSignal = GafferUI.WidgetSignal()
		self.__displayModeChangedSignal = GafferUI.WidgetSignal()
		self.__expansionChangedSignal = GafferUI.WidgetSignal()

		# members for implementing drag and drop
		self.__emittingButtonPress = False
		self.__borrowedButtonPress = None
		self.__buttonPressConnection = self.buttonPressSignal().connect( Gaffer.WeakMethod( self.__buttonPress ) )
		self.__buttonReleaseConnection = self.buttonReleaseSignal().connect( Gaffer.WeakMethod( self.__buttonRelease ) )
		self.__mouseMoveConnection = self.mouseMoveSignal().connect( Gaffer.WeakMethod( self.__mouseMove ) )
		self.__dragBeginConnection = self.dragBeginSignal().connect( Gaffer.WeakMethod( self.__dragBegin ) )
		self.__dragEndConnection = self.dragEndSignal().connect( Gaffer.WeakMethod( self.__dragEnd ) )
		self.__dragPointer = "paths"

		self.__path = None

		self.setDisplayMode( displayMode )
		self.setPath( path )
Exemplo n.º 2
0
	def __update( self ) :

		# update the listing if necessary. when the path itself changes, we only
		# want to update if the directory being viewed has changed. if the path
		# hasn't changed at all then we assume that the filter has changed and
		# we therefore have to update the listing anyway.
		# \todo Add an argument to Path.pathChangedSignal() to specify whether it
		# is the path or the filtering that has changed, and remove self.__currentPath.
		# Also consider whether it might be easier for the C++ PathModel to be
		# doing the signal handling at that point.

		dirPath = self.__dirPath()
		if self.__currentDir!=dirPath or str( self.__path )==self.__currentPath :

			selectedPaths = self.getSelectedPaths()
			expandedPaths = None
			if str( self.__path ) == self.__currentPath :
				# the path location itself hasn't changed so we are assuming that just the filter has.
				# if we're in the tree view mode, the user would probably be very happy
				# if we didn't forget what was expanded.
				if self.getDisplayMode() == self.DisplayMode.Tree :
					expandedPaths = self.getExpandedPaths()

			_GafferUI._pathListingWidgetUpdateModel( GafferUI._qtAddress( self._qtWidget() ), dirPath.copy() )

			if expandedPaths is not None :
				self.setExpandedPaths( expandedPaths )

			self.setSelectedPaths( selectedPaths, scrollToFirst = False, expandNonLeaf = False )

			self.__currentDir = dirPath

		self.__currentPath = str( self.__path )
Exemplo n.º 3
0
    def __update(self):

        # update the listing if necessary. when the path itself changes, we only
        # want to update if the directory being viewed has changed. if the path
        # hasn't changed at all then we assume that the filter has changed and
        # we therefore have to update the listing anyway.
        # \todo Add an argument to Path.pathChangedSignal() to specify whether it
        # is the path or the filtering that has changed, and remove self.__currentPath.
        # Also consider whether it might be easier for the C++ PathModel to be
        # doing the signal handling at that point.

        dirPath = self.__dirPath()
        if self.__currentDir != dirPath or str(
                self.__path) == self.__currentPath:

            selectedPaths = self.getSelectedPaths()
            expandedPaths = None
            if str(self.__path) == self.__currentPath:
                # the path location itself hasn't changed so we are assuming that just the filter has.
                # if we're in the tree view mode, the user would probably be very happy
                # if we didn't forget what was expanded.
                if self.getDisplayMode() == self.DisplayMode.Tree:
                    expandedPaths = self.getExpandedPaths()

            _GafferUI._pathListingWidgetUpdateModel(
                GafferUI._qtAddress(self._qtWidget()), dirPath.copy())

            if expandedPaths is not None:
                self.setExpandedPaths(expandedPaths)

            self.setSelectedPaths(selectedPaths, scrollToFirst=False)

            self.__currentDir = dirPath

        self.__currentPath = str(self.__path)
Exemplo n.º 4
0
	def __init__(
		self,
		path,
		columns = defaultFileSystemColumns,
		allowMultipleSelection = False,
		displayMode = DisplayMode.List,
		**kw
	) :

		GafferUI.Widget.__init__( self, _TreeView(), **kw )

		self._qtWidget().setAlternatingRowColors( True )
		self._qtWidget().setUniformRowHeights( True )
		self._qtWidget().setEditTriggers( QtWidgets.QTreeView.NoEditTriggers )
		self._qtWidget().activated.connect( Gaffer.WeakMethod( self.__activated ) )

		if Qt.__binding__ in ( "PySide2", "PyQt5" ) :
			self._qtWidget().header().setSectionsMovable( False )
		else :
			self._qtWidget().header().setMovable( False )

		self._qtWidget().header().setSortIndicator( 0, QtCore.Qt.AscendingOrder )
		self._qtWidget().setSortingEnabled( True )

		self._qtWidget().expansionChanged.connect( Gaffer.WeakMethod( self.__expansionChanged ) )

		# install an empty model, so we an construct our selection model
		# around it. we'll update the model contents shortly in setPath().
		_GafferUI._pathListingWidgetUpdateModel( GafferUI._qtAddress( self._qtWidget() ), None )
		_GafferUI._pathListingWidgetSetColumns( GafferUI._qtAddress( self._qtWidget() ), columns )

		self.__selectionModel = QtCore.QItemSelectionModel( self._qtWidget().model() )
		self._qtWidget().setSelectionModel( self.__selectionModel )
		self.__selectionChangedSlot = Gaffer.WeakMethod( self.__selectionChanged )
		self._qtWidget().selectionModel().selectionChanged.connect( self.__selectionChangedSlot )
		if allowMultipleSelection :
			self._qtWidget().setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection )

		self.__pathSelectedSignal = GafferUI.WidgetSignal()
		self.__selectionChangedSignal = GafferUI.WidgetSignal()
		self.__displayModeChangedSignal = GafferUI.WidgetSignal()
		self.__expansionChangedSignal = GafferUI.WidgetSignal()

		# members for implementing drag and drop
		self.__emittingButtonPress = False
		self.__borrowedButtonPress = None
		self.__buttonPressConnection = self.buttonPressSignal().connect( Gaffer.WeakMethod( self.__buttonPress ) )
		self.__buttonReleaseConnection = self.buttonReleaseSignal().connect( Gaffer.WeakMethod( self.__buttonRelease ) )
		self.__mouseMoveConnection = self.mouseMoveSignal().connect( Gaffer.WeakMethod( self.__mouseMove ) )
		self.__dragBeginConnection = self.dragBeginSignal().connect( Gaffer.WeakMethod( self.__dragBegin ) )
		self.__dragEndConnection = self.dragEndSignal().connect( Gaffer.WeakMethod( self.__dragEnd ) )
		self.__dragPointer = "paths"

		self.__path = None

		self.setDisplayMode( displayMode )
		self.setPath( path )