Qt 4.8
abstractviewinspector.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef ABSTRACTVIEWINSPECTOR_H
43 #define ABSTRACTVIEWINSPECTOR_H
44 
45 #include <QtCore/QHash>
46 #include <QtCore/QObject>
47 #include <QtCore/QStringList>
48 #include <QtGui/QColor>
49 
51 #include "qmlinspectorconstants.h"
52 
54 class QDeclarativeEngine;
56 class QKeyEvent;
57 class QMouseEvent;
58 class QWheelEvent;
60 
61 namespace QmlJSDebugger {
62 
63 class AbstractTool;
64 
65 /*
66  * The common code between QSGView and QDeclarativeView inspectors lives here,
67  */
69 {
70  Q_OBJECT
71 
72 public:
73  explicit AbstractViewInspector(QObject *parent = 0);
74 
75  virtual void changeCurrentObjects(const QList<QObject*> &objects) = 0;
76 
77  virtual void reloadView() = 0;
78 
79  void createQmlObject(const QString &qml, QObject *parent,
80  const QStringList &importList,
81  const QString &filename = QString());
82 
83  virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0;
84 
85  virtual void changeTool(InspectorProtocol::Tool tool) = 0;
86 
87  void clearComponentCache();
88 
89  virtual QWidget *viewWidget() const = 0;
90  virtual QDeclarativeEngine *declarativeEngine() const = 0;
91 
92 
93  bool showAppOnTop() const { return m_showAppOnTop; }
94  bool designModeBehavior() const { return m_designModeBehavior; }
95 
96  bool animationPaused() const { return m_animationPaused; }
98 
99  void sendCurrentObjects(const QList<QObject*> &);
101  void sendAnimationPaused(bool paused);
103  void sendReloaded();
104  void sendShowAppOnTop(bool showAppOnTop);
105 
106  QString idStringForObject(QObject *obj) const;
107 
108 public slots:
109  void sendDesignModeBehavior(bool inDesignMode);
110  void sendColorChanged(const QColor &color);
111 
113  void changeToZoomTool();
116 
117  virtual void setDesignModeBehavior(bool value);
118 
119  void setShowAppOnTop(bool appOnTop);
120 
121  void setAnimationSpeed(qreal factor);
122  void setAnimationPaused(bool paused);
123 
124 signals:
125  void designModeBehaviorChanged(bool inDesignMode);
126  void showAppOnTopChanged(bool showAppOnTop);
127  void reloadRequested();
129  void selectToolActivated();
130  void zoomToolActivated();
131  void colorPickerActivated();
132  void selectedColorChanged(const QColor &color);
133 
134  void animationSpeedChanged(qreal factor);
135  void animationPausedChanged(bool paused);
136 
137 protected:
138  bool eventFilter(QObject *, QEvent *);
139 
140  virtual bool leaveEvent(QEvent *);
141  virtual bool mousePressEvent(QMouseEvent *event);
142  virtual bool mouseMoveEvent(QMouseEvent *event);
143  virtual bool mouseReleaseEvent(QMouseEvent *event);
144  virtual bool keyPressEvent(QKeyEvent *event);
145  virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
146  virtual bool mouseDoubleClickEvent(QMouseEvent *event);
147  virtual bool wheelEvent(QWheelEvent *event);
148 
150  void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
151 
152 private slots:
153  void handleMessage(const QByteArray &message);
154 
155 private:
157  void animationPausedChangeRequested(bool paused);
158 
160 
163 
166 
169 };
170 
171 } // namespace QmlJSDebugger
172 
173 #endif // ABSTRACTVIEWINSPECTOR_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QKeyEvent class describes a key event.
Definition: qevent.h:224
double qreal
Definition: qglobal.h:1193
void selectedColorChanged(const QColor &color)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString idStringForObject(QObject *obj) const
static void keyEvent(KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
The QWheelEvent class contains parameters that describe a wheel event.
Definition: qevent.h:139
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
void animationPausedChanged(bool paused)
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 void reparentQmlObject(QObject *object, QObject *newParent)=0
virtual bool keyReleaseEvent(QKeyEvent *keyEvent)
virtual bool mousePressEvent(QMouseEvent *event)
void sendAnimationSpeed(qreal slowDownFactor)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void createQmlObject(const QString &qml, QObject *parent, const QStringList &importList, const QString &filename=QString())
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QDeclarativeInspectorService * m_debugService
virtual bool mouseMoveEvent(QMouseEvent *event)
virtual QWidget * viewWidget() const =0
void handleMessage(const QByteArray &message)
virtual bool keyPressEvent(QKeyEvent *event)
#define Q_OBJECT
Definition: qobjectdefs.h:157
virtual void changeCurrentObjects(const QList< QObject *> &objects)=0
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual bool mouseDoubleClickEvent(QMouseEvent *event)
bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
void sendCurrentObjects(const QList< QObject *> &)
void designModeBehaviorChanged(bool inDesignMode)
virtual bool wheelEvent(QWheelEvent *event)
The QDeclarativeEngine class provides an environment for instantiating QML components.
void sendCurrentTool(Constants::DesignTool toolId)
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
virtual bool mouseReleaseEvent(QMouseEvent *event)
virtual QDeclarativeEngine * declarativeEngine() const =0
void showAppOnTopChanged(bool showAppOnTop)
virtual void changeTool(InspectorProtocol::Tool tool)=0
#define slots
Definition: qobjectdefs.h:68
#define signals
Definition: qobjectdefs.h:69
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
void animationSpeedChanged(qreal factor)
The QList class is a template class that provides lists.
Definition: qdatastream.h:62