Beispiel #1
0
    def data(self, index, role):
        row = index.row()
        col = index.column()
        cluster = self.__items[row]

        if role == QtCore.Qt.DisplayRole:
            cbk = self.HEADER_CALLBACKS.get(col)
            if cbk is not None:
                return cbk(cluster)
        
        elif role == QtCore.Qt.BackgroundColorRole:
            if cluster.isLocked:
                return constants.BLUE
            elif col == 3 and cluster.total.lockedNodes:
                return constants.BLUE
            elif col == 4 and cluster.total.repairNodes:
                return constants.ORANGE
            elif col == 5 and cluster.total.downNodes:
                return constants.RED

        elif role == QtCore.Qt.TextAlignmentRole:
            if col != 0:
                return QtCore.Qt.AlignCenter

        elif role == QtCore.Qt.DecorationRole and col == 0:
            if cluster.isLocked:
                return self.__iconLocked

        elif role == IdRole:
            return cluster.id
       
        elif role == ObjectRole:
            return cluster

        elif role == QtCore.Qt.ToolTipRole:
            if col == 1:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Usage: %s" % formatPercentage(cluster.total.runCores, cluster.total.cores)
                ])
            if col == 6:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Up Cores: %d" % cluster.total.upCores,
                    "Down Cores: %d" % cluster.total.downCores,
                    "Repair Cores: %d" % cluster.total.repairCores,
                    "Locked Cores: %d" % cluster.total.lockedCores
                ])
            elif col == 2:
                return "\n".join([
                    "Total Nodes: %d" % cluster.total.nodes,
                    "Up Nodes: %d" % cluster.total.upNodes,
                    "Down Nodes: %d" % cluster.total.downNodes,
                    "Repair Nodes: %d" % cluster.total.repairNodes,
                    "Locked Nodes: %d" % cluster.total.lockedNodes,
                ])
Beispiel #2
0
    def data(self, index, role):
        row = index.row()
        col = index.column()
        cluster = self._items[row]

        if role == QtCore.Qt.BackgroundColorRole:
            if cluster.isLocked:
                return constants.BLUE
            elif col == 3 and cluster.total.lockedNodes:
                return constants.BLUE
            elif col == 4 and cluster.total.repairNodes:
                return constants.ORANGE
            elif col == 5 and cluster.total.downNodes:
                return constants.RED

        elif role == QtCore.Qt.DecorationRole and col == 0:
            if cluster.isLocked:
                return self.__iconLocked

        elif role == QtCore.Qt.ToolTipRole:
            if col == 1:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Usage: %s" % formatPercentage(cluster.total.runCores,
                                                   cluster.total.cores)
                ])
            if col == 6:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Up Cores: %d" % cluster.total.upCores,
                    "Down Cores: %d" % cluster.total.downCores,
                    "Repair Cores: %d" % cluster.total.repairCores,
                    "Locked Cores: %d" % cluster.total.lockedCores
                ])
            elif col == 2:
                return "\n".join([
                    "Total Nodes: %d" % cluster.total.nodes,
                    "Up Nodes: %d" % cluster.total.upNodes,
                    "Down Nodes: %d" % cluster.total.downNodes,
                    "Repair Nodes: %d" % cluster.total.repairNodes,
                    "Locked Nodes: %d" % cluster.total.lockedNodes,
                ])

        return super(ClusterModel, self).data(index, role)
Beispiel #3
0
    def data(self, index, role):
        row = index.row()
        col = index.column()
        cluster = self._items[row]
        
        if role == QtCore.Qt.BackgroundColorRole:
            if cluster.isLocked:
                return constants.BLUE
            elif col == 3 and cluster.total.lockedNodes:
                return constants.BLUE
            elif col == 4 and cluster.total.repairNodes:
                return constants.ORANGE
            elif col == 5 and cluster.total.downNodes:
                return constants.RED

        elif role == QtCore.Qt.DecorationRole and col == 0:
            if cluster.isLocked:
                return self.__iconLocked

        elif role == QtCore.Qt.ToolTipRole:
            if col == 1:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Usage: %s" % formatPercentage(cluster.total.runCores, cluster.total.cores)
                ])
            if col == 6:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Up Cores: %d" % cluster.total.upCores,
                    "Down Cores: %d" % cluster.total.downCores,
                    "Repair Cores: %d" % cluster.total.repairCores,
                    "Locked Cores: %d" % cluster.total.lockedCores
                ])
            elif col == 2:
                return "\n".join([
                    "Total Nodes: %d" % cluster.total.nodes,
                    "Up Nodes: %d" % cluster.total.upNodes,
                    "Down Nodes: %d" % cluster.total.downNodes,
                    "Repair Nodes: %d" % cluster.total.repairNodes,
                    "Locked Nodes: %d" % cluster.total.lockedNodes,
                ])

        return super(ClusterModel, self).data(index, role)
Beispiel #4
0
    def data(self, index, role):
        row = index.row()
        col = index.column()
        cluster = self.__items[row]

        if role == QtCore.Qt.DisplayRole:
            cbk = self.HEADER_CALLBACKS.get(col)
            if cbk is not None:
                return cbk(cluster)

        elif role == QtCore.Qt.BackgroundColorRole:
            if cluster.isLocked:
                return constants.BLUE
            elif col == 3 and cluster.total.lockedNodes:
                return constants.BLUE
            elif col == 4 and cluster.total.repairNodes:
                return constants.ORANGE
            elif col == 5 and cluster.total.downNodes:
                return constants.RED

        elif role == QtCore.Qt.TextAlignmentRole:
            if col != 0:
                return QtCore.Qt.AlignCenter

        elif role == QtCore.Qt.DecorationRole and col == 0:
            if cluster.isLocked:
                return self.__iconLocked

        elif role == IdRole:
            return cluster.id

        elif role == ObjectRole:
            return cluster

        elif role == QtCore.Qt.ToolTipRole:
            if col == 1:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Usage: %s" % formatPercentage(cluster.total.runCores,
                                                   cluster.total.cores)
                ])
            if col == 6:
                return "\n".join([
                    "Total Cores: %d" % cluster.total.cores,
                    "Running Cores: %d" % cluster.total.runCores,
                    "Idle Cores: %d" % cluster.total.idleCores,
                    "Up Cores: %d" % cluster.total.upCores,
                    "Down Cores: %d" % cluster.total.downCores,
                    "Repair Cores: %d" % cluster.total.repairCores,
                    "Locked Cores: %d" % cluster.total.lockedCores
                ])
            elif col == 2:
                return "\n".join([
                    "Total Nodes: %d" % cluster.total.nodes,
                    "Up Nodes: %d" % cluster.total.upNodes,
                    "Down Nodes: %d" % cluster.total.downNodes,
                    "Repair Nodes: %d" % cluster.total.repairNodes,
                    "Locked Nodes: %d" % cluster.total.lockedNodes,
                ])