示例#1
0
    def onFileUpdated(self, fileName, uuid):
        " Triggered when the file is updated "
        fileType = detectFileType(fileName)
        if fileType in [PythonFileType, Python3FileType]:
            path = os.path.realpath(fileName)
            info = GlobalData().briefModinfoCache.get(path)
            if info.isOK:
                icon = PixmapCache().getIcon('filepython.png')
            else:
                icon = PixmapCache().getIcon('filepythonbroken.png')

            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, icon, info)
        elif fileType == CodimensionProjectFileType:
            path = os.path.realpath(fileName)

            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, None, None)
        elif fileName.endswith(".cgi"):
            path = os.path.realpath(fileName)

            icon = getFileIcon(fileType)
            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, icon, None)

        return
示例#2
0
    def onFileUpdated(self, fileName, uuid):
        " Triggered when the file is updated "
        fileType = detectFileType(fileName)
        if fileType in [PythonFileType, Python3FileType]:
            path = os.path.realpath(fileName)
            info = GlobalData().briefModinfoCache.get(path)
            if info.isOK:
                icon = PixmapCache().getIcon("filepython.png")
            else:
                icon = PixmapCache().getIcon("filepythonbroken.png")

            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, icon, info)
        elif fileType == CodimensionProjectFileType:
            path = os.path.realpath(fileName)

            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, None, None)
        elif fileName.endswith(".cgi"):
            path = os.path.realpath(fileName)

            icon = getFileIcon(fileType)
            # For all root items
            for treeItem in self.model().sourceModel().rootItem.childItems:
                self.__walkTreeAndUpdate(treeItem, path, fileType, icon, None)

        return
示例#3
0
    def showReport(self, regexp, results):
        " Shows the find in files results "
        self.__clear()
        self.__noneLabel.hide()

        self.__reportRegexp = regexp
        self.__reportResults = results

        # Add the complete information
        totalMatched = 0
        for item in results:
            matched = len(item.matches)
            totalMatched += matched
            if matched == 1:
                matchText = " (1 match)"
            else:
                matchText = " (" + str(matched) + " matches)"
            columns = [item.fileName, matchText]
            fileItem = MatchTableFileItem(columns, item.bufferUUID)
            fileItem.setIcon(0, getFileIcon(detectFileType(item.fileName)))
            if item.tooltip != "":
                fileItem.setToolTip(0, item.tooltip)
            self.__resultsTree.addTopLevelItem(fileItem)

            # Matches
            for match in item.matches:
                columns = [str(match.line), match.text]
                matchItem = MatchTableItem(columns, match.tooltip)
                fileItem.addChild(matchItem)
            fileItem.setExpanded(True)

        # Update the header with the total number of matches
        headerLabels = [
            "File name / line (total files: " + str(len(results)) + ")",
            "Text (total matches: " + str(totalMatched) + ")"
        ]
        self.__resultsTree.setHeaderLabels(headerLabels)

        # Resizing the table
        self.__resultsTree.header().resizeSections(
            QHeaderView.ResizeToContents)

        # Show the complete information
        self.__resultsTree.show()
        self.__resultsTree.buildCache()

        self.__reportShown = True
        self.__updateButtonsStatus()

        # Connect the buffer change signal if not connected yet
        if not self.__bufferChangeconnected:
            self.__bufferChangeconnected = True
            mainWindow = GlobalData().mainWindow
            editorsManager = mainWindow.editorsManagerWidget.editorsManager
            editorsManager.bufferModified.connect(
                self.__resultsTree.onBufferModified)
        return
    def showReport(self, regexp, results):
        " Shows the find in files results "
        self.__clear()
        self.__noneLabel.hide()

        self.__reportRegexp = regexp
        self.__reportResults = results

        # Add the complete information
        totalMatched = 0
        for item in results:
            matched = len(item.matches)
            totalMatched += matched
            if matched == 1:
                matchText = " (1 match)"
            else:
                matchText = " (" + str(matched) + " matches)"
            columns = [item.fileName, matchText]
            fileItem = MatchTableFileItem(columns, item.bufferUUID)
            fileItem.setIcon(0, getFileIcon(detectFileType(item.fileName)))
            if item.tooltip != "":
                fileItem.setToolTip(0, item.tooltip)
            self.__resultsTree.addTopLevelItem(fileItem)

            # Matches
            for match in item.matches:
                columns = [str(match.line), match.text]
                matchItem = MatchTableItem(columns, match.tooltip)
                fileItem.addChild(matchItem)
            fileItem.setExpanded(True)

        # Update the header with the total number of matches
        headerLabels = [
            "File name / line (total files: " + str(len(results)) + ")",
            "Text (total matches: " + str(totalMatched) + ")",
        ]
        self.__resultsTree.setHeaderLabels(headerLabels)

        # Resizing the table
        self.__resultsTree.header().resizeSections(QHeaderView.ResizeToContents)

        # Show the complete information
        self.__resultsTree.show()
        self.__resultsTree.buildCache()

        self.__reportShown = True
        self.__updateButtonsStatus()

        # Connect the buffer change signal if not connected yet
        if not self.__bufferChangeconnected:
            self.__bufferChangeconnected = True
            mainWindow = GlobalData().mainWindow
            editorsManager = mainWindow.editorsManagerWidget.editorsManager
            editorsManager.bufferModified.connect(self.__resultsTree.onBufferModified)
        return
    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
示例#6
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
示例#7
0
    def updateLinkStatus( self, path ):
        " Called to update the status to/from broken link "
        if not self.isLink:
            return

        self.fileType = detectFileType( path )
        self.icon = getFileIcon( self.fileType )
        if self.fileType == BrokenSymlinkFileType:
            self.toolTip = self.__brokenLinkTooltip( path )
            return

        self.toolTip = self.__linkTooltip( path )
        self.icon = PixmapCache().getIcon( 'filelink.png' )
        self.fileType = detectFileType( os.path.realpath( path ) )
        return
示例#8
0
    def updateLinkStatus(self, path):
        " Called to update the status to/from broken link "
        if not self.isLink:
            return

        self.fileType = detectFileType(path)
        self.icon = getFileIcon(self.fileType)
        if self.fileType == BrokenSymlinkFileType:
            self.toolTip = self.__brokenLinkTooltip(path)
            return

        self.toolTip = self.__linkTooltip(path)
        self.icon = PixmapCache().getIcon('filelink.png')
        self.fileType = detectFileType(os.path.realpath(path))
        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 = 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
示例#10
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
示例#11
0
    def __populateFromOpened(self):
        " Populates the name dialog from the opened files "

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        showTooltips = Settings().findFileTooltips
        for record in editorsManager.getTextEditors():
            # uuid = record[ 0 ]
            fname = record[1]
            widget = record[2]
            fileType = detectFileType(fname)
            tooltip = ""
            if showTooltips and fileType in [PythonFileType, Python3FileType]:
                content = widget.getEditor().text()
                info = getBriefModuleInfoFromMemory(content)
                if info.docstring is not None:
                    tooltip = info.docstring.text
            newItem = FileItem(self.rootItem, getFileIcon(fileType), fname,
                               tooltip)
            self.rootItem.appendChild(newItem)
            self.count += 1
        return
示例#12
0
    def __populateFromOpened( self ):
        " Populates the name dialog from the opened files "

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        showTooltips = Settings().findFileTooltips
        for record in editorsManager.getTextEditors():
            # uuid = record[ 0 ]
            fname = record[ 1 ]
            widget = record[ 2 ]
            fileType = detectFileType( fname )
            tooltip = ""
            if showTooltips and fileType in [ PythonFileType, Python3FileType ]:
                content = widget.getEditor().text()
                info = getBriefModuleInfoFromMemory( content )
                if info.docstring is not None:
                    tooltip = info.docstring.text
            newItem = FileItem( self.rootItem, getFileIcon( fileType ),
                                fname, tooltip )
            self.rootItem.appendChild( newItem )
            self.count += 1
        return
示例#13
0
    def __populateFromProject(self):
        " Populates find name dialog from the project files "

        mainWindow = GlobalData().mainWindow
        showTooltips = Settings().findFileTooltips
        for fname in GlobalData().project.filesList:
            if fname.endswith(os.path.sep):
                continue
            fileType = detectFileType(fname)
            tooltip = ""
            if showTooltips and fileType in [PythonFileType, Python3FileType]:
                widget = mainWindow.getWidgetForFileName(fname)
                if widget is None:
                    info = GlobalData().briefModinfoCache.get(fname)
                else:
                    content = widget.getEditor().text()
                    info = getBriefModuleInfoFromMemory(content)
                if info.docstring is not None:
                    tooltip = info.docstring.text
            newItem = FileItem(self.rootItem, getFileIcon(fileType), fname,
                               tooltip)
            self.rootItem.appendChild(newItem)
            self.count += 1
        return
示例#14
0
    def __populateFromProject( self ):
        " Populates find name dialog from the project files "

        mainWindow = GlobalData().mainWindow
        showTooltips = Settings().findFileTooltips
        for fname in GlobalData().project.filesList:
            if fname.endswith( os.path.sep ):
                continue
            fileType = detectFileType( fname )
            tooltip = ""
            if showTooltips and fileType in [ PythonFileType, Python3FileType ]:
                widget = mainWindow.getWidgetForFileName( fname )
                if widget is None:
                    info = GlobalData().briefModinfoCache.get( fname )
                else:
                    content = widget.getEditor().text()
                    info = getBriefModuleInfoFromMemory( content )
                if info.docstring is not None:
                    tooltip = info.docstring.text
            newItem = FileItem( self.rootItem, getFileIcon( fileType ),
                                fname, tooltip )
            self.rootItem.appendChild( newItem )
            self.count += 1
        return
示例#15
0
    def __createLayout(self, action, title, files):
        """ Creates the dialog layout """

        self.resize(400, 300)
        self.setSizeGripEnabled(True)

        # Top level layout
        layout = QVBoxLayout(self)

        # Pixmap and the message
        topLayout = QHBoxLayout()
        pixmap = QLabel()
        pixmap.setPixmap(PixmapCache().getPixmap('warning.png'))
        topLayout.addWidget(pixmap)
        hSpacer = QWidget()
        hSpacer.setFixedSize(15, 15)
        topLayout.addWidget(hSpacer)
        message = QLabel( "All the project files must be " \
                          "saved before start debugging" )
        message.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        message.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        message.setWordWrap(True)
        topLayout.addWidget(message)
        layout.addLayout(topLayout)

        vSpacer = QWidget()
        vSpacer.setFixedSize(15, 15)
        layout.addWidget(vSpacer)

        layout.addWidget(QLabel(title + ":"))
        filesList = QTreeWidget()
        filesList.setRootIsDecorated(False)
        filesList.setAlternatingRowColors(True)
        filesList.setUniformRowHeights(True)
        filesList.setItemsExpandable(False)
        filesList.setItemDelegate(NoOutlineHeightDelegate(4))
        filesList.setSelectionMode(QAbstractItemView.NoSelection)
        filesList.setHeaderHidden(True)
        for item in files:
            fileName = item[0]
            fileItem = QTreeWidgetItem([fileName])
            fileType = detectFileType(fileName)
            fileItem.setIcon(0, getFileIcon(fileType))
            if fileType in [PythonFileType, Python3FileType]:
                infoSrc = GlobalData().briefModinfoCache
                info = infoSrc.get(fileName)
                if info.docstring is not None:
                    fileItem.setToolTip(0, info.docstring.text)
                else:
                    fileItem.setToolTip(0, "")
            filesList.addTopLevelItem(fileItem)
        layout.addWidget(filesList)

        # Buttons at the bottom
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel)
        continueButton = buttonBox.addButton(action,
                                             QDialogButtonBox.ActionRole)
        continueButton.setDefault(True)
        layout.addWidget(buttonBox)

        continueButton.clicked.connect(self.accept)
        buttonBox.rejected.connect(self.close)
        continueButton.setFocus()
        return
示例#16
-1
    def __createLayout( self, action, title, files ):
        """ Creates the dialog layout """

        self.resize( 400, 300 )
        self.setSizeGripEnabled( True )

        # Top level layout
        layout = QVBoxLayout( self )


        # Pixmap and the message
        topLayout = QHBoxLayout()
        pixmap = QLabel()
        pixmap.setPixmap( PixmapCache().getPixmap( 'warning.png' ) )
        topLayout.addWidget( pixmap )
        hSpacer = QWidget()
        hSpacer.setFixedSize( 15, 15 )
        topLayout.addWidget( hSpacer )
        message = QLabel( "All the project files must be " \
                          "saved before start debugging" )
        message.setAlignment( Qt.AlignHCenter | Qt.AlignVCenter )
        message.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Expanding )
        message.setWordWrap( True )
        topLayout.addWidget( message )
        layout.addLayout( topLayout )

        vSpacer = QWidget()
        vSpacer.setFixedSize( 15, 15 )
        layout.addWidget( vSpacer )

        layout.addWidget( QLabel( title + ":" ) )
        filesList = QTreeWidget()
        filesList.setRootIsDecorated( False )
        filesList.setAlternatingRowColors( True )
        filesList.setUniformRowHeights( True )
        filesList.setItemsExpandable( False )
        filesList.setItemDelegate( NoOutlineHeightDelegate( 4 ) )
        filesList.setSelectionMode( QAbstractItemView.NoSelection )
        filesList.setHeaderHidden( True )
        for item in files:
            fileName = item[ 0 ]
            fileItem = QTreeWidgetItem( [ fileName ] )
            fileType = detectFileType( fileName )
            fileItem.setIcon( 0, getFileIcon( fileType ) )
            if fileType in [ PythonFileType, Python3FileType ]:
                infoSrc = GlobalData().briefModinfoCache
                info = infoSrc.get( fileName )
                if info.docstring is not None:
                    fileItem.setToolTip( 0, info.docstring.text )
                else:
                    fileItem.setToolTip( 0, "" )
            filesList.addTopLevelItem( fileItem )
        layout.addWidget( filesList )

        # Buttons at the bottom
        buttonBox = QDialogButtonBox()
        buttonBox.setOrientation( Qt.Horizontal )
        buttonBox.setStandardButtons( QDialogButtonBox.Cancel )
        continueButton = buttonBox.addButton( action,
                                              QDialogButtonBox.ActionRole )
        continueButton.setDefault( True )
        layout.addWidget( buttonBox )

        continueButton.clicked.connect( self.accept )
        buttonBox.rejected.connect( self.close )
        continueButton.setFocus()
        return