19 const QPointF &pointReference,
23 m_pdfCropping (pdfCropping),
24 m_orientationFlags (orientationFlags),
25 m_disableEventsWhileMovingAutomatically (false),
29 const double SUBTLE_OPACITY = 0.2;
43 setFlags (QGraphicsItem::ItemIsMovable |
44 QGraphicsItem::ItemIsSelectable |
45 QGraphicsItem::ItemSendsScenePositionChanges);
48 setBrush (QBrush (Qt::blue));
51 setOpacity (SUBTLE_OPACITY);
52 setPos (pointReference);
60 QPointF pointPos = pointReference;
62 pointPos.setX (pointPos.x() - handleSize.width() / 2.0);
64 pointPos.setX (pointPos.x() + handleSize.width() / 2.0);
67 pointPos.setY (pointPos.y() - handleSize.height() / 2.0);
69 pointPos.setY (pointPos.y() + handleSize.height() / 2.0);
74 QPointF topLeftLocal = mapFromScene (pointPos);
76 setRect (QRectF (topLeftLocal,
81 const QVariant &value)
83 QVariant valueFiltered = value;
85 if (change == ItemPositionChange && scene()) {
87 QPointF sizeAsPointF (boundingRect().size().width(),
88 boundingRect().size().height());
91 QPointF newPos = valueFiltered.toPointF();
92 QPointF oldPos = pos ();
95 QRectF newRectItem (newPos,
96 QSize (qFloor (boundingRect().size().width()),
97 qFloor (boundingRect().size().height())));
98 QPolygonF newRectScene = mapToScene (newRectItem);
99 QPolygon newRectView = m_view.mapFromScene (newRectScene.boundingRect());
102 QRectF rectWindow = m_scene.sceneRect();
103 if (!rectWindow.contains (newRectView.boundingRect())) {
106 newPos.setX (qMin (rectWindow.right(), qMax (newPos.x(), rectWindow.left())));
107 newPos.setY (qMin (rectWindow.bottom(), qMax (newPos.y(), rectWindow.top())));
109 valueFiltered = (newPos);
115 if (!m_disableEventsWhileMovingAutomatically) {
123 m_pdfCropping.moveTL (newPos, oldPos);
124 }
else if (right && top) {
125 m_pdfCropping.moveTR (newPos, oldPos);
126 }
else if (right && bottom) {
127 m_pdfCropping.moveBR (newPos, oldPos);
128 }
else if (left && bottom) {
129 m_pdfCropping.moveBL (newPos, oldPos);
134 return QGraphicsItem::itemChange(change, valueFiltered);
140 QStyleOptionGraphicsItem scrubbed (*option);
141 scrubbed.state &= ~QStyle::State_Selected;
142 QGraphicsRectItem::paint (painter, &scrubbed, widget);
PdfFrameHandle(QGraphicsScene &scene, QGraphicsView &view, const QPointF &pointReference, int orientationFlags, PdfCropping &pdfCropping, int zValue)
Single constructor.
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Override the paint method so the dashed-border-when-selected can be removed.