'Update the selection rectangle from a QGraphicsSceneMouseEvent
`event` instance.'

def update_selection(self, event):

    if (self.initial_selection is None):
        self.initial_selection = set(self.scene.selectedItems())
        self.last_selection = self.initial_selection
    pos = event.scenePos()
    self.selection_rect = QRectF(self.selection_rect.topLeft(), pos)
    rect = self._bound_selection_rect(self.selection_rect.normalized())
    pw = (self.rect_item.pen().width() + 0.5)
    self.rect_item.setRect(rect.adjusted(pw, pw, (- pw), (- pw)))
    selected = self.scene.items(self.selection_rect.normalized(), Qt.IntersectsItemShape, Qt.AscendingOrder)
    selected = set([item for item in selected if (item.flags() & Qt.ItemIsSelectable)])
    if (self.modifiers & Qt.ControlModifier):
        for item in ((selected | self.last_selection) | self.initial_selection):
            item.setSelected(((item in selected) ^ (item in self.initial_selection)))
    else:
        for item in selected.union(self.last_selection):
            item.setSelected((item in selected))
    self.last_selection = set(self.scene.selectedItems())
