'Draw the focus rectangle of an ItemViewItem.'

def _draw_focus_rect(self):

    state = self._opt.state
    if (not (state & QStyle.State_HasFocus)):
        return
    o = self._opt
    o.rect = self._style.subElementRect(self._style.SE_ItemViewItemFocusRect, self._opt, self._opt.widget)
    o.state |= (QStyle.State_KeyboardFocusChange | QStyle.State_Item)
    qtutils.ensure_valid(o.rect)
    if (state & QStyle.State_Enabled):
        cg = QPalette.Normal
    else:
        cg = QPalette.Disabled
    if (state & QStyle.State_Selected):
        role = QPalette.Highlight
    else:
        role = QPalette.Window
    o.backgroundColor = self._opt.palette.color(cg, role)
    self._style.drawPrimitive(QStyle.PE_FrameFocusRect, o, self._painter, self._opt.widget)
