Qt 4.8
Public Functions | Properties | List of all members
QmlJSDebugger::LiveSelectionIndicator Class Reference

#include <liveselectionindicator.h>

Public Functions

void clear ()
 
void hide ()
 
 LiveSelectionIndicator (QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem)
 
void setItems (const QList< QWeakPointer< QGraphicsObject > > &itemList)
 
void show ()
 
 ~LiveSelectionIndicator ()
 

Properties

QHash< QGraphicsItem *, QGraphicsRectItem * > m_indicatorShapeHash
 
QWeakPointer< QGraphicsObjectm_layerItem
 
QDeclarativeViewInspectorm_view
 

Detailed Description

Definition at line 59 of file liveselectionindicator.h.

Constructors and Destructors

◆ LiveSelectionIndicator()

QmlJSDebugger::LiveSelectionIndicator::LiveSelectionIndicator ( QDeclarativeViewInspector viewInspector,
QGraphicsObject layerItem 
)

Definition at line 54 of file liveselectionindicator.cpp.

56  : m_layerItem(layerItem)
57  , m_view(viewInspector)
58 {
59 }
QWeakPointer< QGraphicsObject > m_layerItem

◆ ~LiveSelectionIndicator()

QmlJSDebugger::LiveSelectionIndicator::~LiveSelectionIndicator ( )

Definition at line 61 of file liveselectionindicator.cpp.

Functions

◆ clear()

void QmlJSDebugger::LiveSelectionIndicator::clear ( void  )

Definition at line 78 of file liveselectionindicator.cpp.

Referenced by QmlJSDebugger::LiveSelectionTool::clear(), setItems(), and ~LiveSelectionIndicator().

79 {
80  if (!m_layerItem.isNull()) {
81  QGraphicsScene *scene = m_layerItem.data()->scene();
82  foreach (QGraphicsRectItem *item, m_indicatorShapeHash) {
83  scene->removeItem(item);
84  delete item;
85  }
86  }
87 
89 
90 }
The QGraphicsScene class provides a surface for managing a large number of 2D graphical items...
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
QHash< QGraphicsItem *, QGraphicsRectItem * > m_indicatorShapeHash
void clear()
Removes all items from the hash.
Definition: qhash.h:574
QWeakPointer< QGraphicsObject > m_layerItem
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
T * data() const
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.

◆ hide()

void QmlJSDebugger::LiveSelectionIndicator::hide ( )

Definition at line 72 of file liveselectionindicator.cpp.

73 {
75  item->hide();
76 }
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
QHash< QGraphicsItem *, QGraphicsRectItem * > m_indicatorShapeHash
void hide()
Hides the item.

◆ setItems()

void QmlJSDebugger::LiveSelectionIndicator::setItems ( const QList< QWeakPointer< QGraphicsObject > > &  itemList)

Definition at line 92 of file liveselectionindicator.cpp.

Referenced by QmlJSDebugger::LiveSelectionTool::repaintBoundingRects(), and QmlJSDebugger::LiveSelectionTool::selectedItemsChanged().

93 {
94  clear();
95 
96  foreach (const QWeakPointer<QGraphicsObject> &object, itemList) {
97  if (object.isNull())
98  continue;
99 
100  QGraphicsItem *item = object.data();
101 
102  if (!m_indicatorShapeHash.contains(item)) {
103  QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data());
104  m_indicatorShapeHash.insert(item, selectionIndicator);
105 
107  const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect);
108 
109  selectionIndicator->setData(Constants::EditorItemDataKey, true);
110  selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false);
111  selectionIndicator->setRect(boundingRectInLayerItemSpace);
112  selectionIndicator->setPen(QColor(108, 141, 221));
113  }
114  }
115 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
QHash< QGraphicsItem *, QGraphicsRectItem * > m_indicatorShapeHash
virtual QRectF boundingRect() const =0
This pure virtual function defines the outer bounds of the item as a rectangle; all painting must be ...
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
QWeakPointer< QGraphicsObject > m_layerItem
QRectF mapRectToScene(const QRectF &rect) const
Maps the rectangle rect, which is in this item&#39;s coordinate system, to the scene coordinate system...
T * data() const
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
static const QRectF boundingRect(const QPointF *points, int pointCount)
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QRectF mapRectFromScene(const QRectF &rect) const
Maps the rectangle rect, which is in scene coordinates, to this item&#39;s coordinate system...
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
void setData(int key, const QVariant &value)
Sets this item&#39;s custom data for the key key to value.
void setPen(const QPen &pen)
Sets the pen for this item to pen.
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
void setRect(const QRectF &rect)
Sets the item&#39;s rectangle to be the given rectangle.
static const int EditorItemDataKey
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
static bool isNull(const QVariant::Private *d)
Definition: qvariant.cpp:300

◆ show()

void QmlJSDebugger::LiveSelectionIndicator::show ( )

Definition at line 66 of file liveselectionindicator.cpp.

67 {
69  item->show();
70 }
The QGraphicsRectItem class provides a rectangle item that you can add to a QGraphicsScene.
QHash< QGraphicsItem *, QGraphicsRectItem * > m_indicatorShapeHash
void show()
Shows the item.

Properties

◆ m_indicatorShapeHash

QHash<QGraphicsItem*, QGraphicsRectItem *> QmlJSDebugger::LiveSelectionIndicator::m_indicatorShapeHash
private

Definition at line 73 of file liveselectionindicator.h.

Referenced by clear(), hide(), setItems(), and show().

◆ m_layerItem

QWeakPointer<QGraphicsObject> QmlJSDebugger::LiveSelectionIndicator::m_layerItem
private

Definition at line 74 of file liveselectionindicator.h.

Referenced by clear(), and setItems().

◆ m_view

QDeclarativeViewInspector* QmlJSDebugger::LiveSelectionIndicator::m_view
private

Definition at line 75 of file liveselectionindicator.h.

Referenced by setItems().


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