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

#include <liveselectiontool.h>

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

Public Functions

void clear ()
 
void hoverMoveEvent (QMouseEvent *event)
 
void itemsAboutToRemoved (const QList< QGraphicsItem *> &)
 
void keyPressEvent (QKeyEvent *event)
 
void keyReleaseEvent (QKeyEvent *)
 
 LiveSelectionTool (QDeclarativeViewInspector *editorView)
 
void mouseDoubleClickEvent (QMouseEvent *)
 
void mouseMoveEvent (QMouseEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event)
 
void selectedItemsChanged (const QList< QGraphicsItem *> &itemList)
 
void selectUnderPoint (QMouseEvent *event)
 
void setRubberbandSelectionMode (bool value)
 
void setSelectOnlyContentItems (bool selectOnlyContentItems)
 
void wheelEvent (QWheelEvent *event)
 
 ~LiveSelectionTool ()
 
- 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...
 

Private Slots

void contextMenuElementHovered (QAction *action)
 
void contextMenuElementSelected ()
 
void repaintBoundingRects ()
 

Private Functions

bool alreadySelected (const QList< QGraphicsItem *> &itemList) const
 
void createContextMenu (const QList< QGraphicsItem *> &itemList, QPoint globalPos)
 
LiveSingleSelectionManipulator::SelectionType getSelectionType (Qt::KeyboardModifiers modifiers)
 

Properties

QList< QGraphicsItem * > m_contextMenuItemList
 
QTime m_mousePressTimer
 
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator
 
bool m_rubberbandSelectionMode
 
QList< QWeakPointer< QGraphicsObject > > m_selectedItemList
 
LiveSelectionIndicator m_selectionIndicator
 
bool m_selectOnlyContentItems
 
LiveSingleSelectionManipulator m_singleSelectionManipulator
 

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 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...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 60 of file liveselectiontool.h.

Constructors and Destructors

◆ LiveSelectionTool()

QmlJSDebugger::LiveSelectionTool::LiveSelectionTool ( QDeclarativeViewInspector editorView)

Definition at line 62 of file liveselectiontool.cpp.

62  :
63  AbstractLiveEditTool(editorView),
66  QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView),
67  m_singleSelectionManipulator(editorView),
68  m_selectionIndicator(editorView,
69  QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer),
70  //m_resizeIndicator(editorView->manipulatorLayer()),
72 {
73 
74 }
LiveSingleSelectionManipulator m_singleSelectionManipulator
LiveSelectionIndicator m_selectionIndicator
AbstractLiveEditTool(QDeclarativeViewInspector *inspector)
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)

◆ ~LiveSelectionTool()

QmlJSDebugger::LiveSelectionTool::~LiveSelectionTool ( )

Definition at line 76 of file liveselectiontool.cpp.

77 {
78 }

Functions

◆ alreadySelected()

bool QmlJSDebugger::LiveSelectionTool::alreadySelected ( const QList< QGraphicsItem *> &  itemList) const
private

Definition at line 98 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

99 {
100  QDeclarativeViewInspectorPrivate *inspectorPrivate
102  const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems();
103 
104  if (selectedItems.isEmpty())
105  return false;
106 
107  foreach (QGraphicsItem *item, itemList)
108  if (selectedItems.contains(item))
109  return true;
110 
111  return false;
112 }
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QDeclarativeViewInspector * inspector() const
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ clear()

void QmlJSDebugger::LiveSelectionTool::clear ( void  )
virtual

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 364 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

365 {
366 #ifndef QT_NO_CURSOR
368 #endif
372  //m_resizeIndicator.clear();
373 }
LiveSingleSelectionManipulator m_singleSelectionManipulator
LiveSelectionIndicator m_selectionIndicator
void setCursor(const QCursor &)
Definition: qwidget.cpp:5290
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator

◆ contextMenuElementHovered

void QmlJSDebugger::LiveSelectionTool::contextMenuElementHovered ( QAction action)
privateslot

Definition at line 193 of file liveselectiontool.cpp.

Referenced by createContextMenu(), and itemsAboutToRemoved().

194 {
195  int itemListIndex = action->data().toInt();
196  if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
197  QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
199  }
200 }
QList< QGraphicsItem * > m_contextMenuItemList
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
QGraphicsObject * toGraphicsObject()
Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object...
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int length() const
This function is identical to count().
Definition: qlist.h:281
QVariant data() const
Returns the user data as set in QAction::setData.
Definition: qaction.cpp:1280
void highlight(const QList< QGraphicsObject *> &item)
QDeclarativeViewInspector * inspector() const
The QGraphicsObject class provides a base class for all graphics items that require signals...
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)

◆ contextMenuElementSelected

void QmlJSDebugger::LiveSelectionTool::contextMenuElementSelected ( )
privateslot

Definition at line 177 of file liveselectiontool.cpp.

Referenced by createContextMenu(), and itemsAboutToRemoved().

178 {
179  QAction *senderAction = static_cast<QAction*>(sender());
180  int itemListIndex = senderAction->data().toInt();
181  if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
182 
183  QPointF updatePt(0, 0);
184  QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex);
187  QList<QGraphicsItem*>() << item,
188  false);
190  }
191 }
QList< QGraphicsItem * > m_contextMenuItemList
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
LiveSingleSelectionManipulator m_singleSelectionManipulator
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
Definition: qobject.cpp:2327
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
Definition: qvariant.cpp:2625
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int length() const
This function is identical to count().
Definition: qlist.h:281
QVariant data() const
Returns the user data as set in QAction::setData.
Definition: qaction.cpp:1280
void select(SelectionType selectionType, const QList< QGraphicsItem *> &items, bool selectOnlyContentItems)
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ createContextMenu()

void QmlJSDebugger::LiveSelectionTool::createContextMenu ( const QList< QGraphicsItem *> &  itemList,
QPoint  globalPos 
)
private

Definition at line 135 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved(), and mousePressEvent().

136 {
137  QMenu contextMenu;
138  connect(&contextMenu, SIGNAL(hovered(QAction*)),
140 
141  m_contextMenuItemList = itemList;
142 
143  contextMenu.addAction(tr("Items"));
144  contextMenu.addSeparator();
145  int shortcutKey = Qt::Key_1;
146  int i = 0;
147 
148  foreach (QGraphicsItem * const item, itemList) {
149  QString itemTitle = titleForItem(item);
150  QAction *elementAction = contextMenu.addAction(itemTitle, this,
152 
153  if (inspector()->selectedItems().contains(item)) {
154  QFont boldFont = elementAction->font();
155  boldFont.setBold(true);
156  elementAction->setFont(boldFont);
157  }
158 
159  elementAction->setData(i);
160 
161  if (shortcutKey <= Qt::Key_9) {
162  elementAction->setShortcut(QKeySequence(shortcutKey));
163  shortcutKey++;
164  }
165 
166  ++i;
167  }
168  // add root item separately
169  // QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
170  // contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
171  // m_contextMenuItemList.append(view()->currentRootItem());
172 
173  contextMenu.exec(globalPos);
175 }
QList< QGraphicsItem * > m_contextMenuItemList
void setShortcut(const QKeySequence &shortcut)
Definition: qaction.cpp:450
void setFont(const QFont &font)
Definition: qaction.cpp:623
#define SLOT(a)
Definition: qobjectdefs.h:226
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
The QString class provides a Unicode character string.
Definition: qstring.h:83
QAction * addAction(const QString &text)
This convenience function creates a new action with text.
Definition: qmenu.cpp:1453
void setData(const QVariant &var)
Sets the action&#39;s internal data to the given userData.
Definition: qaction.cpp:1297
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
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
QFont font
the action&#39;s font
Definition: qaction.h:81
QAction * addSeparator()
This convenience function creates a new separator action, i.e.
Definition: qmenu.cpp:1583
void clear()
Removes all items from the list.
Definition: qlist.h:764
QAction * exec()
Executes this menu synchronously.
Definition: qmenu.cpp:2101
void contextMenuElementHovered(QAction *action)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
Definition: qkeysequence.h:72
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QDeclarativeViewInspector * inspector() const
The QAction class provides an abstract user interface action that can be inserted into widgets...
Definition: qaction.h:64
QString titleForItem(QGraphicsItem *item)

◆ getSelectionType()

LiveSingleSelectionManipulator::SelectionType QmlJSDebugger::LiveSelectionTool::getSelectionType ( Qt::KeyboardModifiers  modifiers)
private

◆ hoverMoveEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 234 of file liveselectiontool.cpp.

Referenced by mouseDoubleClickEvent().

235 {
236 // ### commented out until move tool is re-enabled
237 // QList<QGraphicsItem*> itemList = view()->items(event->pos());
238 // if (!itemList.isEmpty() && !m_rubberbandSelectionMode) {
239 //
240 // foreach (QGraphicsItem *item, itemList) {
241 // if (item->type() == Constants::ResizeHandleItemType) {
242 // ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item);
243 // if (resizeHandle)
244 // view()->changeTool(Constants::ResizeToolMode);
245 // return;
246 // }
247 // }
248 // if (topSelectedItemIsMovable(itemList))
249 // view()->changeTool(Constants::MoveToolMode);
250 // }
251  QDeclarativeViewInspectorPrivate *inspectorPrivate
253 
254  QList<QGraphicsItem*> selectableItemList = inspectorPrivate->selectableItems(event->pos());
255  if (!selectableItemList.isEmpty()) {
256  QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
257  if (item)
259 
260  return;
261  }
262 
264 }
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QGraphicsObject * toGraphicsObject()
Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object...
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
void highlight(const QList< QGraphicsObject *> &item)
QDeclarativeViewInspector * inspector() const
The QGraphicsObject class provides a base class for all graphics items that require signals...
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ itemsAboutToRemoved()

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

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 77 of file liveselectiontool.h.

77 {}

◆ keyPressEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 306 of file liveselectiontool.cpp.

Referenced by mouseDoubleClickEvent().

307 {
308  switch (event->key()) {
309  case Qt::Key_Left:
310  case Qt::Key_Right:
311  case Qt::Key_Up:
312  case Qt::Key_Down:
313  // disabled for now, cannot move stuff yet.
314  //view()->changeTool(Constants::MoveToolMode);
315  //view()->currentTool()->keyPressEvent(event);
316  break;
317  }
318 }
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231

◆ keyReleaseEvent()

void QmlJSDebugger::LiveSelectionTool::keyReleaseEvent ( QKeyEvent )
inlinevirtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 74 of file liveselectiontool.h.

74 {}

◆ mouseDoubleClickEvent()

void QmlJSDebugger::LiveSelectionTool::mouseDoubleClickEvent ( QMouseEvent )
inlinevirtual

Implements QmlJSDebugger::AbstractTool.

Definition at line 71 of file liveselectiontool.h.

71 {}

◆ mouseMoveEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 202 of file liveselectiontool.cpp.

203 {
205  QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos();
206 
207  if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
209  {
211  //view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint());
212  return;
213  }
215  QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
216 
217  if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
220 
221  if (event->modifiers().testFlag(Qt::ControlModifier))
224  else if (event->modifiers().testFlag(Qt::ShiftModifier))
227  else
230  }
231  }
232 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
LiveSingleSelectionManipulator m_singleSelectionManipulator
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
int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
Definition: qpoint.cpp:489
int elapsed() const
Returns the number of milliseconds that have elapsed since the last time start() or restart() was cal...
Definition: qdatetime.cpp:2123
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79

◆ mousePressEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 114 of file liveselectiontool.cpp.

115 {
116  QDeclarativeViewInspectorPrivate *inspectorPrivate
118  QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
120 
121  if (event->buttons() & Qt::LeftButton) {
123 
126  } else {
129  }
130  } else if (event->buttons() & Qt::RightButton) {
131  createContextMenu(itemList, event->globalPos());
132  }
133 }
void start()
Sets this time to the current time.
Definition: qdatetime.cpp:2070
LiveSingleSelectionManipulator m_singleSelectionManipulator
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
void createContextMenu(const QList< QGraphicsItem *> &itemList, QPoint globalPos)
QDeclarativeViewInspector * inspector() const
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
Definition: qevent.h:96
void select(SelectionType selectionType, const QList< QGraphicsItem *> &items, bool selectOnlyContentItems)
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers)

◆ mouseReleaseEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 266 of file liveselectiontool.cpp.

267 {
270  }
272 
273  QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
274  if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) {
276 
277  if (event->modifiers().testFlag(Qt::ControlModifier))
280  else if (event->modifiers().testFlag(Qt::ShiftModifier))
283  else
286 
288  } else {
290 
291  if (event->modifiers().testFlag(Qt::ControlModifier))
294  else if (event->modifiers().testFlag(Qt::ShiftModifier))
297  else
300 
302  }
303  }
304 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
LiveSingleSelectionManipulator m_singleSelectionManipulator
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
int manhattanLength() const
Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" ...
Definition: qpoint.cpp:489
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
Definition: qpoint.h:376
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
void select(SelectionType selectionType, const QList< QGraphicsItem *> &items, bool selectOnlyContentItems)

◆ repaintBoundingRects

void QmlJSDebugger::LiveSelectionTool::repaintBoundingRects ( )
privateslot

Definition at line 403 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved(), and selectedItemsChanged().

404 {
406 }
QList< QWeakPointer< QGraphicsObject > > m_selectedItemList
void setItems(const QList< QWeakPointer< QGraphicsObject > > &itemList)
LiveSelectionIndicator m_selectionIndicator

◆ selectedItemsChanged()

void QmlJSDebugger::LiveSelectionTool::selectedItemsChanged ( const QList< QGraphicsItem *> &  itemList)
virtual

Implements QmlJSDebugger::AbstractLiveEditTool.

Definition at line 375 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

376 {
377  foreach (const QWeakPointer<QGraphicsObject> &obj, m_selectedItemList) {
378  if (!obj.isNull()) {
379  disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
380  disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
381  disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
382  disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
383  disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
384  }
385  }
386 
387  QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList);
389 
390  foreach (QGraphicsObject *obj, objects) {
392  connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
393  connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
394  connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
395  connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
396  connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
397  }
398 
400  //m_resizeIndicator.setItems(toGraphicsObjectList(itemList));
401 }
QList< QWeakPointer< QGraphicsObject > > m_selectedItemList
void setItems(const QList< QWeakPointer< QGraphicsObject > > &itemList)
#define SLOT(a)
Definition: qobjectdefs.h:226
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
T * data() const
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
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
LiveSelectionIndicator m_selectionIndicator
void clear()
Removes all items from the list.
Definition: qlist.h:764
static QList< QGraphicsObject * > toGraphicsObjectList(const QList< QGraphicsItem *> &itemList)
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.
Definition: qobject.cpp:2895
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ selectUnderPoint()

void QmlJSDebugger::LiveSelectionTool::selectUnderPoint ( QMouseEvent event)

Definition at line 408 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

409 {
411 
412  if (event->modifiers().testFlag(Qt::ControlModifier))
415  else if (event->modifiers().testFlag(Qt::ShiftModifier))
418  else
421 
423 }
LiveSingleSelectionManipulator m_singleSelectionManipulator
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
void select(SelectionType selectionType, const QList< QGraphicsItem *> &items, bool selectOnlyContentItems)

◆ setRubberbandSelectionMode()

void QmlJSDebugger::LiveSelectionTool::setRubberbandSelectionMode ( bool  value)

Definition at line 80 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

◆ setSelectOnlyContentItems()

void QmlJSDebugger::LiveSelectionTool::setSelectOnlyContentItems ( bool  selectOnlyContentItems)

Definition at line 359 of file liveselectiontool.cpp.

Referenced by itemsAboutToRemoved().

360 {
361  m_selectOnlyContentItems = selectOnlyContentItems;
362 }

◆ wheelEvent()

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

Implements QmlJSDebugger::AbstractTool.

Definition at line 320 of file liveselectiontool.cpp.

Referenced by keyReleaseEvent().

321 {
323  return;
324 
325  QDeclarativeViewInspectorPrivate *inspectorPrivate
327  QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
328 
329  if (itemList.isEmpty())
330  return;
331 
332  int selectedIdx = 0;
333  if (!inspector()->selectedItems().isEmpty()) {
334  selectedIdx = itemList.indexOf(inspector()->selectedItems().first());
335  if (selectedIdx >= 0) {
336  if (event->delta() > 0) {
337  selectedIdx++;
338  if (selectedIdx == itemList.length())
339  selectedIdx = 0;
340  } else if (event->delta() < 0) {
341  selectedIdx--;
342  if (selectedIdx == -1)
343  selectedIdx = itemList.length() - 1;
344  }
345  } else {
346  selectedIdx = 0;
347  }
348  }
349 
350  QPointF updatePt(0, 0);
353  QList<QGraphicsItem*>() << itemList.at(selectedIdx),
354  false);
356 
357 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
LiveSingleSelectionManipulator m_singleSelectionManipulator
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int delta() const
Returns the distance that the wheel is rotated, in eighths of a degree.
Definition: qevent.h:150
Qt::Orientation orientation() const
Returns the wheel&#39;s orientation.
Definition: qevent.h:159
const QPoint & pos() const
Returns the position of the mouse cursor relative to the widget that received the event...
Definition: qevent.h:151
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
int length() const
This function is identical to count().
Definition: qlist.h:281
QDeclarativeViewInspector * inspector() const
void select(SelectionType selectionType, const QList< QGraphicsItem *> &items, bool selectOnlyContentItems)
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

Properties

◆ m_contextMenuItemList

QList<QGraphicsItem*> QmlJSDebugger::LiveSelectionTool::m_contextMenuItemList
private

◆ m_mousePressTimer

QTime QmlJSDebugger::LiveSelectionTool::m_mousePressTimer
private

Definition at line 110 of file liveselectiontool.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ m_rubberbandSelectionManipulator

LiveRubberBandSelectionManipulator QmlJSDebugger::LiveSelectionTool::m_rubberbandSelectionManipulator
private

Definition at line 106 of file liveselectiontool.h.

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

◆ m_rubberbandSelectionMode

bool QmlJSDebugger::LiveSelectionTool::m_rubberbandSelectionMode
private

Definition at line 105 of file liveselectiontool.h.

Referenced by mousePressEvent(), setRubberbandSelectionMode(), and wheelEvent().

◆ m_selectedItemList

QList<QWeakPointer<QGraphicsObject> > QmlJSDebugger::LiveSelectionTool::m_selectedItemList
private

Definition at line 113 of file liveselectiontool.h.

Referenced by repaintBoundingRects(), and selectedItemsChanged().

◆ m_selectionIndicator

LiveSelectionIndicator QmlJSDebugger::LiveSelectionTool::m_selectionIndicator
private

Definition at line 108 of file liveselectiontool.h.

Referenced by clear(), repaintBoundingRects(), and selectedItemsChanged().

◆ m_selectOnlyContentItems

bool QmlJSDebugger::LiveSelectionTool::m_selectOnlyContentItems
private

◆ m_singleSelectionManipulator

LiveSingleSelectionManipulator QmlJSDebugger::LiveSelectionTool::m_singleSelectionManipulator
private

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