'Overloads `paint` to draw borders'

def paint(self, painter, option, index):

    QStyledItemDelegate.paint(self, painter, option, index)
    borders = index.data(BorderRole)
    if borders:
        color = (index.data(BorderColorRole) or self.color)
        painter.save()
        painter.setPen(color)
        rect = option.rect
        for (side, p1, p2) in (('t', rect.topLeft(), rect.topRight()), ('r', rect.topRight(), rect.bottomRight()), ('b', rect.bottomLeft(), rect.bottomRight()), ('l', rect.topLeft(), rect.bottomLeft())):
            if (side in borders):
                painter.drawLine(p1, p2)
        painter.restore()
