示例#1
0
    def updateTooltip(self):
        """Updates the item tooltip"""
        fileName = self.getFilename()

        # Check that the file exists
        if not os.path.exists(fileName):
            self.__isValid = False
            self.setToolTip(0, 'Project file does not exist')
            self.setToolTip(1, 'Project file does not exist')
            self.__markBroken()
        else:
            # Get the project properties
            try:
                tooltip = getProjectFileTooltip(fileName)
                if Settings()['recentTooltips']:
                    self.setToolTip(1, tooltip)
                else:
                    self.setToolTip(1, "")
                self.setText(0, "")
                if fileName == GlobalData().project.fileName:
                    self.__markCurrent()
            except:
                # Cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip(0, 'Broken project file')
                self.setToolTip(1, 'Broken project file')
                self.__markBroken()
        self.setToolTip(2, self.getFilename())
    def updateTooltip( self ):
        " Updates the item tooltip "

        fileName = self.getFilename()

        # Check that the file exists
        if not os.path.exists( fileName ):
            self.__isValid = False
            self.setToolTip( 0, 'Project file does not exist' )
            self.setToolTip( 1, 'Project file does not exist' )
            self.__markBroken()
        else:

            # Get the project properties
            try:
                tooltip = getProjectFileTooltip( fileName )
                if Settings().recentTooltips:
                    self.setToolTip( 1, tooltip )
                else:
                    self.setToolTip( 1, "" )
                self.setText( 0, "" )
                if fileName == GlobalData().project.fileName:
                    self.__markCurrent()
            except:
                # Cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip( 0, 'Broken project file' )
                self.setToolTip( 1, 'Broken project file' )
                self.__markBroken()
        self.setToolTip( 2, self.getFilename() )
        return
示例#3
0
    def __init__( self, parent, path ):

        path = str( path )
        TreeViewItem.__init__( self, parent, os.path.basename( path ) )
        self.itemType = FileItemType
        self.parsingErrors = False  # Used for python files only
        self.isLink = False

        self.fileType = detectFileType( path )
        self.icon = getFileIcon( self.fileType )

        if self.fileType == BrokenSymlinkFileType:
            self.isLink = True
            self.toolTip = self.__brokenLinkTooltip( path )
            return

        if os.path.islink( path ):
            self.isLink = True
            self.toolTip = self.__linkTooltip( path )
            self.icon = PixmapCache().getIcon( 'filelink.png' )
            self.fileType = detectFileType( os.path.realpath( path ) )
            return

        # Fine corrections for some file types
        if self.fileType in [ PythonFileType, Python3FileType ]:
            self.populated = False
            self.lazyPopulation = True
            return

        if self.fileType == LinguistFileType:
            if path.endswith( '.ts' ):
                self.icon = PixmapCache().getIcon( 'filelinguist.png' )
            return

        if self.fileType == CodimensionProjectFileType:
            # Get the project properties
            try:
                self.toolTip = getProjectFileTooltip( path )
            except:
                # cannot get project properties
                self.toolTip = 'Broken project file'
            return

        return
示例#4
0
    def __init__(self, parent, path):

        path = str(path)
        TreeViewItem.__init__(self, parent, os.path.basename(path))
        self.itemType = FileItemType
        self.parsingErrors = False  # Used for python files only
        self.isLink = False

        self.fileType = detectFileType(path)
        self.icon = getFileIcon(self.fileType)

        if self.fileType == BrokenSymlinkFileType:
            self.isLink = True
            self.toolTip = self.__brokenLinkTooltip(path)
            return

        if os.path.islink(path):
            self.isLink = True
            self.toolTip = self.__linkTooltip(path)
            self.icon = PixmapCache().getIcon('filelink.png')
            self.fileType = detectFileType(os.path.realpath(path))
            return

        # Fine corrections for some file types
        if self.fileType in [PythonFileType, Python3FileType]:
            self.populated = False
            self.lazyPopulation = True
            return

        if self.fileType == LinguistFileType:
            if path.endswith('.ts'):
                self.icon = PixmapCache().getIcon('filelinguist.png')
            return

        if self.fileType == CodimensionProjectFileType:
            # Get the project properties
            try:
                self.toolTip = getProjectFileTooltip(path)
            except:
                # cannot get project properties
                self.toolTip = 'Broken project file'
            return

        return
示例#5
0
    def __walkTreeAndUpdate(self, treeItem, path, mime, icon, info):
        """Recursively walks the tree items and updates the icon"""
        if treeItem.itemType in [DirectoryItemType, SysPathItemType]:
            for i in treeItem.childItems:
                if i.itemType in [
                        DirectoryItemType, SysPathItemType, FileItemType
                ]:
                    self.__walkTreeAndUpdate(i, path, mime, icon, info)

        if treeItem.itemType == FileItemType:
            if path == os.path.realpath(treeItem.getPath()):
                if isPythonMime(mime) and info:
                    # Update icon
                    treeItem.setIcon(icon)
                    if info.docstring is None:
                        treeItem.toolTip = ""
                    else:
                        treeItem.toolTip = info.docstring.text
                    treeItem.parsingErrors = not info.isOK

                    self._signalItemUpdated(treeItem)

                    # Update content if populated
                    self.updateFileItem(treeItem, info)
                elif isCDMProjectMime(mime):
                    # Tooltip update only
                    treeItem.toolTip = getProjectFileTooltip(path)
                    self._signalItemUpdated(treeItem)
                elif path.endswith(".cgi"):
                    # It can only happened when python CGI is not a python any
                    # more. So display it as a general file.
                    # The case when a cgi became a python file is covered in
                    # the first branch of this if statement.
                    treeItem.setIcon(icon)
                    treeItem.toolTip = ""
                    self._signalItemUpdated(treeItem)

                    # Remove child items if so
                    while treeItem.childItems:
                        self.__removeTreeItem(treeItem.childItems[0])
                else:
                    treeItem.setIcon(icon)
                    treeItem.toolTip = ""
                    self._signalItemUpdated(treeItem)
    def __markOK( self ):
        " Mark the file as OK "
        self.__isValid = True
        fileName = self.getFilename()
        fileType = detectFileType( fileName )
        if fileType in [ PythonFileType, Python3FileType ]:
            # The tooltip could be the file docstring
            info = GlobalData().briefModinfoCache.get( fileName )
            if info.docstring is not None and Settings().recentTooltips:
                self.setToolTip( 1, info.docstring.text )
            else:
                self.setToolTip( 1, "" )
            if info.isOK:
                self.setIcon( 0,
                              PixmapCache().getIcon( 'filepython.png' ) )
            else:
                self.setIcon( 0,
                              PixmapCache().getIcon( 'filepythonbroken.png' ) )
            self.setToolTip( 0, "" )

        elif fileType == CodimensionProjectFileType:
            # Get the project properties
            try:
                self.setToolTip( 0, "" )
                tooltip = getProjectFileTooltip( fileName )
                if Settings().recentTooltips:
                    self.setToolTip( 1, tooltip )
                else:
                    self.setToolTip( 1, "" )
                self.setText( 0, "" )
            except:
                # cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip( 0, 'Broken project file' )
                self.setToolTip( 1, 'Broken project file' )
            self.setIcon( 0, getFileIcon( fileType ) )
        else:
            # Get the other file type icon
            self.setIcon( 0, getFileIcon( fileType ) )

        self.setToolTip( 2, self.getFilename() )
        return
示例#7
0
    def __walkTreeAndUpdate(self, treeItem, path, fileType, icon, info):
        " Recursively walks the tree items and updates the icon "

        if treeItem.itemType in [DirectoryItemType, SysPathItemType]:
            for i in treeItem.childItems:
                if i.itemType in [DirectoryItemType, SysPathItemType, FileItemType]:
                    self.__walkTreeAndUpdate(i, path, fileType, icon, info)

        if treeItem.itemType == FileItemType:
            if path == os.path.realpath(treeItem.getPath()):
                if fileType in [PythonFileType, Python3FileType]:
                    # Update icon
                    treeItem.setIcon(icon)
                    if info.docstring is None:
                        treeItem.toolTip = ""
                    else:
                        treeItem.toolTip = info.docstring.text
                    treeItem.parsingErrors = not info.isOK

                    self._signalItemUpdated(treeItem)

                    # Update content if populated
                    self.updateFileItem(treeItem, info)
                elif fileType == CodimensionProjectFileType:
                    # Tooltip update only
                    treeItem.toolTip = getProjectFileTooltip(path)
                    self._signalItemUpdated(treeItem)
                elif path.endswith(".cgi"):
                    # It can only happened when python CGI is not a python any
                    # more. So display it a a general file.
                    # The case when a cgi became a python file is covered in
                    # the first branch of this if statement.
                    treeItem.setIcon(icon)
                    treeItem.toolTip = ""
                    self._signalItemUpdated(treeItem)

                    # Remove child items if so
                    while treeItem.childItems:
                        self.__removeTreeItem(treeItem.childItems[0])

        return
示例#8
0
    def __markOK(self):
        " Mark the file as OK "
        self.__isValid = True
        fileName = self.getFilename()
        fileType = detectFileType(fileName)
        if fileType in [PythonFileType, Python3FileType]:
            # The tooltip could be the file docstring
            info = GlobalData().briefModinfoCache.get(fileName)
            if info.docstring is not None and Settings().recentTooltips:
                self.setToolTip(1, info.docstring.text)
            else:
                self.setToolTip(1, "")
            if info.isOK:
                self.setIcon(0, getIcon('filepython.png'))
            else:
                self.setIcon(0, getIcon('filepythonbroken.png'))
            self.setToolTip(0, "")

        elif fileType == CodimensionProjectFileType:
            # Get the project properties
            try:
                self.setToolTip(0, "")
                tooltip = getProjectFileTooltip(fileName)
                if Settings().recentTooltips:
                    self.setToolTip(1, tooltip)
                else:
                    self.setToolTip(1, "")
                self.setText(0, "")
            except:
                # cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip(0, 'Broken project file')
                self.setToolTip(1, 'Broken project file')
            self.setIcon(0, getFileIcon(fileType))
        else:
            # Get the other file type icon
            self.setIcon(0, getFileIcon(fileType))

        self.setToolTip(2, self.getFilename())
        return
示例#9
0
    def __init__(self, parent, path):
        path = str(path)
        TreeViewItem.__init__(self, parent, os.path.basename(path))
        self.itemType = FileItemType
        self.parsingErrors = False  # Used for python files only
        self.isLink = False

        self.fileType, self.icon, _ = getFileProperties(path)
        if self.fileType is None:
            if self.icon is None:
                self.icon = getIcon('filemisc.png')
            return

        if 'broken-symlink' in self.fileType:
            self.isLink = True
            self.toolTip = self.__brokenLinkTooltip(path)
            return

        if os.path.islink(path):
            self.isLink = True
            self.toolTip = self.__linkTooltip(path)
            self.icon = getIcon('filelink.png')
            self.fileType, _, _ = getFileProperties(os.path.realpath(path))
            return

        # Fine corrections for some file types
        if isPythonMime(self.fileType):
            self.populated = False
            self.lazyPopulation = True
            return

        if isCDMProjectMime(self.fileType):
            # Get the project properties
            try:
                self.toolTip = getProjectFileTooltip(path)
            except:
                # cannot get project properties
                self.toolTip = 'Broken project file'
            return
示例#10
0
    def __markOK(self):
        """Mark the file as OK"""
        self.__isValid = True
        fileName = self.getFilename()
        mime, icon, _ = getFileProperties(fileName)
        if isPythonMime(mime):
            # The tooltip could be the file docstring
            info = GlobalData().briefModinfoCache.get(fileName)
            if info.docstring and Settings()['recentTooltips']:
                self.setToolTip(1, info.docstring.text)
            else:
                self.setToolTip(1, "")
            if info.isOK:
                self.setIcon(0, getIcon('filepython.png'))
            else:
                self.setIcon(0, getIcon('filepythonbroken.png'))
            self.setToolTip(0, "")
        elif isCDMProjectMime(mime):
            # Get the project properties
            try:
                self.setToolTip(0, "")
                tooltip = getProjectFileTooltip(fileName)
                if Settings()['recentTooltips']:
                    self.setToolTip(1, tooltip)
                else:
                    self.setToolTip(1, "")
                self.setText(0, "")
            except:
                # cannot get project properties. Mark broken.
                self.__isValid = False
                self.setToolTip(0, 'Broken project file')
                self.setToolTip(1, 'Broken project file')
            self.setIcon(0, icon)
        else:
            # Get the other file type icon
            self.setIcon(0, icon)

        self.setToolTip(2, self.getFilename())