Qt 4.8
Public Types | Public Functions | Protected Functions | Private Slots | Private Functions | Properties | List of all members
QmlJSDebugger::ZoomTool Class Reference

#include <zoomtool.h>

Inheritance diagram for QmlJSDebugger::ZoomTool:
QmlJSDebugger::AbstractLiveEditTool QmlJSDebugger::AbstractTool QObject

Public Types

enum  ZoomDirection { ZoomIn, ZoomOut }
 

Public Functions

void clear ()
 
void hoverMoveEvent (QMouseEvent *event)
 
void itemsAboutToRemoved (const QList< QGraphicsItem *> &)
 
void keyPressEvent (QKeyEvent *event)
 
void keyReleaseEvent (QKeyEvent *keyEvent)
 
void mouseDoubleClickEvent (QMouseEvent *event)
 
void mouseMoveEvent (QMouseEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event)
 
void wheelEvent (QWheelEvent *event)
 
 ZoomTool (QDeclarativeViewInspector *view)
 
virtual ~ZoomTool ()
 
- Public Functions inherited from QmlJSDebugger::AbstractLiveEditTool
 AbstractLiveEditTool (QDeclarativeViewInspector *inspector)
 
QList< QGraphicsItem * > items () const
 
void leaveEvent (QEvent *)
 
QString titleForItem (QGraphicsItem *item)
 
bool topItemIsMovable (const QList< QGraphicsItem *> &itemList)
 
bool topItemIsResizeHandle (const QList< QGraphicsItem *> &itemList)
 
bool topSelectedItemIsMovable (const QList< QGraphicsItem *> &itemList)
 
void updateSelectedItems ()
 
virtual ~AbstractLiveEditTool ()
 
- Public Functions inherited from QmlJSDebugger::AbstractTool
 AbstractTool (AbstractViewInspector *inspector)
 
AbstractViewInspectorinspector () const
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

void selectedItemsChanged (const QList< QGraphicsItem *> &)
 
- Protected Functions inherited from QmlJSDebugger::AbstractLiveEditTool
QDeclarativeViewInspectorinspector () const
 
QGraphicsScenescene () const
 
QDeclarativeViewview () const
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Private Slots

void zoomIn ()
 
void zoomOut ()
 
void zoomTo100 ()
 

Private Functions

qreal nextZoomScale (ZoomDirection direction) const
 
void scaleView (const QPointF &centerPos)
 

Properties

qreal m_currentScale
 
QPointF m_dragBeginPos
 
bool m_dragStarted
 
QPoint m_mousePos
 
LiveRubberBandSelectionManipulatorm_rubberbandManipulator
 
qreal m_smoothZoomMultiplier
 
QActionm_zoomInAction
 
QActionm_zoomOutAction
 
QActionm_zoomTo100Action
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QmlJSDebugger::AbstractLiveEditTool
static QList< QGraphicsObject * > toGraphicsObjectList (const QList< QGraphicsItem *> &itemList)
 
static QDeclarativeItemtopMovableDeclarativeItem (const QList< QGraphicsItem *> &itemList)
 
static QGraphicsItemtopMovableGraphicsItem (const QList< QGraphicsItem *> &itemList)
 
static QDeclarativeItemtoQDeclarativeItem (QGraphicsItem *item)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 52 of file zoomtool.h.

Enumerations

◆ ZoomDirection

Enumerator
ZoomIn 
ZoomOut 

Definition at line 57 of file zoomtool.h.

Constructors and Destructors

◆ ZoomTool()

QmlJSDebugger::ZoomTool::ZoomTool ( QDeclarativeViewInspector view)
explicit

Definition at line 57 of file zoomtool.cpp.

57  :
61  m_currentScale(1.0f)
62 {
63  m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this);
64  m_zoomInAction = new QAction(tr("Zoom In"), this);
65  m_zoomOutAction = new QAction(tr("Zoom Out"), this);
68 
69 
70  LiveLayerItem *layerItem = QDeclarativeViewInspectorPrivate::get(view)->manipulatorLayer;
71  QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem);
72  m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view);
73 
74 
75  connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100()));
76  connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn()));
77  connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut()));
78 }
void setShortcut(const QKeySequence &shortcut)
Definition: qaction.cpp:450
QAction * m_zoomTo100Action
Definition: zoomtool.h:96
#define SLOT(a)
Definition: qobjectdefs.h:226
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QAction * m_zoomOutAction
Definition: zoomtool.h:98
LiveRubberBandSelectionManipulator * m_rubberbandManipulator
Definition: zoomtool.h:99
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
AbstractLiveEditTool(QDeclarativeViewInspector *inspector)
The QGraphicsObject class provides a base class for all graphics items that require signals...
QAction * m_zoomInAction
Definition: zoomtool.h:97
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)

◆ ~ZoomTool()

QmlJSDebugger::ZoomTool::~ZoomTool ( )
virtual

Definition at line 80 of file zoomtool.cpp.

81 {
83 }
LiveRubberBandSelectionManipulator * m_rubberbandManipulator
Definition: zoomtool.h:99

Functions

◆ clear()

void QmlJSDebugger::ZoomTool::clear ( void  )
virtual

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 245 of file zoomtool.cpp.

Referenced by itemsAboutToRemoved().

246 {
247 #ifndef QT_NO_CURSOR
249 #endif
250 }
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290

◆ hoverMoveEvent()

void QmlJSDebugger::ZoomTool::hoverMoveEvent ( QMouseEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 183 of file zoomtool.cpp.

184 {
185  m_mousePos = event->pos();
186 }

◆ itemsAboutToRemoved()

void QmlJSDebugger::ZoomTool::itemsAboutToRemoved ( const QList< QGraphicsItem *> &  )
inlinevirtual

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 76 of file zoomtool.h.

76 {}

◆ keyPressEvent()

void QmlJSDebugger::ZoomTool::keyPressEvent ( QKeyEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 189 of file zoomtool.cpp.

190 {
191 }

◆ keyReleaseEvent()

void QmlJSDebugger::ZoomTool::keyReleaseEvent ( QKeyEvent keyEvent)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 215 of file zoomtool.cpp.

216 {
217  switch (event->key()) {
218  case Qt::Key_Plus:
219  zoomIn();
220  break;
221  case Qt::Key_Minus:
222  zoomOut();
223  break;
224  case Qt::Key_1:
225  case Qt::Key_2:
226  case Qt::Key_3:
227  case Qt::Key_4:
228  case Qt::Key_5:
229  case Qt::Key_6:
230  case Qt::Key_7:
231  case Qt::Key_8:
232  case Qt::Key_9:
233  {
234  m_currentScale = ((event->key() - Qt::Key_0) * 1.0f);
235  scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center())
236  break;
237  }
238 
239  default:
240  break;
241  }
242 
243 }
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
void scaleView(const QPointF &centerPos)
Definition: zoomtool.cpp:252

◆ mouseDoubleClickEvent()

void QmlJSDebugger::ZoomTool::mouseDoubleClickEvent ( QMouseEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 177 of file zoomtool.cpp.

178 {
179  m_mousePos = event->pos();
180 }

◆ mouseMoveEvent()

void QmlJSDebugger::ZoomTool::mouseMoveEvent ( QMouseEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 104 of file zoomtool.cpp.

105 {
106  m_mousePos = event->pos();
107 
108  QPointF scenePos = view()->mapToScene(event->pos());
109 
110  if (event->buttons() & Qt::LeftButton
111  && (QPointF(scenePos - m_dragBeginPos).manhattanLength()
113  && !m_dragStarted)
114  {
115  m_dragStarted = true;
117  return;
118  }
119 
120  if (m_dragStarted)
121  m_rubberbandManipulator->update(scenePos);
122 
123 }
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
static const int DragStartDistance
LiveRubberBandSelectionManipulator * m_rubberbandManipulator
Definition: zoomtool.h:99
qreal manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
Definition: qpoint.cpp:603
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102

◆ mousePressEvent()

void QmlJSDebugger::ZoomTool::mousePressEvent ( QMouseEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 85 of file zoomtool.cpp.

86 {
87  m_mousePos = event->pos();
88 
89  QPointF scenePos = view()->mapToScene(event->pos());
90 
91  if (event->buttons() & Qt::RightButton) {
92  QMenu contextMenu;
93  contextMenu.addAction(m_zoomTo100Action);
94  contextMenu.addSeparator();
95  contextMenu.addAction(m_zoomInAction);
96  contextMenu.addAction(m_zoomOutAction);
97  contextMenu.exec(event->globalPos());
98  } else if (event->buttons() & Qt::LeftButton) {
99  m_dragBeginPos = scenePos;
100  m_dragStarted = false;
101  }
102 }
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
QAction * m_zoomTo100Action
Definition: zoomtool.h:96
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
QAction * m_zoomOutAction
Definition: zoomtool.h:98
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
QAction * m_zoomInAction
Definition: zoomtool.h:97

◆ mouseReleaseEvent()

void QmlJSDebugger::ZoomTool::mouseReleaseEvent ( QMouseEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 125 of file zoomtool.cpp.

126 {
127  m_mousePos = event->pos();
128  QPointF scenePos = view()->mapToScene(event->pos());
129 
130  if (m_dragStarted) {
132 
133  int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
134  int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
135  int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
136  int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
137 
138  QPointF scenePosTopLeft = QPoint(x1, y1);
139  QPointF scenePosBottomRight = QPoint(x2, y2);
140 
141  QRectF sceneArea(scenePosTopLeft, scenePosBottomRight);
142 
143  m_currentScale = qMin(view()->rect().width() / sceneArea.width(),
144  view()->rect().height() / sceneArea.height());
145 
146 
147  QTransform transform;
148  transform.scale(m_currentScale, m_currentScale);
149 
150  view()->setTransform(transform);
151  view()->setSceneRect(sceneArea);
152  } else {
154 #ifdef Q_WS_MAC
155  modifierKey = Qt::AltModifier;
156 #endif
157  if (event->modifiers() & modifierKey) {
158  zoomOut();
159  } else {
160  zoomIn();
161  }
162  }
163 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QPointF mapToScene(const QPoint &point) const
Returns the viewport coordinate point mapped to scene coordinates.
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
KeyboardModifier
Definition: qnamespace.h:127
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setTransform(const QTransform &matrix, bool combine=false)
Sets the view&#39;s current transformation matrix to matrix.
int width() const
QRect rect() const
LiveRubberBandSelectionManipulator * m_rubberbandManipulator
Definition: zoomtool.h:99
void setSceneRect(const QRectF &rect)
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ nextZoomScale()

qreal QmlJSDebugger::ZoomTool::nextZoomScale ( ZoomDirection  direction) const
private

Definition at line 292 of file zoomtool.cpp.

Referenced by selectedItemsChanged(), wheelEvent(), zoomIn(), and zoomOut().

293 {
294  static QList<qreal> zoomScales =
295  QList<qreal>()
296  << 0.125f
297  << 1.0f / 6.0f
298  << 0.25f
299  << 1.0f / 3.0f
300  << 0.5f
301  << 2.0f / 3.0f
302  << 1.0f
303  << 2.0f
304  << 3.0f
305  << 4.0f
306  << 5.0f
307  << 6.0f
308  << 7.0f
309  << 8.0f
310  << 12.0f
311  << 16.0f
312  << 32.0f
313  << 48.0f;
314 
315  if (direction == ZoomIn) {
316  for (int i = 0; i < zoomScales.length(); ++i) {
317  if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1)
318  return zoomScales[i];
319  }
320  } else {
321  for (int i = zoomScales.length() - 1; i >= 0; --i) {
322  if (zoomScales[i] < m_currentScale || i == 0)
323  return zoomScales[i];
324  }
325  }
326 
327  return 1.0f;
328 }
int length() const
This function is identical to count().
Definition: qlist.h:281
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
Qt::LayoutDirection direction

◆ scaleView()

void QmlJSDebugger::ZoomTool::scaleView ( const QPointF centerPos)
private

Definition at line 252 of file zoomtool.cpp.

Referenced by keyReleaseEvent(), selectedItemsChanged(), wheelEvent(), zoomIn(), zoomOut(), and zoomTo100().

253 {
254 
255  QTransform transform;
256  transform.scale(m_currentScale, m_currentScale);
257  view()->setTransform(transform);
258 
259  QPointF adjustedCenterPos = centerPos;
260  QSize rectSize(view()->rect().width() / m_currentScale,
261  view()->rect().height() / m_currentScale);
262 
263  QRectF sceneRect;
265  adjustedCenterPos.rx() = rectSize.width() / 2;
266  adjustedCenterPos.ry() = rectSize.height() / 2;
267  }
268 
269  if (m_currentScale < 1.0f) {
270  adjustedCenterPos.rx() = rectSize.width() / 2;
271  adjustedCenterPos.ry() = rectSize.height() / 2;
272  sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
273  view()->rect().height() / 2 -rectSize.height() / 2,
274  rectSize.width(),
275  rectSize.height());
276  } else {
277  sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
278  adjustedCenterPos.y() - rectSize.height() / 2,
279  rectSize.width(),
280  rectSize.height());
281  }
282 
283  view()->setSceneRect(sceneRect);
284 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
qreal & rx()
Returns a reference to the x coordinate of this point.
Definition: qpoint.h:302
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
void setTransform(const QTransform &matrix, bool combine=false)
Sets the view&#39;s current transformation matrix to matrix.
int width() const
void setRect(qreal x, qreal y, qreal w, qreal h)
Sets the coordinates of the rectangle&#39;s top-left corner to (x, y), and its size to the given width an...
Definition: qrect.h:754
static const double ZoomSnapDelta
QRect rect() const
void setSceneRect(const QRectF &rect)
qreal & ry()
Returns a reference to the y coordinate of this point.
Definition: qpoint.h:307
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QTransform & scale(qreal sx, qreal sy)
Scales the coordinate system by sx horizontally and sy vertically, and returns a reference to the mat...
Definition: qtransform.cpp:485
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ selectedItemsChanged()

void QmlJSDebugger::ZoomTool::selectedItemsChanged ( const QList< QGraphicsItem *> &  )
inlineprotectedvirtual

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 81 of file zoomtool.h.

81 {}

◆ wheelEvent()

void QmlJSDebugger::ZoomTool::wheelEvent ( QWheelEvent event)
virtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 193 of file zoomtool.cpp.

194 {
195  if (event->orientation() != Qt::Vertical)
196  return;
197 
198  Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier;
199  if (event->modifiers() & smoothZoomModifier) {
200  int numDegrees = event->delta() / 8;
201  m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f);
202 
203  scaleView(view()->mapToScene(m_mousePos));
204 
205  } else if (!event->modifiers()) {
206  if (event->delta() > 0) {
208  } else if (event->delta() < 0) {
210  }
211  scaleView(view()->mapToScene(m_mousePos));
212  }
213 }
qreal nextZoomScale(ZoomDirection direction) const
Definition: zoomtool.cpp:292
KeyboardModifier
Definition: qnamespace.h:127
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
void scaleView(const QPointF &centerPos)
Definition: zoomtool.cpp:252
Qt::Orientation orientation() const
Returns the wheel&#39;s orientation.
Definition: qevent.h:159
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79

◆ zoomIn

void QmlJSDebugger::ZoomTool::zoomIn ( )
privateslot

Definition at line 165 of file zoomtool.cpp.

Referenced by keyReleaseEvent(), mouseReleaseEvent(), selectedItemsChanged(), and ZoomTool().

166 {
168  scaleView(view()->mapToScene(m_mousePos));
169 }
qreal nextZoomScale(ZoomDirection direction) const
Definition: zoomtool.cpp:292
void scaleView(const QPointF &centerPos)
Definition: zoomtool.cpp:252

◆ zoomOut

void QmlJSDebugger::ZoomTool::zoomOut ( )
privateslot

Definition at line 171 of file zoomtool.cpp.

Referenced by keyReleaseEvent(), mouseReleaseEvent(), selectedItemsChanged(), and ZoomTool().

172 {
174  scaleView(view()->mapToScene(m_mousePos));
175 }
qreal nextZoomScale(ZoomDirection direction) const
Definition: zoomtool.cpp:292
void scaleView(const QPointF &centerPos)
Definition: zoomtool.cpp:252

◆ zoomTo100

void QmlJSDebugger::ZoomTool::zoomTo100 ( )
privateslot

Definition at line 286 of file zoomtool.cpp.

Referenced by selectedItemsChanged(), and ZoomTool().

287 {
288  m_currentScale = 1.0f;
289  scaleView(view()->mapToScene(view()->rect().center()));
290 }
void scaleView(const QPointF &centerPos)
Definition: zoomtool.cpp:252
Q_CORE_EXPORT QTextStream & center(QTextStream &s)

Properties

◆ m_currentScale

qreal QmlJSDebugger::ZoomTool::m_currentScale
private

◆ m_dragBeginPos

QPointF QmlJSDebugger::ZoomTool::m_dragBeginPos
private

Definition at line 95 of file zoomtool.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_dragStarted

bool QmlJSDebugger::ZoomTool::m_dragStarted
private

Definition at line 93 of file zoomtool.h.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

◆ m_mousePos

QPoint QmlJSDebugger::ZoomTool::m_mousePos
private

◆ m_rubberbandManipulator

LiveRubberBandSelectionManipulator* QmlJSDebugger::ZoomTool::m_rubberbandManipulator
private

Definition at line 99 of file zoomtool.h.

Referenced by mouseMoveEvent(), mouseReleaseEvent(), ZoomTool(), and ~ZoomTool().

◆ m_smoothZoomMultiplier

qreal QmlJSDebugger::ZoomTool::m_smoothZoomMultiplier
private

Definition at line 101 of file zoomtool.h.

Referenced by wheelEvent().

◆ m_zoomInAction

QAction* QmlJSDebugger::ZoomTool::m_zoomInAction
private

Definition at line 97 of file zoomtool.h.

Referenced by mousePressEvent(), and ZoomTool().

◆ m_zoomOutAction

QAction* QmlJSDebugger::ZoomTool::m_zoomOutAction
private

Definition at line 98 of file zoomtool.h.

Referenced by mousePressEvent(), and ZoomTool().

◆ m_zoomTo100Action

QAction* QmlJSDebugger::ZoomTool::m_zoomTo100Action
private

Definition at line 96 of file zoomtool.h.

Referenced by mousePressEvent(), and ZoomTool().


The documentation for this class was generated from the following files: