Exemple #1
0
    def __init__(self, statusList, parent=None):
        QDialog.__init__(self, parent)

        # Split statuses
        paths = []
        ignoredPaths = []
        for status in statusList:
            if status[1] == IND_IGNORED:
                ignoredPaths.append(status)
            else:
                paths.append(status)

        self.__createLayout(paths, ignoredPaths)
        self.setWindowTitle("SVN status")

        # Fill the lists
        for item in paths:
            message = ""
            if item[2]:
                message = item[2]
            newItem = QTreeWidgetItem(["", item[0],
                                       STATUS[item[1]], message])
            pixmap = getIndicatorPixmap(item[1])
            if pixmap:
                newItem.setIcon(0, QIcon(pixmap))
            newItem.setToolTip(1, item[0])
            newItem.setToolTip(2, STATUS[item[1]])
            if message:
                newItem.setToolTip(3, message)
            self.__pathView.addTopLevelItem(newItem)
        self.__pathView.header().resizeSections(QHeaderView.ResizeToContents)
        self.__pathView.header().resizeSection(0, 20)
        self.__pathView.header().setResizeMode(QHeaderView.Fixed)

        for item in ignoredPaths:
            newItem = QTreeWidgetItem([item[0], STATUS[item[1]]])
            newItem.setToolTip(0, item[0])
            newItem.setToolTip(1, STATUS[item[1]])
            self.__ignoredPathView.addTopLevelItem(newItem)
        self.__ignoredPathView.header().resizeSections(QHeaderView.ResizeToContents)
Exemple #2
0
    def addCallTrace(self, isCall, fromFile, fromLine, fromFunction, toFile,
                     toLine, toFunction):
        """Adds a record to the list"""
        tooltip = 'Return\n'
        icon = self.__retIcon
        if isCall:
            tooltip = 'Call\n'
            icon = self.__callIcon

        if self.projectLoaded:
            project = GlobalData().project
            fromFile = project.getRelativePath(fromFile)
            toFile = project.getRelativePath(toFile)

        parentItem = self
        if self.__callStack:
            parentItem = self.__callStack[-1]

        fromItem = self.__entryFormat.format(fromFile, fromLine, fromFunction)
        toItem = self.__entryFormat.format(toFile, toLine, toFunction)
        item = QTreeWidgetItem(parentItem, ['', fromItem, toItem])
        item.setIcon(0, icon)
        item.setData(0, Qt.UserRole, isCall)
        item.setExpanded(True)

        tooltip += 'From: ' + fromItem + '\nTo: ' + toItem
        item.setToolTip(1, tooltip)
        item.setToolTip(2, tooltip)

        if isCall:
            self.__callStack.append(item)
        else:
            if self.__callStack:
                self.__callStack.pop(-1)

        self.count += 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(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()