! * Updates the magnified content of the scene under the cursor that is shown in the magnification window. * \pos is the current position of the cursor in scene coordinates which defines the middle of the magnification window. */
| 986 | * \pos is the current position of the cursor in scene coordinates which defines the middle of the magnification window. |
| 987 | */ |
| 988 | void WorksheetView::updateMagnificationWindow(const QPointF& pos) { |
| 989 | m_magnificationWindow->setVisible(false); |
| 990 | |
| 991 | // copy the part of the view to be shown magnified |
| 992 | const int size = Worksheet::convertToSceneUnits(2.0, Worksheet::Unit::Centimeter) / transform().m11(); |
| 993 | const QRectF copyRect(pos.x() - size / (2 * magnificationFactor), |
| 994 | pos.y() - size / (2 * magnificationFactor), |
| 995 | size / magnificationFactor, |
| 996 | size / magnificationFactor); |
| 997 | QPixmap px = grab(mapFromScene(copyRect).boundingRect()); |
| 998 | px = px.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); |
| 999 | |
| 1000 | // draw the bounding rect |
| 1001 | QPainter painter(&px); |
| 1002 | const QPen pen = QPen(Qt::darkGray, 2 / transform().m11()); |
| 1003 | painter.setPen(pen); |
| 1004 | QRect rect = px.rect(); |
| 1005 | rect.setWidth(rect.width() - pen.widthF() / 2); |
| 1006 | rect.setHeight(rect.height() - pen.widthF() / 2); |
| 1007 | painter.drawRect(rect); |
| 1008 | |
| 1009 | // set the pixmap and show it again |
| 1010 | m_magnificationWindow->setPixmap(px); |
| 1011 | m_magnificationWindow->setPos(pos.x() - px.width() / 2, pos.y() - px.height() / 2); |
| 1012 | m_magnificationWindow->setVisible(true); |
| 1013 | } |
| 1014 | |
| 1015 | void WorksheetView::contextMenuEvent(QContextMenuEvent* e) { |
| 1016 | if ((m_magnificationWindow && m_magnificationWindow->isVisible() && items(e->pos()).size() == 1) || !itemAt(e->pos())) { |