Qt 4.8
Public Functions | Protected Functions | Private Functions | Properties | Friends | List of all members
QmlJSDebugger::QDeclarativeViewInspector Class Reference

#include <qdeclarativeviewinspector.h>

Inheritance diagram for QmlJSDebugger::QDeclarativeViewInspector:
QmlJSDebugger::AbstractViewInspector QObject

Public Functions

QRectF adjustToScreenBoundaries (const QRectF &boundingRectInSceneSpace)
 
void changeCurrentObjects (const QList< QObject *> &objects)
 
void changeTool (InspectorProtocol::Tool tool)
 
QDeclarativeEnginedeclarativeEngine () const
 
QDeclarativeViewdeclarativeView () const
 
 QDeclarativeViewInspector (QDeclarativeView *view, QObject *parent=0)
 
void reloadView ()
 
void reparentQmlObject (QObject *object, QObject *newParent)
 
QList< QGraphicsItem * > selectedItems () const
 
void setSelectedItems (QList< QGraphicsItem *> items)
 
QWidgetviewWidget () const
 
 ~QDeclarativeViewInspector ()
 
- Public Functions inherited from QmlJSDebugger::AbstractViewInspector
 AbstractViewInspector (QObject *parent=0)
 
bool animationPaused () const
 
void clearComponentCache ()
 
void createQmlObject (const QString &qml, QObject *parent, const QStringList &importList, const QString &filename=QString())
 
bool designModeBehavior () const
 
QString idStringForObject (QObject *obj) const
 
void sendAnimationPaused (bool paused)
 
void sendAnimationSpeed (qreal slowDownFactor)
 
void sendCurrentObjects (const QList< QObject *> &)
 
void sendCurrentTool (Constants::DesignTool toolId)
 
void sendReloaded ()
 
void sendShowAppOnTop (bool showAppOnTop)
 
bool showAppOnTop () const
 
qreal slowDownFactor () 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...
 
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

AbstractLiveEditToolcurrentTool () const
 
bool eventFilter (QObject *obj, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
bool leaveEvent (QEvent *)
 
bool mouseMoveEvent (QMouseEvent *event)
 
- Protected Functions inherited from QmlJSDebugger::AbstractViewInspector
AbstractToolcurrentTool () const
 
virtual bool keyPressEvent (QKeyEvent *event)
 
virtual bool keyReleaseEvent (QKeyEvent *keyEvent)
 
virtual bool mouseDoubleClickEvent (QMouseEvent *event)
 
virtual bool mousePressEvent (QMouseEvent *event)
 
virtual bool mouseReleaseEvent (QMouseEvent *event)
 
void setCurrentTool (AbstractTool *tool)
 
virtual bool wheelEvent (QWheelEvent *event)
 
- 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 Functions

QDeclarativeViewInspectorPrivated_func ()
 

Properties

QScopedPointer< QDeclarativeViewInspectorPrivatedata
 

Friends

class AbstractLiveEditTool
 
class QDeclarativeViewInspectorPrivate
 

Additional Inherited Members

- Public Slots inherited from QmlJSDebugger::AbstractViewInspector
void changeToColorPickerTool ()
 
void changeToMarqueeSelectTool ()
 
void changeToSingleSelectTool ()
 
void changeToZoomTool ()
 
void sendColorChanged (const QColor &color)
 
void sendDesignModeBehavior (bool inDesignMode)
 
void setAnimationPaused (bool paused)
 
void setAnimationSpeed (qreal factor)
 
virtual void setDesignModeBehavior (bool value)
 
void setShowAppOnTop (bool appOnTop)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QmlJSDebugger::AbstractViewInspector
void animationPausedChanged (bool paused)
 
void animationSpeedChanged (qreal factor)
 
void colorPickerActivated ()
 
void designModeBehaviorChanged (bool inDesignMode)
 
void marqueeSelectToolActivated ()
 
void reloadRequested ()
 
void selectedColorChanged (const QColor &color)
 
void selectToolActivated ()
 
void showAppOnTopChanged (bool showAppOnTop)
 
void zoomToolActivated ()
 
- 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 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 58 of file qdeclarativeviewinspector.h.

Constructors and Destructors

◆ QDeclarativeViewInspector()

QmlJSDebugger::QDeclarativeViewInspector::QDeclarativeViewInspector ( QDeclarativeView view,
QObject parent = 0 
)
explicit

Definition at line 67 of file qdeclarativeviewinspector.cpp.

68  :
69  AbstractViewInspector(parent),
71 {
72  data->view = view;
73  data->manipulatorLayer = new LiveLayerItem(view->scene());
74  data->selectionTool = new LiveSelectionTool(this);
75  data->zoomTool = new ZoomTool(this);
76  data->colorPickerTool = new ColorPickerTool(this);
77  data->boundingRectHighlighter = new BoundingRectHighlighter(this);
78  setCurrentTool(data->selectionTool);
79 
80  // to capture ChildRemoved event when viewport changes
81  data->view->installEventFilter(this);
82 
83  data->setViewport(data->view->viewport());
84 
85  connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
86  data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
87 
88  connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
90  connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
91  this, SLOT(sendColorChanged(QColor)));
92 
94 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
void selectedColorChanged(const QColor &color)
QScopedPointer< QDeclarativeViewInspectorPrivate > data
#define SLOT(a)
Definition: qobjectdefs.h:226
void changeTool(InspectorProtocol::Tool tool)
#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
Status
Specifies the loading status of the QDeclarativeView.
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.

◆ ~QDeclarativeViewInspector()

QmlJSDebugger::QDeclarativeViewInspector::~QDeclarativeViewInspector ( )

Definition at line 96 of file qdeclarativeviewinspector.cpp.

97 {
98 }

Functions

◆ adjustToScreenBoundaries()

QRectF QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries ( const QRectF boundingRectInSceneSpace)

Definition at line 415 of file qdeclarativeviewinspector.cpp.

Referenced by QmlJSDebugger::BoundingRectHighlighter::highlightAll(), QmlJSDebugger::LiveSelectionIndicator::setItems(), and viewWidget().

416 {
417  int marginFromEdge = 1;
418  QRectF boundingRect(boundingRectInSceneSpace);
419  if (qAbs(boundingRect.left()) - 1 < 2)
420  boundingRect.setLeft(marginFromEdge);
421 
422  QRect rect = data->view->rect();
423 
424  if (boundingRect.right() >= rect.right())
425  boundingRect.setRight(rect.right() - marginFromEdge);
426 
427  if (qAbs(boundingRect.top()) - 1 < 2)
428  boundingRect.setTop(marginFromEdge);
429 
430  if (boundingRect.bottom() >= rect.bottom())
431  boundingRect.setBottom(rect.bottom() - marginFromEdge);
432 
433  return boundingRect;
434 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
QScopedPointer< QDeclarativeViewInspectorPrivate > data
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:674
void setBottom(qreal pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:676
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:672
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
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528

◆ changeCurrentObjects()

void QmlJSDebugger::QDeclarativeViewInspector::changeCurrentObjects ( const QList< QObject *> &  objects)
virtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 100 of file qdeclarativeviewinspector.cpp.

101 {
102  QList<QGraphicsItem*> items;
103  QList<QGraphicsObject*> gfxObjects;
104  foreach (QObject *obj, objects) {
105  if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
106  items << declarativeItem;
107  gfxObjects << declarativeItem;
108  }
109  }
110  if (designModeBehavior()) {
111  data->setSelectedItemsForTools(items);
112  data->clearHighlight();
113  data->highlight(gfxObjects);
114  }
115 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
The QDeclarativeItem class provides the most basic of all visual items in QML.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ changeTool()

void QmlJSDebugger::QDeclarativeViewInspector::changeTool ( InspectorProtocol::Tool  tool)
virtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 123 of file qdeclarativeviewinspector.cpp.

Referenced by QDeclarativeViewInspector().

124 {
125  switch (tool) {
127  data->changeToColorPickerTool();
128  break;
130  data->changeToMarqueeSelectTool();
131  break;
133  data->changeToSingleSelectTool();
134  break;
136  data->changeToZoomTool();
137  break;
138  }
139 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data

◆ currentTool()

AbstractLiveEditTool * QmlJSDebugger::QDeclarativeViewInspector::currentTool ( ) const
protected

Definition at line 141 of file qdeclarativeviewinspector.cpp.

Referenced by mouseMoveEvent(), and viewWidget().

◆ d_func()

QDeclarativeViewInspectorPrivate* QmlJSDebugger::QDeclarativeViewInspector::d_func ( )
inlineprivate

Definition at line 92 of file qdeclarativeviewinspector.h.

92 { return data.data(); }
QScopedPointer< QDeclarativeViewInspectorPrivate > data

◆ declarativeEngine()

QDeclarativeEngine * QmlJSDebugger::QDeclarativeViewInspector::declarativeEngine ( ) const
virtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 146 of file qdeclarativeviewinspector.cpp.

Referenced by viewWidget().

147 {
148  return data->view->engine();
149 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data

◆ declarativeView()

QDeclarativeView * QmlJSDebugger::QDeclarativeViewInspector::declarativeView ( ) const

◆ eventFilter()

bool QmlJSDebugger::QDeclarativeViewInspector::eventFilter ( QObject ,
QEvent  
)
protectedvirtual

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also
installEventFilter()

Reimplemented from QmlJSDebugger::AbstractViewInspector.

Definition at line 173 of file qdeclarativeviewinspector.cpp.

Referenced by viewWidget().

174 {
175  if (obj == data->view) {
176  // Event from view
177  if (event->type() == QEvent::ChildRemoved) {
178  // Might mean that viewport has changed
179  if (data->view->viewport() != data->viewport.data())
180  data->setViewport(data->view->viewport());
181  }
182  return QObject::eventFilter(obj, event);
183  }
184 
186 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data
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
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
Definition: qobject.cpp:1375
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...

◆ leaveEvent()

bool QmlJSDebugger::QDeclarativeViewInspector::leaveEvent ( QEvent event)
protectedvirtual

Reimplemented from QmlJSDebugger::AbstractViewInspector.

Definition at line 188 of file qdeclarativeviewinspector.cpp.

Referenced by viewWidget().

189 {
190  data->clearHighlight();
191  return AbstractViewInspector::leaveEvent(event);
192 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data

◆ mouseMoveEvent()

bool QmlJSDebugger::QDeclarativeViewInspector::mouseMoveEvent ( QMouseEvent event)
protectedvirtual

Reimplemented from QmlJSDebugger::AbstractViewInspector.

Definition at line 194 of file qdeclarativeviewinspector.cpp.

Referenced by viewWidget().

195 {
196  QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
197  if (!selItems.isEmpty()) {
198  declarativeView()->setToolTip(currentTool()->titleForItem(selItems.first()));
199  } else {
201  }
202 
204 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data
The QString class provides a Unicode character string.
Definition: qstring.h:83
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
virtual bool mouseMoveEvent(QMouseEvent *event)
void setToolTip(const QString &)
Definition: qwidget.cpp:11600
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ reloadView()

void QmlJSDebugger::QDeclarativeViewInspector::reloadView ( )
virtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 117 of file qdeclarativeviewinspector.cpp.

118 {
119  data->clearHighlight();
121 }
QScopedPointer< QDeclarativeViewInspectorPrivate > data
#define emit
Definition: qobjectdefs.h:76

◆ reparentQmlObject()

void QmlJSDebugger::QDeclarativeViewInspector::reparentQmlObject ( QObject object,
QObject newParent 
)
virtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 206 of file qdeclarativeviewinspector.cpp.

207 {
208  if (!newParent)
209  return;
210 
211  object->setParent(newParent);
212  QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent);
214  if (newParentItem && item)
215  item->setParentItem(newParentItem);
216 }
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void setParentItem(QDeclarativeItem *parent)
The QDeclarativeItem class provides the most basic of all visual items in QML.

◆ selectedItems()

QList< QGraphicsItem * > QmlJSDebugger::QDeclarativeViewInspector::selectedItems ( ) const

◆ setSelectedItems()

void QmlJSDebugger::QDeclarativeViewInspector::setSelectedItems ( QList< QGraphicsItem *>  items)

◆ viewWidget()

QWidget* QmlJSDebugger::QDeclarativeViewInspector::viewWidget ( ) const
inlinevirtual

Implements QmlJSDebugger::AbstractViewInspector.

Definition at line 71 of file qdeclarativeviewinspector.h.

71 { return declarativeView(); }

Friends and Related Functions

◆ AbstractLiveEditTool

friend class AbstractLiveEditTool
friend

Definition at line 95 of file qdeclarativeviewinspector.h.

◆ QDeclarativeViewInspectorPrivate

Definition at line 94 of file qdeclarativeviewinspector.h.

Properties

◆ data

QScopedPointer<QDeclarativeViewInspectorPrivate> QmlJSDebugger::QDeclarativeViewInspector::data
private

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