'Return the bounding rect of the document\'s viewport on the scene.'

def viewport_rect(self):

    view = self.document.view()
    vsize = view.viewport().size()
    viewportrect = QRect(0, 0, vsize.width(), vsize.height())
    return view.mapToScene(viewportrect).boundingRect()
