예제 #1
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)

        extendInstance(self, MarginBase)
        MarginBase.__init__(self, parent, "cdm_flakes_margin", 1)
        self.setMouseTracking(True)

        self.__messages = {}
        self.__bgColor = GlobalData().skin['flakesMarginPaper']
        self.__noTooltip = True

        self.currentDebugLine = None
        self.excptionLine = None

        self.__marks = {
            self.CURRENT_MARK: [getPixmap('dbgcurrentmarker.png'), 0],
            self.EXC_MARK: [getPixmap('dbgexcptmarker.png'), 0],
            self.FLAKES_MARK: [getPixmap('pyflakesmsgmarker.png'), 0]}

        for item in self.__marks:
            self.__marks[item][1] = self.__marks[item][0].height()
            if self.__marks[item][0].height() != self.__marks[item][0].width():
                logging.error('flakes margin pixmap needs to be square')

        self.myUUID = None
        if hasattr(self._qpart._parent, 'getUUID'):
            self.myUUID = self._qpart._parent.getUUID()

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        editorsManager.sigFileTypeChanged.connect(self.__onFileTypeChanged)
        self._qpart.blockCountChanged.connect(self.update)
예제 #2
0
    def setFlakesResults(label, results, editor):
        """Displays the appropriate icon:

        - pyflakes has no complains
        - pyflakes found errors
        """
        if editor is not None:
            editor.clearPyflakesMessages()

        if results:
            # There are complains
            complains = "Buffer checked: there are pyflakes complains<br/>"
            lineNumbers = list(results.keys())
            lineNumbers.sort()
            for lineNo in lineNumbers:
                for item in results[lineNo]:
                    complains += '<br/>'
                    if lineNo == -1:
                        # Special case: compilation error
                        complains += escape(item)
                    else:
                        complains += "Line " + str(lineNo) + \
                                     ": " + escape(item)
            label.setToolTip(complains.replace(' ', '&nbsp;'))
            label.setPixmap(getPixmap('flakeserrors.png'))
            if editor is not None:
                editor.setPyflakesMessages(results)
        else:
            # There are no complains
            label.setToolTip("File checked: no pyflakes complains")
            label.setPixmap(getPixmap('flakesok.png'))
예제 #3
0
    def updateInfoIcon( self, state ):
        " Updates the information icon "
        if state == self.__currentIconState:
            return

        if state == self.STATE_OK_UTD:
            self.__infoIcon.setPixmap( getPixmap( 'cfokutd.png' ) )
            self.__infoIcon.setToolTip( "Control flow is up to date" )
            self.__currentIconState = self.STATE_OK_UTD
        elif state == self.STATE_OK_CHN:
            self.__infoIcon.setPixmap( getPixmap( 'cfokchn.png' ) )
            self.__infoIcon.setToolTip( "Control flow is not up to date; will be updated on idle" )
            self.__currentIconState = self.STATE_OK_CHN
        elif state == self.STATE_BROKEN_UTD:
            self.__infoIcon.setPixmap( getPixmap( 'cfbrokenutd.png' ) )
            self.__infoIcon.setToolTip( "Control flow might be invalid due to invalid python code" )
            self.__currentIconState = self.STATE_BROKEN_UTD
        elif state == self.STATE_BROKEN_CHN:
            self.__infoIcon.setPixmap( getPixmap( 'cfbrokenchn.png' ) )
            self.__infoIcon.setToolTip( "Control flow might be invalid; will be updated on idle" )
            self.__currentIconState = self.STATE_BROKEN_CHN
        else:
            # STATE_UNKNOWN
            self.__infoIcon.setPixmap( getPixmap( 'cfunknown.png' ) )
            self.__infoIcon.setToolTip( "Control flow state is unknown" )
            self.__currentIconState = self.STATE_UNKNOWN
        return
예제 #4
0
    def updateInfoIcon(self, state):
        """Updates the information icon"""
        if state == self.__currentIconState:
            return

        if state == self.STATE_OK_UTD:
            self.__infoIcon.setPixmap(getPixmap('cfokutd.png'))
            self.__infoIcon.setToolTip("Control flow is up to date")
            self.__currentIconState = self.STATE_OK_UTD
        elif state == self.STATE_OK_CHN:
            self.__infoIcon.setPixmap(getPixmap('cfokchn.png'))
            self.__infoIcon.setToolTip("Control flow is not up to date; "
                                       "will be updated on idle")
            self.__currentIconState = self.STATE_OK_CHN
        elif state == self.STATE_BROKEN_UTD:
            self.__infoIcon.setPixmap(getPixmap('cfbrokenutd.png'))
            self.__infoIcon.setToolTip("Control flow might be invalid "
                                       "due to invalid python code")
            self.__currentIconState = self.STATE_BROKEN_UTD
        elif state == self.STATE_BROKEN_CHN:
            self.__infoIcon.setPixmap(getPixmap('cfbrokenchn.png'))
            self.__infoIcon.setToolTip("Control flow might be invalid; "
                                       "will be updated on idle")
            self.__currentIconState = self.STATE_BROKEN_CHN
        else:
            # STATE_UNKNOWN
            self.__infoIcon.setPixmap(getPixmap('cfunknown.png'))
            self.__infoIcon.setToolTip("Control flow state is unknown")
            self.__currentIconState = self.STATE_UNKNOWN
예제 #5
0
    def setAnalysisNotAvailable(label, ccLabel):
        """Displays the appropriate icon that pyflakes is not available"""
        label.setToolTip('Not a python file: pyflakes is sleeping')
        label.setPixmap(getPixmap('flakessleep.png'))

        ccLabel.setToolTip('Not a python file: radon is sleeping')
        ccLabel.setPixmap(getPixmap('flakessleep.png'))
예제 #6
0
    def setAnalysisWaiting(label, ccLabel):
        """Displays the waiting for a time slice to start checking icon"""
        label.setToolTip('File is modified: '
                         'pyflakes is waiting for time slice')
        label.setPixmap(getPixmap('flakesmodified.png'))

        ccLabel.setToolTip('File is modified: '
                           'radon is waiting for time slice')
        ccLabel.setPixmap(getPixmap('flakesmodified.png'))
예제 #7
0
    def setAnalysisResults(label, results, ccLabel, ccResults, editor):
        """Displays the appropriate icon:

        - pyflakes has no complains
        - pyflakes found errors
        """
        if editor is not None:
            editor.clearAnalysisMessages()
            editor.setAnalysisMessages(results, ccResults)

        if results:
            # There are complains
            complains = "Buffer checked: there are pyflakes complains<br/>"
            lineNumbers = list(results.keys())
            lineNumbers.sort()
            for lineNo in lineNumbers:
                for item in results[lineNo]:
                    complains += '<br/>'
                    if lineNo == -1:
                        # Special case: compilation error
                        complains += escape(item)
                    else:
                        complains += "Line " + str(lineNo) + \
                                     ": " + escape(item)
            label.setToolTip(complains.replace(' ', '&nbsp;'))
            label.setPixmap(getPixmap('flakeserrors.png'))
        else:
            # There are no complains
            label.setToolTip('Buffer checked: no pyflakes complains')
            label.setPixmap(getPixmap('flakesok.png'))

        if ccResults:
            complains = 'Buffer cyclomatic complexity:<br/>'
            worstComplexity = 'A'
            for item in ccResults:
                complexity = cc_rank(item.complexity)
                worstComplexity = max(complexity, worstComplexity)

                if complexity != 'A':
                    complains += '<br/>' + complexity + \
                                 '(' + str(item.complexity) + ') ' + \
                                 escape(item.fullname)
                    if item.letter in ('F', 'M'):
                        complains += '()'

            if worstComplexity == 'A':
                ccLabel.setToolTip(
                    'Buffer cyclomatic complexity: no complains')
            else:
                ccLabel.setToolTip(complains.replace(' ', '&nbsp;'))
            ccLabel.setPixmap(getPixmap(COMPLEXITY_PIXMAPS[worstComplexity]))
        else:
            ccLabel.setToolTip('No complexity information available')
            ccLabel.setPixmap(getPixmap('ccmarker.png'))
예제 #8
0
    def paint(self, painter, option, widget):
        """Draws a filled rectangle and then adds a title"""
        # Hide the dotted outline
        itemOption = QStyleOptionGraphicsItem(option)
        if itemOption.state & QStyle.State_Selected != 0:
            itemOption.state = itemOption.state & ~QStyle.State_Selected

        # Draw the rectangle
        pen = painter.pen()
        pen.setJoinStyle(Qt.RoundJoin)
        painter.setPen(pen)
        QGraphicsRectItem.paint(self, painter, itemOption, widget)

        # Draw text over the rectangle
        painter.setFont(self.__font)
        painter.setPen(QPen(QColor(255, 255, 255)))
        painter.drawText(self.__node.posX - self.__node.width / 2.0,
                         self.__node.posY - self.__node.height / 2.0,
                         self.__node.width, self.__node.height, Qt.AlignCenter,
                         self.__node.label.replace('\\n', '\n'))

        if self.__outside:
            pixmap = getPixmap("nonprojectentrydgm.png")
            pixmapPosX = self.__node.posX - self.__node.width / 2.0 + 2
            pixmapPosY = self.__node.posY + self.__node.height / 2.0 - \
                pixmap.height() - 2
            painter.setRenderHint(QPainter.SmoothPixmapTransform)
            painter.drawPixmap(pixmapPosX, pixmapPosY, pixmap)
예제 #9
0
    def __createLayout( self ):
        " Creates the layout "
        self.setFixedHeight( 24 )
        self.__layout = QHBoxLayout( self )
        self.__layout.setMargin( 0 )
        self.__layout.setContentsMargins( 0, 0, 0, 0 )

        # Create info icon
        self.__infoIcon = QLabel()
        self.__infoIcon.setPixmap( getPixmap( 'cfunknown.png' ) )
        self.__layout.addWidget( self.__infoIcon )
        self.__spacer = QWidget()
        self.__spacer.setSizePolicy( QSizePolicy.Fixed, QSizePolicy.Expanding )
        self.__spacer.setMinimumWidth( 0 )
        self.__layout.addWidget( self.__spacer )
#        self.__pathLabel = FitLabel( self )
        self.__pathLabel = QLabel( self )
        self.__pathLabel.setTextFormat( Qt.PlainText )
        self.__pathLabel.setAlignment( Qt.AlignLeft )
        self.__pathLabel.setWordWrap( False )
        self.__pathLabel.setFrameStyle( QFrame.StyledPanel )
        self.__pathLabel.setTextInteractionFlags( Qt.NoTextInteraction )
        self.__pathLabel.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed )
        self.__layout.addWidget( self.__pathLabel )
        return
예제 #10
0
    def __createLayout(self):
        """Creates the layout"""
        self.setFixedHeight(24)
        self.__layout = QHBoxLayout(self)
        self.__layout.setContentsMargins(0, 0, 0, 0)

        # Create info icon
        self.__infoIcon = QLabel(self)
        self.__infoIcon.setPixmap(getPixmap('cfunknown.png'))
        self.__layout.addWidget(self.__infoIcon)

        self.__warningsIcon = QLabel(self)
        self.__warningsIcon.setPixmap(getPixmap('cfwarning.png'))
        self.__layout.addWidget(self.__warningsIcon)

        self.clearWarnings()

        labelStylesheet = 'QLabel {' + getLabelStyle(self.__infoIcon) + '}'

        # Create the path label
        self.__pathLabel = QLabel(self)
        self.__pathLabel.setStyleSheet(labelStylesheet)
        self.__pathLabel.setTextFormat(Qt.PlainText)
        self.__pathLabel.setAlignment(Qt.AlignLeft)
        self.__pathLabel.setWordWrap(False)
        self.__pathLabel.setTextInteractionFlags(Qt.NoTextInteraction)
        self.__pathLabel.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)
        self.__layout.addWidget(self.__pathLabel)

        self.__spacer = QWidget()
        self.__spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.__spacer.setMinimumWidth(0)
        self.__layout.addWidget(self.__spacer)

        # Create the selection label
        self.__selectionLabel = QLabel(self)
        self.__selectionLabel.setStyleSheet(labelStylesheet)
        self.__selectionLabel.setTextFormat(Qt.PlainText)
        self.__selectionLabel.setAlignment(Qt.AlignCenter)
        self.__selectionLabel.setWordWrap(False)
        self.__selectionLabel.setTextInteractionFlags(Qt.NoTextInteraction)
        self.__selectionLabel.setSizePolicy(QSizePolicy.Fixed,
                                            QSizePolicy.Fixed)
        self.__selectionLabel.setMinimumWidth(40)
        self.__layout.addWidget(self.__selectionLabel)
        self.setSelectionLabel(0, None)
예제 #11
0
    def __init__(self, parent, debugger):
        QWidget.__init__(self, parent)

        extendInstance(self, MarginBase)
        MarginBase.__init__(self, parent, "cdm_bpoint_margin", getMarginBits())
        self.setMouseTracking(True)

        self.__debugger = debugger
        self.__breakpoints = {}  # block handle -> Breakpoint instance
        self.__breakableLines = None
        self.__maxBreakpoints = Settings()['maxBreakpoints']
        self.__bgColor = GlobalData().skin['bpointsMarginPaper']

        self.__marks = {
            self.BPOINT_MARK: [getPixmap('dbgbpointmarker.png'), 0],
            self.TMP_BPOINT_MARK: [getPixmap('dbgtmpbpointmarker.png'), 0],
            self.DISABLED_BPOINT_MARK:
            [getPixmap('dbgdisbpointmarker.png'), 0]
        }

        for item in self.__marks:
            self.__marks[item][1] = self.__marks[item][0].height()
            if self.__marks[item][0].height() != self.__marks[item][0].width():
                logging.error('breakpoint margin pixmap needs to be square')

        self.myUUID = None
        if hasattr(self._qpart._parent, 'getUUID'):
            self.myUUID = self._qpart._parent.getUUID()

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        editorsManager.sigFileTypeChanged.connect(self.__onFileTypeChanged)

        self.blockClicked.connect(self.__onBlockClicked)

        self._qpart.blockCountChanged.connect(self.__onBlockCountChanged)

        bpointModel = self.__debugger.getBreakPointModel()
        bpointModel.rowsAboutToBeRemoved.connect(self.__deleteBreakPoints)
        bpointModel.sigDataAboutToBeChanged.connect(
            self.__breakPointDataAboutToBeChanged)
        bpointModel.dataChanged.connect(self.__changeBreakPoints)
        bpointModel.rowsInserted.connect(self.__addBreakPoints)
예제 #12
0
    def __createLayout(self):
        """Creates the layout"""
        self.__layout = QHBoxLayout(self)
        self.__layout.setContentsMargins(0, 0, 0, 0)

        # Create info icon
        self.__infoIcon = QLabel(self)
        self.__infoIcon.setPixmap(getPixmap('cfunknown.png'))
        self.__layout.addWidget(self.__infoIcon)

        self.__warningsIcon = QLabel(self)
        self.__warningsIcon.setPixmap(getPixmap('cfwarning.png'))
        self.__layout.addWidget(self.__warningsIcon)

        self.clearWarnings()

        # Create the path label
        self.__pathLabel = HeaderFitLabel(self)
        self.__pathLabel.setTextFormat(Qt.PlainText)
        self.__pathLabel.setAlignment(Qt.AlignLeft)
        self.__pathLabel.setWordWrap(False)
        self.__pathLabel.setTextInteractionFlags(Qt.NoTextInteraction)
        self.__pathLabel.setSizePolicy(QSizePolicy.Expanding,
                                       QSizePolicy.Fixed)
        self.__pathLabel.setMinimumWidth(40)
        self.__layout.addWidget(self.__pathLabel)

        self.__spacer = ToolBarExpandingSpacer(self)
        self.__spacer.setMinimumWidth(0)
        self.__layout.addWidget(self.__spacer)

        # Create the selection label
        self.__selectionLabel = HeaderLabel('', None, self)
        self.__selectionLabel.setTextFormat(Qt.PlainText)
        self.__selectionLabel.setAlignment(Qt.AlignCenter)
        self.__selectionLabel.setWordWrap(False)
        self.__selectionLabel.setTextInteractionFlags(Qt.NoTextInteraction)
        self.__selectionLabel.setSizePolicy(QSizePolicy.Fixed,
                                            QSizePolicy.Fixed)
        self.__selectionLabel.setMinimumWidth(40)
        self.__layout.addWidget(self.__selectionLabel)
        self.setSelectionLabel(0, None)
예제 #13
0
    def __init__(self):
        self.labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignRight
                                           | Qt.AlignAbsolute)

        # The window flags are needed for some X Servers. E.g. Xwin-32
        # on windows draws a normal window outline if the flags are not here
        QSplashScreen.__init__(
            self, None, getPixmap('splash.png'), Qt.SplashScreen
            | Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint)

        self.show()
        QApplication.flush()
예제 #14
0
    def __createLayout(self):
        """Creates the layout"""
        self.setFixedHeight(24)
        self.__layout = QHBoxLayout(self)
        self.__layout.setContentsMargins(0, 0, 0, 0)

        # Create info icon
        self.__infoIcon = QLabel()
        self.__infoIcon.setPixmap(getPixmap('cfunknown.png'))
        self.__layout.addWidget(self.__infoIcon)

        self.__warningsIcon = QLabel()
        self.__warningsIcon.setPixmap(getPixmap('cfwarning.png'))
        self.__layout.addWidget(self.__warningsIcon)

        self.clearWarnings()

        self.__spacer = QWidget()
        self.__spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.__spacer.setMinimumWidth(0)
        self.__layout.addWidget(self.__spacer)
예제 #15
0
 def __updateInfoIcon(self, state):
     """Updates the information icon"""
     if state != self.__currentIconState:
         if state == self.STATE_OK_UTD:
             self.__infoIcon.setPixmap(getPixmap('nbokutd.png'))
             self.__infoIcon.setToolTip("Context is up to date")
             self.__currentIconState = self.STATE_OK_UTD
         elif state == self.STATE_OK_CHN:
             self.__infoIcon.setPixmap(getPixmap('nbokchn.png'))
             self.__infoIcon.setToolTip("Context is not up to date; "
                                        "will be updated on idle")
             self.__currentIconState = self.STATE_OK_CHN
         elif state == self.STATE_BROKEN_UTD:
             self.__infoIcon.setPixmap(getPixmap('nbbrokenutd.png'))
             self.__infoIcon.setToolTip("Context might be invalid "
                                        "due to invalid python code")
             self.__currentIconState = self.STATE_BROKEN_UTD
         else:
             # STATE_BROKEN_CHN
             self.__infoIcon.setPixmap(getPixmap('nbbrokenchn.png'))
             self.__infoIcon.setToolTip("Context might be invalid; "
                                        "will be updated on idle")
             self.__currentIconState = self.STATE_BROKEN_CHN
예제 #16
0
    def __parseConfigTuple(self, pluginIndicator):
        """Checks what plugin provided"""
        if len(pluginIndicator) != 5:
            raise Exception("Unexpected format of an indicator "
                            "description. Expected 5 values.")
        # ID field
        self.identifier = int(pluginIndicator[0])

        # Pixmap/text field
        try:
            if isinstance(pluginIndicator[1], QPixmap):
                self.pixmap = QPixmap(pluginIndicator[1])
            elif os.path.exists(pluginIndicator[1]):
                self.pixmap = QPixmap(pluginIndicator[1])
            elif getPixmapLocation(pluginIndicator[1]) is not None:
                self.pixmap = getPixmap(pluginIndicator[1])
            else:
                self.__setText(pluginIndicator[1])
        except:
            self.__setBrokenIndicator("Failed to get plugin indicator "
                                      "pixmap. Indicator id: " +
                                      str(self.identifier))
            return

        # Foreground color
        if pluginIndicator[2] is None:
            self.foregroundColor = None
        else:
            if type(pluginIndicator[2]) == str:
                self.foregroundColor = buildColor(pluginIndicator[2])
            else:
                self.foregroundColor = QColor(pluginIndicator[2])

        # Background color
        if pluginIndicator[3] is None:
            self.backgroundColor = None
        else:
            if type(pluginIndicator[3]) == str:
                self.backgroundColor = buildColor(pluginIndicator[3])
            else:
                self.backgroundColor = QColor(pluginIndicator[3])

        # Default tooltip
        if pluginIndicator[4] is None:
            self.defaultTooltip = ""
        else:
            self.defaultTooltip = str(pluginIndicator[4]).strip()
예제 #17
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)

        extendInstance(self, MarginBase)
        MarginBase.__init__(self, parent, "cdm_flakes_margin", 1)
        self.setMouseTracking(True)

        self.__messages = {}
        self.__ccMessages = {}
        self.__bgColor = GlobalData().skin['flakesMarginPaper']
        self.__noTooltip = True

        self.currentDebugLine = None
        self.excptionLine = None

        if not MARKS:
            MARKS[self.CURRENT_MARK] = getPixmap('dbgcurrentmarker.png')
            MARKS[self.EXC_MARK] = getPixmap('dbgexcptmarker.png')
            MARKS[self.FLAKES_MARK] = getPixmap('pyflakesmsgmarker.png')
            MARKS[self.COMPLEXITY_A_MARK] = getPixmap('complexity-a.png')
            MARKS[self.COMPLEXITY_B_MARK] = getPixmap('complexity-b.png')
            MARKS[self.COMPLEXITY_C_MARK] = getPixmap('complexity-c.png')
            MARKS[self.COMPLEXITY_D_MARK] = getPixmap('complexity-d.png')
            MARKS[self.COMPLEXITY_E_MARK] = getPixmap('complexity-e.png')
            MARKS[self.COMPLEXITY_F_MARK] = getPixmap('complexity-f.png')

            for item in MARKS:
                if MARKS[item].height() != MARKS[item].width():
                    logging.error('analysis margin pixmap needs to be square')

        self.myUUID = None
        if hasattr(self._qpart._parent, 'getUUID'):
            self.myUUID = self._qpart._parent.getUUID()

        mainWindow = GlobalData().mainWindow
        editorsManager = mainWindow.editorsManagerWidget.editorsManager
        editorsManager.sigFileTypeChanged.connect(self.__onFileTypeChanged)
        self._qpart.blockCountChanged.connect(self.update)
예제 #18
0
    def loadResource(self, resourceType, resourceURL):
        """Overloaded; by default the remote pixmaps are not loaded"""
        if resourceType == QTextDocument.ImageResource:
            url = resourceURL.toString()
            currentFileName = self._parentWidget.getFileName()
            if currentFileName:
                currentDir = os.path.dirname(currentFileName) + os.path.sep
                if url.startswith(currentDir):
                    url = url.replace(currentDir, '', 1)
            lowerUrl = url.lower()

            if url.startswith('plantuml:'):
                fName = url[9:]
                if os.path.exists(fName):
                    return QPixmap(fName)
                # I cannot return my picture. If I do that then the resource
                # will not be reloaded when the generated diagram is ready
                return None

            if url.startswith('cdm-image:'):
                try:
                    return getPixmap(url[10:])
                except Exception as exc:
                    logging.error('Unknown Codimension cache image: ' +
                                  url[10:])
                return None

            if lowerUrl.startswith('http:/') or lowerUrl.startswith('https:/'):
                if not lowerUrl.startswith('http://') and \
                   not lowerUrl.startswith('https://'):
                    url = url.replace(':/', '://', 1)
                fName = Settings().webResourceCache.getResource(
                    url, self._parentWidget.getUUID())
                if fName is not None:
                    try:
                        return QPixmap(fName)
                    except Exception as exc:
                        logging.error('Cannot use the image from ' + fName +
                                      ': ' + str(exc))
                return None
        return TextViewer.loadResource(self, resourceType, resourceURL)
예제 #19
0
    def __createLayout(self):
        """Creates the dialog layout"""
        self.resize(640, 480)
        self.setSizeGripEnabled(True)

        vboxLayout = QVBoxLayout(self)
        hboxLayout = QHBoxLayout()
        iconLabel = QLabel()
        iconLabel.setPixmap(getPixmap("logo-48x48.png"))
        iconLabel.setScaledContents(False)
        hboxLayout.addWidget(iconLabel)
        versionLabel = QLabel(
            "<b>Codimension IDE version " + str(GlobalData().version) + "<br>"
            "CML version " + str(CMLVersion.VERSION) +
            "</b><p>Copyright (c) Sergey Satskiy 2010-2019</p>")
        versionLabel.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        versionLabel.setFixedHeight(versionLabel.minimumSizeHint().height())
        versionLabel.setAlignment(Qt.AlignCenter)
        hboxLayout.addWidget(versionLabel)
        vboxLayout.addLayout(hboxLayout)

        tabWidget = QTabWidget(self)
        tabWidget.setFocusPolicy(Qt.NoFocus)

        description = self.__createDescription()
        tabWidget.addTab(description, "About")
        versioning = self.__createVersioning()
        tabWidget.addTab(versioning, "Versions and licenses")
        authors = self.__createAuthors()
        tabWidget.addTab(authors, "Contributors")
        vboxLayout.addWidget(tabWidget)

        # Button at the bottom
        buttonBox = QDialogButtonBox(self)
        buttonBox.setOrientation(Qt.Horizontal)
        buttonBox.setStandardButtons(QDialogButtonBox.Ok)
        buttonBox.accepted.connect(self.close)
        buttonBox.rejected.connect(self.close)
        vboxLayout.addWidget(buttonBox)
예제 #20
0
 def setFlakesNotAvailable(label):
     """Displays the appropriate icon that pyflakes is not available"""
     label.setToolTip("Not a python file: pyflakes is sleeping")
     label.setPixmap(getPixmap('flakessleep.png'))
예제 #21
0
 def setFlakesWaiting(label):
     """Displays the waiting for a time slice to start checking icon"""
     label.setToolTip("File is modified: "
                      "pyflakes is waiting for time slice")
     label.setPixmap(getPixmap('flakesmodified.png'))
예제 #22
0
 def __init__(self, parent=None):
     self.icon = QLabel()
     self.icon.setPixmap(getPixmap('nbsep.png'))
     self.combo = NavBarComboBox(parent)
예제 #23
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(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, icon, _ = getFileProperties(fileName)
            fileItem.setIcon(0, icon)
            if isPythonMime(fileType):
                info = GlobalData().briefModinfoCache.get(fileName)
                fileItem.setToolTip(
                    0, info.docstring.text if info.docstring else '')
            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()
예제 #24
0
    def __buildGraphicsScene(self, graph):
        """Builds the QT graphics scene"""
        self.scene.clear()
        self.scene.setSceneRect(0, 0, graph.width, graph.height)

        for edge in graph.edges:
            # self.scene.addItem( GraphicsEdge( edge, self ) )
            dataModelObj = self.dataModel.findConnection(edge.tail, edge.head)
            if dataModelObj is None:
                raise Exception("Cannot find the following connection: " +
                                edge.tail + " -> " + edge.head)

            if dataModelObj.kind == DgmConnection.ModuleDoc:
                modObj = self.dataModel.findModule(dataModelObj.source)
                if modObj is None:
                    raise Exception("Cannot find module object: " +
                                    dataModelObj.source)
                self.scene.addItem(ImportsDgmDocConn(edge, modObj))
                continue
            if dataModelObj.kind == DgmConnection.ModuleDependency:
                # Find the source module object first
                modObj = self.dataModel.findModule(dataModelObj.source)
                if modObj is None:
                    raise Exception("Cannot find module object: " +
                                    dataModelObj.source)
                self.scene.addItem(
                    ImportsDgmDependConn(edge, modObj, dataModelObj))

                if edge.label != "":
                    self.scene.addItem(ImportsDgmEdgeLabel(edge, modObj))
                continue

            raise Exception("Unexpected type of connection: " +
                            str(dataModelObj.kind))

        for node in graph.nodes:
            dataModelObj = self.dataModel.findModule(node.name)
            if dataModelObj is None:
                dataModelObj = self.dataModel.findDocstring(node.name)
            if dataModelObj is None:
                raise Exception("Cannot find object " + node.name)

            if isinstance(dataModelObj, DgmDocstring):
                self.scene.addItem(
                    ImportsDgmDocNote(node, dataModelObj.refFile,
                                      dataModelObj.docstring))
                continue

            # OK, this is a module rectangle. Switch by type of the module.
            if dataModelObj.kind == DgmModule.ModuleOfInterest:
                self.scene.addItem(
                    ImportsDgmModuleOfInterest(node, dataModelObj.refFile,
                                               dataModelObj,
                                               self.physicalDpiX()))
            elif dataModelObj.kind == DgmModule.OtherProjectModule:
                self.scene.addItem(
                    ImportsDgmOtherPrjModule(node, dataModelObj.refFile,
                                             dataModelObj,
                                             self.physicalDpiX()))
            elif dataModelObj.kind == DgmModule.SystemWideModule:
                self.scene.addItem(
                    ImportsDgmSystemWideModule(node, dataModelObj.refFile,
                                               dataModelObj.docstring))
            elif dataModelObj.kind == DgmModule.BuiltInModule:
                self.scene.addItem(ImportsDgmBuiltInModule(node))
            elif dataModelObj.kind == DgmModule.UnknownModule:
                self.scene.addItem(ImportsDgmUnknownModule(node))
            else:
                raise Exception("Unexpected type of module: " +
                                str(dataModelObj.kind))

            tooltip = dataModelObj.getTooltip()
            if tooltip:
                pixmap = getPixmap('diagramdoc.png')
                docItem = QGraphicsPixmapItem(pixmap)
                docItem.setToolTip(tooltip)
                posX = node.posX + node.width / 2.0 - pixmap.width() / 2.0
                posY = node.posY - node.height / 2.0 - pixmap.height() / 2.0
                docItem.setPos(posX, posY)
                self.scene.addItem(docItem)