This class acts as a single handle for the PdfCropping class.
More...
#include <PdfFrameHandle.h>
|
| | PdfFrameHandle (QGraphicsScene &scene, QGraphicsView &view, const QPointF &pointReference, int orientationFlags, PdfCropping &pdfCropping, int zValue) |
| | Single constructor. More...
|
| |
| virtual QVariant | itemChange (GraphicsItemChange change, const QVariant &value) |
| | Intercept the drags and process them, which is the whole point of handles. More...
|
| |
| virtual void | paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
| | Override the paint method so the dashed-border-when-selected can be removed. More...
|
| |
| void | setDisableEventsWhileMovingAutomatically (bool disable) |
| | Temporarily disable event handling so code can move this object without triggering a cascade of events. More...
|
| |
This class acts as a single handle for the PdfCropping class.
Definition at line 18 of file PdfFrameHandle.h.
◆ PdfFrameHandle()
| PdfFrameHandle::PdfFrameHandle |
( |
QGraphicsScene & |
scene, |
|
|
QGraphicsView & |
view, |
|
|
const QPointF & |
pointReference, |
|
|
int |
orientationFlags, |
|
|
PdfCropping & |
pdfCropping, |
|
|
int |
zValue |
|
) |
| |
Single constructor.
Definition at line 16 of file PdfFrameHandle.cpp.
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,
◆ itemChange()
| QVariant PdfFrameHandle::itemChange |
( |
GraphicsItemChange |
change, |
|
|
const QVariant & |
value |
|
) |
| |
|
virtual |
Intercept the drags and process them, which is the whole point of handles.
Definition at line 79 of file PdfFrameHandle.cpp.
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);
◆ paint()
| void PdfFrameHandle::paint |
( |
QPainter * |
painter, |
|
|
const QStyleOptionGraphicsItem * |
option, |
|
|
QWidget * |
widget |
|
) |
| |
|
virtual |
Override the paint method so the dashed-border-when-selected can be removed.
Definition at line 136 of file PdfFrameHandle.cpp.
140 QStyleOptionGraphicsItem scrubbed (*option);
141 scrubbed.state &= ~QStyle::State_Selected;
142 QGraphicsRectItem::paint (painter, &scrubbed, widget);
◆ setDisableEventsWhileMovingAutomatically()
| void PdfFrameHandle::setDisableEventsWhileMovingAutomatically |
( |
bool |
disable | ) |
|
Temporarily disable event handling so code can move this object without triggering a cascade of events.
Definition at line 144 of file PdfFrameHandle.cpp.
147 m_disableEventsWhileMovingAutomatically = disable;
The documentation for this class was generated from the following files: