Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / plugins / qmltooling / shared / abstractviewinspector.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
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
50 #include "qdeclarativeinspectorprotocol.h"
51 #include "qmlinspectorconstants.h"
52
53 QT_BEGIN_NAMESPACE
54 class QDeclarativeEngine;
55 class QDeclarativeInspectorService;
56 class QKeyEvent;
57 class QMouseEvent;
58 class QWheelEvent;
59 QT_END_NAMESPACE
60
61 namespace QmlJSDebugger {
62
63 class AbstractTool;
64
65 /*
66  * The common code between QQuickView and QDeclarativeView inspectors lives here,
67  */
68 class AbstractViewInspector : public QObject
69 {
70     Q_OBJECT
71
72 public:
73     explicit AbstractViewInspector(QObject *parent = 0);
74
75     void handleMessage(const QByteArray &message);
76
77     void createQmlObject(const QString &qml, QObject *parent,
78                          const QStringList &importList,
79                          const QString &filename = QString());
80     void clearComponentCache();
81
82     bool showAppOnTop() const { return m_showAppOnTop; }
83     bool designModeBehavior() const { return m_designModeBehavior; }
84
85     bool animationPaused() const { return m_animationPaused; }
86     qreal slowDownFactor() const { return m_slowDownFactor; }
87
88     void sendCurrentObjects(const QList<QObject*> &);
89     void sendAnimationSpeed(qreal slowDownFactor);
90     void sendAnimationPaused(bool paused);
91     void sendCurrentTool(Constants::DesignTool toolId);
92     void sendReloaded();
93     void sendShowAppOnTop(bool showAppOnTop);
94
95     QString idStringForObject(QObject *obj) const;
96
97     virtual void changeCurrentObjects(const QList<QObject*> &objects) = 0;
98     virtual void reloadView() = 0;
99     virtual void reparentQmlObject(QObject *object, QObject *newParent) = 0;
100     virtual void changeTool(InspectorProtocol::Tool tool) = 0;
101     virtual Qt::WindowFlags windowFlags() const = 0;
102     virtual void setWindowFlags(Qt::WindowFlags flags) = 0;
103     virtual QDeclarativeEngine *declarativeEngine() const = 0;
104
105 signals:
106     void designModeBehaviorChanged(bool inDesignMode);
107     void showAppOnTopChanged(bool showAppOnTop);
108     void reloadRequested();
109     void marqueeSelectToolActivated();
110     void selectToolActivated();
111     void zoomToolActivated();
112     void colorPickerActivated();
113     void selectedColorChanged(const QColor &color);
114
115     void animationSpeedChanged(qreal factor);
116     void animationPausedChanged(bool paused);
117
118 protected:
119     AbstractTool *currentTool() const { return m_currentTool; }
120     void setCurrentTool(AbstractTool *tool) { m_currentTool = tool; }
121     bool eventFilter(QObject *, QEvent *);
122
123     virtual bool leaveEvent(QEvent *);
124     virtual bool mousePressEvent(QMouseEvent *event);
125     virtual bool mouseMoveEvent(QMouseEvent *event);
126     virtual bool mouseReleaseEvent(QMouseEvent *event);
127     virtual bool keyPressEvent(QKeyEvent *event);
128     virtual bool keyReleaseEvent(QKeyEvent *keyEvent);
129     virtual bool mouseDoubleClickEvent(QMouseEvent *event);
130     virtual bool wheelEvent(QWheelEvent *event);
131
132 private slots:
133     void sendColorChanged(const QColor &color);
134
135 private:
136     void sendDesignModeBehavior(bool inDesignMode);
137
138     void changeToColorPickerTool();
139     void changeToZoomTool();
140     void changeToSingleSelectTool();
141     void changeToMarqueeSelectTool();
142
143     virtual void setDesignModeBehavior(bool value);
144
145     void setShowAppOnTop(bool appOnTop);
146
147     void setAnimationSpeed(qreal factor);
148     void setAnimationPaused(bool paused);
149
150     void animationSpeedChangeRequested(qreal factor);
151     void animationPausedChangeRequested(bool paused);
152
153     AbstractTool *m_currentTool;
154
155     bool m_showAppOnTop;
156     bool m_designModeBehavior;
157
158     bool m_animationPaused;
159     qreal m_slowDownFactor;
160
161     QHash<int, QString> m_stringIdForObjectId;
162     QDeclarativeInspectorService *m_debugService;
163 };
164
165 } // namespace QmlJSDebugger
166
167 #endif // ABSTRACTVIEWINSPECTOR_H