Exemplo n.º 1
0
    def data(self, index, role=QtCore.Qt.DisplayRole):
        if not index.isValid():
            return QtCore.QVariant()

        column = index.column()
        if role == QtCore.Qt.EditRole:
            item = index.internalPointer()
            if item:
                return item.data(index.column())
        else:
            return CTreeModel.data(self, index, role)
Exemplo n.º 2
0
 def data(self, index, role):
     if index.column() == TreeColumns.CONTAINER_TYPE:
         bg = index.internalPointer().containerColor()
         if isinstance(bg, QtGui.QColor):
             if role == QtCore.Qt.BackgroundRole:
                 return QtGui.QBrush(bg)
             elif role == QtCore.Qt.ForegroundRole:
                 # http://stackoverflow.com/a/1855903/5139327
                 a = 1 - (.299 * bg.red() + .587 * bg.green() +
                          .114 * bg.blue()) / 255
                 return QtGui.QBrush(
                     QtCore.Qt.black if a < .5 else QtCore.Qt.white)
     return CTreeModel.data(self, index, role)
Exemplo n.º 3
0
    def data(self, index, role=QtCore.Qt.DisplayRole):
        if not index.isValid():
            return QtCore.QVariant()

        column = index.column()
        if role == QtCore.Qt.CheckStateRole and column == CEventJobTicketsItem.nameColumn:
            item = index.internalPointer()
            if item:
                return QtCore.QVariant(QtCore.Qt.Checked if item.checked() else QtCore.Qt.Unchecked)
        elif role == QtCore.Qt.EditRole:
            item = index.internalPointer()
            if item:
                if column == CEventJobTicketsItem.jobTicketColumn:
                    return QtCore.QVariant(item.jobTicketId())
                elif column == CEventJobTicketsItem.jobTicketLIDColumn and item._ttjRecord:
                    return toVariant(forceString(item._ttjRecord.value('externalId')))
        return CTreeModel.data(self, index, role)