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

#include <liverubberbandselectionmanipulator.h>

Public Types

enum  SelectionType { ReplaceSelection, AddToSelection, RemoveFromSelection }
 

Public Functions

void begin (const QPointF &beginPoint)
 
QPointF beginPoint () const
 
void clear ()
 
void end ()
 
bool isActive () const
 
 LiveRubberBandSelectionManipulator (QGraphicsObject *layerItem, QDeclarativeViewInspector *editorView)
 
void select (SelectionType selectionType)
 
void setItems (const QList< QGraphicsItem *> &itemList)
 
void update (const QPointF &updatePoint)
 

Protected Functions

QGraphicsItemtopFormEditorItem (const QList< QGraphicsItem *> &itemList)
 

Properties

QGraphicsItemm_beginFormEditorItem
 
QPointF m_beginPoint
 
QDeclarativeViewInspectorm_editorView
 
bool m_isActive
 
QList< QGraphicsItem * > m_itemList
 
QList< QGraphicsItem * > m_oldSelectionList
 
LiveSelectionRectangle m_selectionRectangleElement
 

Detailed Description

Definition at line 55 of file liverubberbandselectionmanipulator.h.

Enumerations

◆ SelectionType

Constructors and Destructors

◆ LiveRubberBandSelectionManipulator()

QmlJSDebugger::LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator ( QGraphicsObject layerItem,
QDeclarativeViewInspector editorView 
)

Functions

◆ begin()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::begin ( const QPointF beginPoint)

Definition at line 80 of file liverubberbandselectionmanipulator.cpp.

Referenced by QmlJSDebugger::ZoomTool::mouseMoveEvent(), and QmlJSDebugger::LiveSelectionTool::mousePressEvent().

81 {
85  m_isActive = true;
86  QDeclarativeViewInspectorPrivate *inspectorPrivate
88  m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint));
90 }
void setRect(const QPointF &firstPoint, const QPointF &secondPoint)
QGraphicsItem * topFormEditorItem(const QList< QGraphicsItem *> &itemList)
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)

◆ beginPoint()

QPointF QmlJSDebugger::LiveRubberBandSelectionManipulator::beginPoint ( ) const

◆ clear()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::clear ( void  )

◆ end()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::end ( )

◆ isActive()

bool QmlJSDebugger::LiveRubberBandSelectionManipulator::isActive ( ) const

◆ select()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::select ( SelectionType  selectionType)

Definition at line 104 of file liverubberbandselectionmanipulator.cpp.

Referenced by QmlJSDebugger::LiveSelectionTool::mouseMoveEvent(), and QmlJSDebugger::LiveSelectionTool::mouseReleaseEvent().

105 {
106  QDeclarativeViewInspectorPrivate *inspectorPrivate
108  QList<QGraphicsItem*> itemList
109  = inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(),
111  QList<QGraphicsItem*> newSelectionList;
112 
113  foreach (QGraphicsItem* item, itemList) {
114  if (item
115  && item->parentItem()
116  && !newSelectionList.contains(item)
117  //&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
118  )
119  {
120  newSelectionList.append(item);
121  }
122  }
123 
124  if (newSelectionList.isEmpty() && m_beginFormEditorItem)
125  newSelectionList.append(m_beginFormEditorItem);
126 
127  QList<QGraphicsItem*> resultList;
128 
129  switch (selectionType) {
130  case AddToSelection: {
131  resultList.append(m_oldSelectionList);
132  resultList.append(newSelectionList);
133  }
134  break;
135  case ReplaceSelection: {
136  resultList.append(newSelectionList);
137  }
138  break;
139  case RemoveFromSelection: {
140  QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet());
141  QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet());
142  resultList.append(oldSelectionSet.subtract(newSelectionSet).toList());
143  }
144  }
145 
146  m_editorView->setSelectedItems(resultList);
147 }
QSet< T > toSet() const
Returns a QSet object with the data contained in this QList.
Definition: qset.h:309
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
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
void setSelectedItems(QList< QGraphicsItem *> items)
QGraphicsItem * parentItem() const
Returns a pointer to this item&#39;s parent item.
static QDeclarativeViewInspectorPrivate * get(QDeclarativeViewInspector *v)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ setItems()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::setItems ( const QList< QGraphicsItem *> &  itemList)

Definition at line 150 of file liverubberbandselectionmanipulator.cpp.

151 {
152  m_itemList = itemList;
153 }

◆ topFormEditorItem()

QGraphicsItem * QmlJSDebugger::LiveRubberBandSelectionManipulator::topFormEditorItem ( const QList< QGraphicsItem *> &  itemList)
protected

Definition at line 71 of file liverubberbandselectionmanipulator.cpp.

Referenced by begin().

73 {
74  if (itemList.isEmpty())
75  return 0;
76 
77  return itemList.first();
78 }
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282

◆ update()

void QmlJSDebugger::LiveRubberBandSelectionManipulator::update ( const QPointF updatePoint)

Properties

◆ m_beginFormEditorItem

QGraphicsItem* QmlJSDebugger::LiveRubberBandSelectionManipulator::m_beginFormEditorItem
private

Definition at line 90 of file liverubberbandselectionmanipulator.h.

Referenced by begin(), and select().

◆ m_beginPoint

QPointF QmlJSDebugger::LiveRubberBandSelectionManipulator::m_beginPoint
private

Definition at line 88 of file liverubberbandselectionmanipulator.h.

Referenced by begin(), beginPoint(), clear(), and update().

◆ m_editorView

QDeclarativeViewInspector* QmlJSDebugger::LiveRubberBandSelectionManipulator::m_editorView
private

Definition at line 89 of file liverubberbandselectionmanipulator.h.

Referenced by begin(), and select().

◆ m_isActive

bool QmlJSDebugger::LiveRubberBandSelectionManipulator::m_isActive
private

Definition at line 91 of file liverubberbandselectionmanipulator.h.

Referenced by begin(), clear(), end(), and isActive().

◆ m_itemList

QList<QGraphicsItem*> QmlJSDebugger::LiveRubberBandSelectionManipulator::m_itemList
private

Definition at line 85 of file liverubberbandselectionmanipulator.h.

Referenced by clear(), and setItems().

◆ m_oldSelectionList

QList<QGraphicsItem*> QmlJSDebugger::LiveRubberBandSelectionManipulator::m_oldSelectionList
private

Definition at line 86 of file liverubberbandselectionmanipulator.h.

Referenced by begin(), clear(), end(), and select().

◆ m_selectionRectangleElement

LiveSelectionRectangle QmlJSDebugger::LiveRubberBandSelectionManipulator::m_selectionRectangleElement
private

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