51 #include <QtDeclarative/QDeclarativeItem> 52 #include <QtGui/QWidget> 53 #include <QtGui/QMouseEvent> 54 #include <QtGui/QGraphicsObject> 81 data->view->installEventFilter(
this);
83 data->setViewport(
data->view->viewport());
104 foreach (
QObject *obj, objects) {
105 if (
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
106 items << declarativeItem;
107 gfxObjects << declarativeItem;
111 data->setSelectedItemsForTools(items);
112 data->clearHighlight();
113 data->highlight(gfxObjects);
119 data->clearHighlight();
127 data->changeToColorPickerTool();
130 data->changeToMarqueeSelectTool();
133 data->changeToSingleSelectTool();
136 data->changeToZoomTool();
148 return data->view->engine();
153 if (viewport.data() ==
widget)
157 viewport.data()->removeEventFilter(q);
163 viewport.data()->installEventFilter(q);
175 if (obj ==
data->view) {
179 if (
data->view->viewport() !=
data->viewport.data())
180 data->setViewport(
data->view->viewport());
190 data->clearHighlight();
211 object->setParent(newParent);
214 if (newParentItem && item)
221 if (
QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj))
233 currentSelection.removeOne(obj);
240 if (!currentSelection.contains(obj)) {
243 currentSelection.append(obj);
248 q->currentTool()->updateSelectedItems();
254 setSelectedItemsForTools(items);
255 if (oldList != currentSelection) {
259 objectList << graphicsObject.
data();
262 q->sendCurrentObjects(objectList);
270 if (selectedObject.
data())
271 selection << selectedObject.
data();
279 data->setSelectedItems(items);
284 return data->selectedItems();
294 boundingRectHighlighter->clear();
309 objectList << childObject;
313 boundingRectHighlighter->highlight(objectList);
320 return filterForSelection(itemlist);
326 return filterForSelection(itemlist);
333 return filterForSelection(itemlist);
338 selectionTool->setRubberbandSelectionMode(
false);
340 changeToSelectTool();
342 emit q->selectToolActivated();
348 if (q->currentTool() == selectionTool)
351 q->currentTool()->clear();
352 q->setCurrentTool(selectionTool);
353 q->currentTool()->clear();
354 q->currentTool()->updateSelectedItems();
359 changeToSelectTool();
360 selectionTool->setRubberbandSelectionMode(
true);
362 emit q->marqueeSelectToolActivated();
368 q->currentTool()->clear();
369 q->setCurrentTool(zoomTool);
370 q->currentTool()->clear();
372 emit q->zoomToolActivated();
378 if (q->currentTool() == colorPickerTool)
381 q->currentTool()->clear();
382 q->setCurrentTool(colorPickerTool);
383 q->currentTool()->clear();
385 emit q->colorPickerActivated();
417 int marginFromEdge = 1;
419 if (
qAbs(boundingRect.
left()) - 1 < 2)
420 boundingRect.
setLeft(marginFromEdge);
427 if (
qAbs(boundingRect.
top()) - 1 < 2)
428 boundingRect.
setTop(marginFromEdge);
The QColor class provides colors based on RGB, HSV or CMYK values.
AbstractTool * currentTool() const
void reparentQmlObject(QObject *object, QObject *newParent)
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
void setViewport(QWidget *widget)
void selectedColorChanged(const QColor &color)
QPointer< QWidget > widget
QDeclarativeView * declarativeView() const
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
The QDeclarativeView class provides a widget for displaying a Qt Declarative user interface...
QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent=0)
QScopedPointer< QDeclarativeViewInspectorPrivate > data
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
bool designModeBehavior() const
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
void changeTool(InspectorProtocol::Tool tool)
bool mouseMoveEvent(QMouseEvent *event)
void sendColorChanged(const QColor &color)
QList< QGraphicsItem * > selectedItems() const
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
bool leaveEvent(QEvent *)
static LibLoadStatus status
void setBottom(qreal pos)
Sets the bottom edge of the rectangle to the given y coordinate.
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
~QDeclarativeViewInspector()
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
QList< QGraphicsItem * > selectedItems() const
Q_DECL_CONSTEXPR T qAbs(const T &t)
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
static bool isEditorItem(QGraphicsItem *item)
static const QRectF boundingRect(const QPointF *points, int pointCount)
QGraphicsObject * toGraphicsObject()
Return the graphics item cast to a QGraphicsObject, if the class is actually a graphics object...
void setParentItem(QDeclarativeItem *parent)
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *)
void changeCurrentObjects(const QList< QObject *> &objects)
QList< QGraphicsItem * > filterForSelection(QList< QGraphicsItem *> &itemlist) const
The QRectF class defines a rectangle in the plane using floating point precision. ...
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
The QDeclarativeItem class provides the most basic of all visual items in QML.
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...
QVariant data(int key) const
Returns this item's custom data for the key key as a QVariant.
virtual int type() const
Returns the type of an item as an int.
virtual bool mouseMoveEvent(QMouseEvent *event)
static const char * data(const QByteArray &arr)
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
void changeToColorPickerTool()
virtual bool leaveEvent(QEvent *)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
QList< QGraphicsItem * > selectableItems(const QPoint &pos) const
The QMouseEvent class contains parameters that describe a mouse event.
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
T & first()
Returns a reference to the first item in the list.
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.
void setSelectedItems(QList< QGraphicsItem *> items)
void setSelectedItems(const QList< QGraphicsItem *> &items)
void setSelectedItemsForTools(const QList< QGraphicsItem *> &items)
int right() const
Returns the x-coordinate of the rectangle's right edge.
The QDeclarativeEngine class provides an environment for instantiating QML components.
QDeclarativeEngine * declarativeEngine() const
bool eventFilter(QObject *obj, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object...
~QDeclarativeViewInspectorPrivate()
QObject * parent() const
Returns a pointer to the parent object.
void _q_onStatusChanged(QDeclarativeView::Status status)
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
void _q_removeFromSelection(QObject *)
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
void highlight(const QList< QGraphicsObject *> &item)
AbstractLiveEditTool * currentTool() const
qreal bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
static const int EditorItemDataKey
void changeToSingleSelectTool()
Status
Specifies the loading status of the QDeclarativeView.
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.
void changeToSelectTool()
The QList class is a template class that provides lists.
void changeToMarqueeSelectTool()
void setCurrentTool(AbstractTool *tool)