summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Hartmann <Thomas.Hartmann@digia.com>2013-09-16 14:33:07 +0200
committerThomas Hartmann <Thomas.Hartmann@digia.com>2013-09-16 14:35:53 +0200
commit9e58ab2ac88c9beae06b7ef371b32c8bb5a54b0b (patch)
tree778f8f966a6a0ef41bbee602b4775730ea41c5b2 /src
parent8e281fe27bbdc004017b5ebaba647ba0e2d467c4 (diff)
downloadqt-creator-9e58ab2ac88c9beae06b7ef371b32c8bb5a54b0b.tar.gz
QmlProfiler: Initial conversion from Quick 1 to Quick 2
Updated class names and functions. Fixed imports. Change-Id: I5f12e3a108a0e60c091acc9c415ff77e52118029 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/plugins.pro8
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp24
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h17
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp14
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h14
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp12
-rw-r--r--src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h14
-rw-r--r--src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp6
-rw-r--r--src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h6
-rw-r--r--src/plugins/qmlprofiler/qml/Detail.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/Label.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/MainView.qml4
-rw-r--r--src/plugins/qmlprofiler/qml/Overview.qml4
-rw-r--r--src/plugins/qmlprofiler/qml/RangeDetails.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/RangeMover.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/SelectionRange.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/TimeDisplay.qml2
-rw-r--r--src/plugins/qmlprofiler/qml/TimeMarks.qml2
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.pro2
-rw-r--r--src/plugins/qmlprofiler/qmlprofiler.qbs2
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertraceview.cpp88
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertraceview.h9
-rw-r--r--src/plugins/qmlprofiler/timelinerenderer.cpp21
-rw-r--r--src/plugins/qmlprofiler/timelinerenderer.h18
25 files changed, 143 insertions, 136 deletions
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index 95de5cf33c..73cf7b15e9 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -64,16 +64,18 @@ isEmpty(IDE_PACKAGE_MODE) {
contains(QT_CONFIG, declarative)|!isEmpty(QT.declarative.name) {
SUBDIRS += \
- qmlprojectmanager \
- qmlprofiler
+ qmlprojectmanager
greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 0) {
SUBDIRS += \
qmldesigner \
+ qmlprofiler \
welcome
} else {
warning("QmlDesigner plugin has been disabled.")
- warning("The plugin needs at least Qt 5.1.")
+ warning("QmlProfiler plugin has been disabled.")
+ warning("Welcome plugin has been disabled.")
+ warning("These plugins need at least Qt 5.1.")
}
} else {
warning("QmlProjectManager, QmlProfiler and QmlDesigner plugins have been disabled: The plugins require QtDeclarative")
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
index 70a849f39b..4611d7096b 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas.cpp
@@ -35,16 +35,14 @@
QT_BEGIN_NAMESPACE
-Canvas::Canvas(QDeclarativeItem *parent)
- : QDeclarativeItem(parent),
+Canvas::Canvas(QQuickPaintedItem *parent)
+ : QQuickPaintedItem(parent),
m_context(new Context2D(this)),
m_canvasWidth(0),
m_canvasHeight(0),
m_fillMode(Canvas::Stretch),
m_color(Qt::white)
{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
- setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
@@ -57,10 +55,10 @@ void Canvas::componentComplete()
connect(m_context, SIGNAL(changed()), this, SLOT(requestPaint()));
emit init();
- QDeclarativeItem::componentComplete();
+ QQuickItem::componentComplete();
}
-void Canvas::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
+void Canvas::paint(QPainter *painter)
{
m_context->setInPaint(true);
emit paint();
@@ -160,7 +158,7 @@ void Canvas::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometr
&& newGeometry.width() > 0 && newGeometry.height() > 0) {
m_context->setSize(width(), height());
}
- QDeclarativeItem::geometryChanged(newGeometry, oldGeometry);
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
}
void Canvas::setCanvasWidth(int newWidth)
@@ -219,24 +217,24 @@ CanvasImage *Canvas::toImage() const
return new CanvasImage(m_context->pixmap());
}
-void Canvas::setTimeout(const QScriptValue &handler, long timeout)
+void Canvas::setTimeout(const QJSValue &handler, long timeout)
{
- if (handler.isFunction())
+ if (handler.isCallable())
CanvasTimer::createTimer(this, handler, timeout, true);
}
-void Canvas::setInterval(const QScriptValue &handler, long interval)
+void Canvas::setInterval(const QJSValue &handler, long interval)
{
- if (handler.isFunction())
+ if (handler.isCallable())
CanvasTimer::createTimer(this, handler, interval, false);
}
-void Canvas::clearTimeout(const QScriptValue &handler)
+void Canvas::clearTimeout(const QJSValue &handler)
{
CanvasTimer::removeTimer(handler);
}
-void Canvas::clearInterval(const QScriptValue &handler)
+void Canvas::clearInterval(const QJSValue &handler)
{
CanvasTimer::removeTimer(handler);
}
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
index 429097d5b4..3f4fd8b0dd 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecanvas_p.h
@@ -30,15 +30,14 @@
#ifndef QDECLARATIVECANVAS_P_H
#define QDECLARATIVECANVAS_P_H
-#include <qdeclarativeitem.h>
+#include <QQuickPaintedItem>
#include "qdeclarativecontext2d_p.h"
#include "qdeclarativecanvastimer_p.h"
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
-class Canvas : public QDeclarativeItem
+class Canvas : public QQuickPaintedItem
{
Q_OBJECT
@@ -49,11 +48,11 @@ class Canvas : public QDeclarativeItem
Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged)
public:
- Canvas(QDeclarativeItem *parent = 0);
+ Canvas(QQuickPaintedItem *parent = 0);
enum FillMode { Stretch, PreserveAspectFit, PreserveAspectCrop, Tile, TileVertically, TileHorizontally };
- void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ void paint(QPainter *);
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
void setCanvasWidth(int newWidth);
int canvasWidth() {return m_canvasWidth;}
@@ -78,10 +77,10 @@ public Q_SLOTS:
bool save(const QString& filename) const;
// Timers
- void setInterval(const QScriptValue &handler, long timeout);
- void setTimeout(const QScriptValue &handler, long timeout);
- void clearInterval(const QScriptValue &handler);
- void clearTimeout(const QScriptValue &handler);
+ void setInterval(const QJSValue &handler, long timeout);
+ void setTimeout(const QJSValue &handler, long timeout);
+ void clearInterval(const QJSValue &handler);
+ void clearTimeout(const QJSValue &handler);
Q_SIGNALS:
void fillModeChanged();
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp
index 4d41aec983..8069fbbcb7 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer.cpp
@@ -29,28 +29,28 @@
#include "qdeclarativecanvastimer_p.h"
-#include <qscriptengine.h>
-#include <qscriptvalue.h>
+#include <QJSEngine>
+#include <QJSValue>
#include <qtimer.h>
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QList<CanvasTimer*> , activeTimers);
-CanvasTimer::CanvasTimer(QObject *parent, const QScriptValue &data)
+CanvasTimer::CanvasTimer(QObject *parent, const QJSValue &data)
: QTimer(parent), m_value(data)
{
}
void CanvasTimer::handleTimeout()
{
- Q_ASSERT(m_value.isFunction());
+ Q_ASSERT(m_value.isCallable());
m_value.call();
if (isSingleShot())
removeTimer(this);
}
-void CanvasTimer::createTimer(QObject *parent, const QScriptValue &val, long timeout, bool singleshot)
+void CanvasTimer::createTimer(QObject *parent, const QJSValue &val, long timeout, bool singleshot)
{
CanvasTimer *timer = new CanvasTimer(parent, val);
@@ -67,9 +67,9 @@ void CanvasTimer::removeTimer(CanvasTimer *timer)
timer->deleteLater();
}
-void CanvasTimer::removeTimer(const QScriptValue &val)
+void CanvasTimer::removeTimer(const QJSValue &val)
{
- if (!val.isFunction())
+ if (!val.isCallable())
return;
for (int i = 0 ; i < activeTimers()->count() ; ++i) {
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h b/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h
index 915afa542d..b25a98eb44 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecanvastimer_p.h
@@ -30,32 +30,30 @@
#ifndef QDECLARATIVECANVASTIMER_P_H
#define QDECLARATIVECANVASTIMER_P_H
-#include <qscriptvalue.h>
+#include <QJSValue>
#include <qtimer.h>
#include <qlist.h>
QT_BEGIN_NAMESPACE
-QT_MODULE(Declarative)
-
class CanvasTimer : public QTimer
{
Q_OBJECT
public:
- CanvasTimer(QObject *parent, const QScriptValue &data);
+ CanvasTimer(QObject *parent, const QJSValue &data);
public Q_SLOTS:
void handleTimeout();
- bool equals(const QScriptValue &value){return m_value.equals(value);}
+ bool equals(const QJSValue &value){return m_value.equals(value);}
public:
- static void createTimer(QObject *parent, const QScriptValue &val, long timeout, bool singleshot);
+ static void createTimer(QObject *parent, const QJSValue &val, long timeout, bool singleshot);
static void removeTimer(CanvasTimer *timer);
- static void removeTimer(const QScriptValue &);
+ static void removeTimer(const QJSValue &);
private:
- QScriptValue m_value;
+ QJSValue m_value;
};
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
index 5121aac332..be092b12ad 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d.cpp
@@ -39,6 +39,7 @@
#include <qgraphicseffect.h>
#include <QImage>
+#include <QWidget>
QT_BEGIN_NAMESPACE
@@ -737,8 +738,8 @@ void Context2D::strokeRect(qreal x, qreal y, qreal w, qreal h)
scheduleChange();
}
-void Context2D::mouseArea(qreal x, qreal y, qreal w, qreal h, const QScriptValue &callback,
- const QScriptValue &data)
+void Context2D::mouseArea(qreal x, qreal y, qreal w, qreal h, const QJSValue &callback,
+ const QJSValue &data)
{
MouseArea a = { callback, data, QRectF(x, y, w, h), m_state.matrix };
m_mouseAreas << a;
@@ -1104,8 +1105,13 @@ void Context2D::setPainterTranslate(const QPoint &translate)
void Context2D::scheduleChange()
{
+ QMetaObject::invokeMethod(this, "onScheduleChange", Qt::QueuedConnection, Q_ARG(int, 0));
+}
+
+void Context2D::onScheduleChange(int interval)
+{
if (m_changeTimerId == -1 && !m_inPaint)
- m_changeTimerId = startTimer(0);
+ m_changeTimerId = startTimer(interval);
}
void Context2D::timerEvent(QTimerEvent *e)
diff --git a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
index 7183875768..cd84e1fa2b 100644
--- a/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
+++ b/src/plugins/qmlprofiler/canvas/qdeclarativecontext2d_p.h
@@ -38,11 +38,10 @@
#include <qmetatype.h>
#include <qcoreevent.h>
#include <qvariant.h>
-#include <qscriptvalue.h>
-QT_BEGIN_NAMESPACE
+#include <QJSValue>
-QT_MODULE(Declarative)
+QT_BEGIN_NAMESPACE
QColor colorFromString(const QString &name);
@@ -174,8 +173,8 @@ public:
void setShadowColor(const QString &str);
struct MouseArea {
- QScriptValue callback;
- QScriptValue data;
+ QJSValue callback;
+ QJSValue data;
QRectF rect;
QMatrix matrix;
};
@@ -209,7 +208,7 @@ public slots:
void strokeRect(qreal x, qreal y, qreal w, qreal h);
// mouse
- void mouseArea(qreal x, qreal y, qreal w, qreal h, const QScriptValue &, const QScriptValue & = QScriptValue());
+ void mouseArea(qreal x, qreal y, qreal w, qreal h, const QJSValue &, const QJSValue & = QJSValue());
// path API
void beginPath();
@@ -239,6 +238,9 @@ public slots:
void putImageData(ImageData image, qreal dx, qreal dy);
void endPainting();
+private slots:
+ void onScheduleChange(int interval);
+
signals:
void changed();
diff --git a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp b/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
index 01e3b3cdda..e078680863 100644
--- a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
+++ b/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.cpp
@@ -41,9 +41,7 @@ QmlProfilerCanvas::QmlProfilerCanvas()
: m_context2d(new Context2D(this))
, m_dirty(true)
{
- setFlag(QGraphicsItem::ItemHasNoContents, false);
setAcceptedMouseButtons(Qt::LeftButton);
- setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
void QmlProfilerCanvas::requestPaint()
@@ -57,7 +55,7 @@ void QmlProfilerCanvas::requestRedraw()
update();
}
-void QmlProfilerCanvas::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+void QmlProfilerCanvas::paint(QPainter *p)
{
if (m_context2d->size().width() != width() || m_context2d->size().height() != height()) {
m_dirty = true;
@@ -84,7 +82,7 @@ void QmlProfilerCanvas::componentComplete()
if (p.hasNotifySignal())
QMetaObject::connect(this, p.notifySignalIndex(), this, requestPaintMethod, 0, 0);
}
- QDeclarativeItem::componentComplete();
+ QQuickItem::componentComplete();
}
}
diff --git a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h b/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h
index 51289d8b96..f7837f2ed0 100644
--- a/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h
+++ b/src/plugins/qmlprofiler/canvas/qmlprofilercanvas.h
@@ -30,7 +30,7 @@
#ifndef QMLPROFILERCANVAS_H
#define QMLPROFILERCANVAS_H
-#include <QDeclarativeItem>
+#include <QQuickPaintedItem>
QT_BEGIN_NAMESPACE
class Context2D;
@@ -39,7 +39,7 @@ QT_END_NAMESPACE
namespace QmlProfiler {
namespace Internal {
-class QmlProfilerCanvas : public QDeclarativeItem
+class QmlProfilerCanvas : public QQuickPaintedItem
{
Q_OBJECT
@@ -67,7 +67,7 @@ public slots:
void requestRedraw();
protected:
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ virtual void paint(QPainter *);
virtual void componentComplete();
private:
diff --git a/src/plugins/qmlprofiler/qml/Detail.qml b/src/plugins/qmlprofiler/qml/Detail.qml
index 7bc28178d9..6eab0bbc3d 100644
--- a/src/plugins/qmlprofiler/qml/Detail.qml
+++ b/src/plugins/qmlprofiler/qml/Detail.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Item {
diff --git a/src/plugins/qmlprofiler/qml/Label.qml b/src/plugins/qmlprofiler/qml/Label.qml
index 015391a3f5..608bb53f76 100644
--- a/src/plugins/qmlprofiler/qml/Label.qml
+++ b/src/plugins/qmlprofiler/qml/Label.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Item {
id: labelContainer
diff --git a/src/plugins/qmlprofiler/qml/MainView.qml b/src/plugins/qmlprofiler/qml/MainView.qml
index 9e859258ee..0cdb3b81ea 100644
--- a/src/plugins/qmlprofiler/qml/MainView.qml
+++ b/src/plugins/qmlprofiler/qml/MainView.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Rectangle {
@@ -502,7 +502,7 @@ Rectangle {
onPressed: {
selectionRange.pressedOnCreation();
}
- onMousePositionChanged: {
+ onPositionChanged: {
selectionRange.movedOnCreation();
}
}
diff --git a/src/plugins/qmlprofiler/qml/Overview.qml b/src/plugins/qmlprofiler/qml/Overview.qml
index d90e1e6c7d..42bc387e19 100644
--- a/src/plugins/qmlprofiler/qml/Overview.qml
+++ b/src/plugins/qmlprofiler/qml/Overview.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
import "Overview.js" as Plotter
@@ -108,7 +108,7 @@ Canvas2D {
onPressed: {
jumpTo(mouse.x);
}
- onMousePositionChanged: {
+ onPositionChanged: {
jumpTo(mouse.x);
}
}
diff --git a/src/plugins/qmlprofiler/qml/RangeDetails.qml b/src/plugins/qmlprofiler/qml/RangeDetails.qml
index a0fb3e8d77..dae4db3818 100644
--- a/src/plugins/qmlprofiler/qml/RangeDetails.qml
+++ b/src/plugins/qmlprofiler/qml/RangeDetails.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Item {
diff --git a/src/plugins/qmlprofiler/qml/RangeMover.qml b/src/plugins/qmlprofiler/qml/RangeMover.qml
index 18226d8d25..4e1fa4290c 100644
--- a/src/plugins/qmlprofiler/qml/RangeMover.qml
+++ b/src/plugins/qmlprofiler/qml/RangeMover.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Rectangle {
id: rangeMover
diff --git a/src/plugins/qmlprofiler/qml/SelectionRange.qml b/src/plugins/qmlprofiler/qml/SelectionRange.qml
index b302de614a..6079b07135 100644
--- a/src/plugins/qmlprofiler/qml/SelectionRange.qml
+++ b/src/plugins/qmlprofiler/qml/SelectionRange.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
Rectangle {
id: selectionRange
diff --git a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
index 5af24af14d..529bf3b980 100644
--- a/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
+++ b/src/plugins/qmlprofiler/qml/SelectionRangeDetails.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Item {
diff --git a/src/plugins/qmlprofiler/qml/TimeDisplay.qml b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
index 2f5a8bfaaf..dd6ece6083 100644
--- a/src/plugins/qmlprofiler/qml/TimeDisplay.qml
+++ b/src/plugins/qmlprofiler/qml/TimeDisplay.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Canvas2D {
diff --git a/src/plugins/qmlprofiler/qml/TimeMarks.qml b/src/plugins/qmlprofiler/qml/TimeMarks.qml
index f2ba65f66e..742bc09629 100644
--- a/src/plugins/qmlprofiler/qml/TimeMarks.qml
+++ b/src/plugins/qmlprofiler/qml/TimeMarks.qml
@@ -27,7 +27,7 @@
**
****************************************************************************/
-import QtQuick 1.0
+import QtQuick 2.0
import Monitor 1.0
Canvas2D {
diff --git a/src/plugins/qmlprofiler/qmlprofiler.pro b/src/plugins/qmlprofiler/qmlprofiler.pro
index c9f7ba7ed7..f5b68699d5 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.pro
+++ b/src/plugins/qmlprofiler/qmlprofiler.pro
@@ -1,6 +1,6 @@
DEFINES += QMLPROFILER_LIBRARY
-QT += network script declarative
+QT += network qml quick
include(../../qtcreatorplugin.pri)
include(canvas/canvas.pri)
diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs
index 82bf351cf8..48df39e062 100644
--- a/src/plugins/qmlprofiler/qmlprofiler.qbs
+++ b/src/plugins/qmlprofiler/qmlprofiler.qbs
@@ -5,7 +5,7 @@ import "../QtcPlugin.qbs" as QtcPlugin
QtcPlugin {
name: "QmlProfiler"
- Depends { name: "Qt"; submodules: ["widgets", "network", "script", "declarative"] }
+ Depends { name: "Qt"; submodules: ["widgets", "network", "qml", "quick"] }
Depends { name: "Core" }
Depends { name: "AnalyzerBase" }
Depends { name: "QmlProjectManager" }
diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
index c094a07f13..76874e9272 100644
--- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp
@@ -42,7 +42,7 @@
#include <utils/styledbar.h>
-#include <QDeclarativeContext>
+#include <QQmlContext>
#include <QToolButton>
#include <QEvent>
#include <QVBoxLayout>
@@ -50,6 +50,7 @@
#include <QScrollBar>
#include <QSlider>
#include <QMenu>
+#include <QQuickItem>
#include <math.h>
@@ -86,23 +87,22 @@ void ZoomControl::setRange(qint64 startTime, qint64 endTime)
}
/////////////////////////////////////////////////////////
-ScrollableDeclarativeView::ScrollableDeclarativeView(QWidget *parent)
- : QDeclarativeView(parent)
+ScrollableQuickView::ScrollableQuickView(QQuickView *parent)
+ : QQuickView(parent)
{
}
-ScrollableDeclarativeView::~ScrollableDeclarativeView()
+ScrollableQuickView::~ScrollableQuickView()
{
}
-void ScrollableDeclarativeView::scrollContentsBy(int dx, int dy)
+void ScrollableQuickView::scrollContentsBy(int /*dx*/, int dy)
{
// special workaround to track the scrollbar
if (rootObject()) {
int scrollY = rootObject()->property("scrollY").toInt();
rootObject()->setProperty("scrollY", QVariant(scrollY - dy));
}
- QDeclarativeView::scrollContentsBy(dx,dy);
}
/////////////////////////////////////////////////////////
@@ -110,6 +110,13 @@ class QmlProfilerTraceView::QmlProfilerTraceViewPrivate
{
public:
QmlProfilerTraceViewPrivate(QmlProfilerTraceView *qq) : q(qq) {}
+ ~QmlProfilerTraceViewPrivate()
+ {
+ delete m_mainView;
+ delete m_timebar;
+ delete m_overview;
+ }
+
QmlProfilerTraceView *q;
QmlProfilerStateManager *m_profilerState;
@@ -118,9 +125,9 @@ public:
QSize m_sizeHint;
- ScrollableDeclarativeView *m_mainView;
- QDeclarativeView *m_timebar;
- QDeclarativeView *m_overview;
+ ScrollableQuickView *m_mainView;
+ QQuickView *m_timebar;
+ QQuickView *m_overview;
QmlProfilerModelManager *m_modelManager;
TimelineModelAggregator *m_modelProxy;
@@ -145,40 +152,38 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
groupLayout->setContentsMargins(0, 0, 0, 0);
groupLayout->setSpacing(0);
- d->m_mainView = new ScrollableDeclarativeView(this);
- d->m_mainView->setResizeMode(QDeclarativeView::SizeViewToRootObject);
- d->m_mainView->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
- d->m_mainView->setBackgroundBrush(QBrush(Qt::white));
- d->m_mainView->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- d->m_mainView->setFocus();
+ d->m_mainView = new ScrollableQuickView();
+ d->m_mainView->setResizeMode(QQuickView::SizeViewToRootObject);
+ QWidget *mainViewContainer = QWidget::createWindowContainer(d->m_mainView);
MouseWheelResizer *resizer = new MouseWheelResizer(this);
connect(resizer,SIGNAL(mouseWheelMoved(int,int,int)), this, SLOT(mouseWheelMoved(int,int,int)));
- d->m_mainView->viewport()->installEventFilter(resizer);
QHBoxLayout *toolsLayout = new QHBoxLayout;
- d->m_timebar = new QDeclarativeView(this);
- d->m_timebar->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- d->m_timebar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- d->m_timebar->setFixedHeight(24);
+ d->m_timebar = new QQuickView();
+ d->m_timebar->setResizeMode(QQuickView::SizeRootObjectToView);
+ QWidget *timeBarContainer = QWidget::createWindowContainer(d->m_timebar);
+ timeBarContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ timeBarContainer->setFixedHeight(24);
- d->m_overview = new QDeclarativeView(this);
- d->m_overview->setResizeMode(QDeclarativeView::SizeRootObjectToView);
- d->m_overview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- d->m_overview->setMaximumHeight(50);
+ d->m_overview = new QQuickView();
+ d->m_overview->setResizeMode(QQuickView::SizeRootObjectToView);
+ QWidget *overviewContainer = QWidget::createWindowContainer(d->m_overview);
+ overviewContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ overviewContainer->setMaximumHeight(50);
d->m_zoomToolbar = createZoomToolbar();
d->m_zoomToolbar->move(0, d->m_timebar->height());
d->m_zoomToolbar->setVisible(false);
toolsLayout->addWidget(createToolbar());
- toolsLayout->addWidget(d->m_timebar);
+ toolsLayout->addWidget(timeBarContainer);
emit enableToolbar(false);
groupLayout->addLayout(toolsLayout);
- groupLayout->addWidget(d->m_mainView);
- groupLayout->addWidget(d->m_overview);
+ groupLayout->addWidget(mainViewContainer);
+ groupLayout->addWidget(overviewContainer);
setLayout(groupLayout);
@@ -224,7 +229,7 @@ void QmlProfilerTraceView::reset()
d->m_overview->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/Overview.qml")));
d->m_mainView->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/MainView.qml")));
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
rootObject->setProperty("width", QVariant(width()));
rootObject->setProperty("candidateHeight", QVariant(height() - d->m_timebar->height() - d->m_overview->height()));
@@ -345,7 +350,7 @@ QWidget *QmlProfilerTraceView::createZoomToolbar()
/////////////////////////////////////////////////////////
bool QmlProfilerTraceView::hasValidSelection() const
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
return rootObject->property("selectionRangeReady").toBool();
return false;
@@ -353,7 +358,7 @@ bool QmlProfilerTraceView::hasValidSelection() const
qint64 QmlProfilerTraceView::selectionStart() const
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
return rootObject->property("selectionRangeStart").toLongLong();
return 0;
@@ -361,7 +366,7 @@ qint64 QmlProfilerTraceView::selectionStart() const
qint64 QmlProfilerTraceView::selectionEnd() const
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
return rootObject->property("selectionRangeEnd").toLongLong();
return 0;
@@ -380,7 +385,7 @@ void QmlProfilerTraceView::clearDisplay()
void QmlProfilerTraceView::selectNextEventByHash(const QString &hash)
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
QMetaObject::invokeMethod(rootObject, "selectNextByHash",
@@ -392,7 +397,7 @@ void QmlProfilerTraceView::selectNextEventByLocation(const QString &filename, co
int eventId = d->m_modelProxy->getEventIdForLocation(filename, line, column);
if (eventId != -1) {
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
QMetaObject::invokeMethod(rootObject, "selectNextById",
Q_ARG(QVariant,QVariant(eventId)));
@@ -403,7 +408,7 @@ void QmlProfilerTraceView::selectNextEventByLocation(const QString &filename, co
// Goto source location
void QmlProfilerTraceView::updateCursorPosition()
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
emit gotoSourceLocation(rootObject->property("fileName").toString(),
rootObject->property("lineNumber").toInt(),
rootObject->property("columnNumber").toInt());
@@ -413,7 +418,7 @@ void QmlProfilerTraceView::updateCursorPosition()
// Toolbar buttons
void QmlProfilerTraceView::toggleRangeMode(bool active)
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
bool rangeMode = rootObject->property("selectionRangeMode").toBool();
if (active != rangeMode) {
if (active)
@@ -436,7 +441,7 @@ void QmlProfilerTraceView::updateRangeButton()
void QmlProfilerTraceView::toggleLockMode(bool active)
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
bool lockMode = !rootObject->property("selectionLocked").toBool();
if (active != lockMode) {
rootObject->setProperty("selectionLocked", QVariant(!active));
@@ -480,7 +485,7 @@ void QmlProfilerTraceView::updateRange()
void QmlProfilerTraceView::mouseWheelMoved(int mouseX, int mouseY, int wheelDelta)
{
Q_UNUSED(mouseY);
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject) {
QMetaObject::invokeMethod(rootObject, "wheelZoom",
Q_ARG(QVariant, QVariant(mouseX)),
@@ -493,15 +498,14 @@ void QmlProfilerTraceView::updateToolTip(const QString &text)
setToolTip(text);
}
-void QmlProfilerTraceView::updateVerticalScroll(int newPosition)
+void QmlProfilerTraceView::updateVerticalScroll(int /*newPosition*/)
{
- d->m_mainView->verticalScrollBar()->setValue(newPosition);
}
void QmlProfilerTraceView::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject) {
rootObject->setProperty("width", QVariant(event->size().width()));
int newHeight = event->size().height() - d->m_timebar->height() - d->m_overview->height();
@@ -560,14 +564,14 @@ void QmlProfilerTraceView::contextMenuEvent(QContextMenuEvent *ev)
// Tell QML the state of the profiler
void QmlProfilerTraceView::setRecording(bool recording)
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
rootObject->setProperty("recordingEnabled", QVariant(recording));
}
void QmlProfilerTraceView::setAppKilled()
{
- QGraphicsObject *rootObject = d->m_mainView->rootObject();
+ QQuickItem *rootObject = d->m_mainView->rootObject();
if (rootObject)
rootObject->setProperty("appKilled",QVariant(true));
}
diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h
index dd7d233ff0..985838f7aa 100644
--- a/src/plugins/qmlprofiler/qmlprofilertraceview.h
+++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h
@@ -30,7 +30,8 @@
#ifndef QMLPROFILERTRACEVIEW_H
#define QMLPROFILERTRACEVIEW_H
-#include <QDeclarativeView>
+#include <QQuickView>
+#include <QWidget>
namespace Analyzer {
class IAnalyzerTool;
@@ -74,12 +75,12 @@ private:
qint64 m_endTime;
};
-class ScrollableDeclarativeView : public QDeclarativeView
+class ScrollableQuickView : public QQuickView
{
Q_OBJECT
public:
- explicit ScrollableDeclarativeView(QWidget *parent = 0);
- ~ScrollableDeclarativeView();
+ explicit ScrollableQuickView(QQuickView *parent = 0);
+ ~ScrollableQuickView();
protected:
void scrollContentsBy(int dx, int dy);
};
diff --git a/src/plugins/qmlprofiler/timelinerenderer.cpp b/src/plugins/qmlprofiler/timelinerenderer.cpp
index 4f86f2cd9a..77d895cf24 100644
--- a/src/plugins/qmlprofiler/timelinerenderer.cpp
+++ b/src/plugins/qmlprofiler/timelinerenderer.cpp
@@ -29,8 +29,8 @@
#include "timelinerenderer.h"
-#include <qdeclarativecontext.h>
-#include <qdeclarativeproperty.h>
+#include <QQmlContext>
+#include <QQmlProperty>
#include <QTimer>
#include <QPixmap>
#include <QPainter>
@@ -43,13 +43,12 @@ using namespace QmlProfiler::Internal;
const int DefaultRowHeight = 30;
-TimelineRenderer::TimelineRenderer(QDeclarativeItem *parent) :
- QDeclarativeItem(parent), m_startTime(0), m_endTime(0), m_spacing(0),
+TimelineRenderer::TimelineRenderer(QQuickPaintedItem *parent) :
+ QQuickPaintedItem(parent), m_startTime(0), m_endTime(0), m_spacing(0),
m_lastStartTime(0), m_lastEndTime(0)
, m_profilerModelProxy(0)
{
clearData();
- setFlag(QGraphicsItem::ItemHasNoContents, false);
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptHoverEvents(true);
}
@@ -77,7 +76,7 @@ void TimelineRenderer::componentComplete()
if (p.hasNotifySignal())
QMetaObject::connect(this, p.notifySignalIndex(), this, requestPaintMethod, 0, 0);
}
- QDeclarativeItem::componentComplete();
+ QQuickItem::componentComplete();
}
void TimelineRenderer::requestPaint()
@@ -85,7 +84,7 @@ void TimelineRenderer::requestPaint()
update();
}
-void TimelineRenderer::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
+void TimelineRenderer::paint(QPainter *p)
{
qint64 windowDuration = m_endTime - m_startTime;
if (windowDuration <= 0)
@@ -260,7 +259,7 @@ int TimelineRenderer::modelFromPosition(int y)
return 0;
}
-void TimelineRenderer::mousePressEvent(QGraphicsSceneMouseEvent *event)
+void TimelineRenderer::mousePressEvent(QMouseEvent *event)
{
// special case: if there is a drag area below me, don't accept the
// events unless I'm actually clicking inside an item
@@ -271,19 +270,19 @@ void TimelineRenderer::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
-void TimelineRenderer::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+void TimelineRenderer::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event);
manageClicked();
}
-void TimelineRenderer::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+void TimelineRenderer::mouseMoveEvent(QMouseEvent *event)
{
event->setAccepted(false);
}
-void TimelineRenderer::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+void TimelineRenderer::hoverMoveEvent(QHoverEvent *event)
{
Q_UNUSED(event);
manageHovered(event->pos().x(), event->pos().y());
diff --git a/src/plugins/qmlprofiler/timelinerenderer.h b/src/plugins/qmlprofiler/timelinerenderer.h
index d4c70a4d9e..e5018565d7 100644
--- a/src/plugins/qmlprofiler/timelinerenderer.h
+++ b/src/plugins/qmlprofiler/timelinerenderer.h
@@ -30,15 +30,15 @@
#ifndef TIMELINERENDERER_H
#define TIMELINERENDERER_H
-#include <QDeclarativeItem>
-#include <QScriptValue>
+#include <QQuickPaintedItem>
+#include <QJSValue>
#include "qmlprofilertimelinemodelproxy.h"
#include "timelinemodelaggregator.h"
namespace QmlProfiler {
namespace Internal {
-class TimelineRenderer : public QDeclarativeItem
+class TimelineRenderer : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(qint64 startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
@@ -51,7 +51,7 @@ class TimelineRenderer : public QDeclarativeItem
Q_PROPERTY(int endDragArea READ endDragArea WRITE setEndDragArea NOTIFY endDragAreaChanged)
public:
- explicit TimelineRenderer(QDeclarativeItem *parent = 0);
+ explicit TimelineRenderer(QQuickPaintedItem *parent = 0);
qint64 startTime() const
{
@@ -176,12 +176,12 @@ public slots:
}
protected:
- virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+ virtual void paint(QPainter *);
virtual void componentComplete();
- virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void mousePressEvent(QMouseEvent *event);
+ virtual void mouseReleaseEvent(QMouseEvent *event);
+ virtual void mouseMoveEvent(QMouseEvent *event);
+ virtual void hoverMoveEvent(QHoverEvent *event);
private:
void drawItemsToPainter(QPainter *p, int modelIndex, int fromIndex, int toIndex);