Commit c40d9e9d authored by Ulf Hermann's avatar Ulf Hermann

Timeline: Create new library from contents of QmlProfiler

Change-Id: I964b2f149e237eb25a08600e8dab8968e8bc0cb9
Reviewed-by: default avatarKai Koehne <kai.koehne@theqtcompany.com>
parent acc4d1a4
......@@ -12,7 +12,8 @@ SUBDIRS = \
qmldebug \
qmleditorwidgets \
glsl \
ssh
ssh \
timeline
for(l, SUBDIRS) {
QTC_LIB_DEPENDS =
......
......@@ -13,6 +13,7 @@ Project {
"qmldebug/qmldebug.qbs",
"qtcreatorcdbext/qtcreatorcdbext.qbs",
"ssh/ssh.qbs",
"timeline/timeline.qbs",
"utils/process_stub.qbs",
"utils/process_ctrlc_stub.qbs",
"utils/utils.qbs",
......
The timeline library can be used to display timeline data, primarily for performance analysis. It
provides a comprehensive set of visual components as well as a set of models that can be extended to
hold custom timeline data. You can use all the provided QML to get a complete GUI similar to the QML
profiler or you can mix and match the QML components with your own.
Models
------
At the core of the timeline library is the TimelineModel. You can create multiple TimelineModels to
represent different categories of data. The TimelineModelAggregator class is then used to manage
those models. TimelineModels are expected to load their contents all at once and then only change if
you clear() and possibly reload them. To complement that, you can use the TimelineNotesModel. The
TimelineNotesModel is designed to hold less, but mutable, data that spans all TimelineModels in a
TimelineModelAggregator.
Views
-----
Expose the TimelineRenderer class to QML and add a TimelineModel to it to get a visualization of the
data in the model. TimelineRenderer will generally use the TimelineRenderPasses the TimelineModel
suggests. It contains a caching system for keeping different versions of the visualization,
depending on position and zoom level, so that the picture always stays sharp and numerical overflows
are avoided. To do that it needs a TimelineZoomControl which manages zooming and scrolling.
A simplified display for the contents of a TimelineModel, based on the same render passes as the
TimelineRenderer, can be found in TimelineOverviewRenderer. TimelineOverviewRenderer will squeeze
the data into a fixed height and only allow all the data to be displayed at once. It won't react to
zooming or scrolling and can easily be used for a more concise overview.
Various utilities are provided in the QML code. CategoryLabels can be used to provide a legend for
data rendered using a TimelineRenderer. TimeMarks provides colored bars that can be layered behind
a TimelineRenderer to make the rows easier to distinguish. TimeDisplay provides a legend for the
time spanned by a timeline.
......@@ -84,7 +84,7 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: "qrc:/qmlprofiler/ico_prev.png"
iconSource: "qrc:/timeline/ico_prev.png"
tooltip: qsTr("Jump to previous event.")
onClicked: buttons.jumpToPrev()
}
......@@ -95,7 +95,7 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: "qrc:/qmlprofiler/ico_next.png"
iconSource: "qrc:/timeline/ico_next.png"
tooltip: qsTr("Jump to next event.")
onClicked: buttons.jumpToNext()
}
......@@ -106,7 +106,7 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: "qrc:/qmlprofiler/ico_zoom.png"
iconSource: "qrc:/timeline/ico_zoom.png"
tooltip: qsTr("Show zoom slider.")
checkable: true
checked: false
......@@ -119,7 +119,7 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: "qrc:/qmlprofiler/ico_filter.png"
iconSource: "qrc:/timeline/ico_filter.png"
tooltip: qsTr("Filter Categories")
checkable: true
onCheckedChanged: buttons.filterMenuChanged()
......@@ -131,8 +131,8 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: checked ? "qrc:/qmlprofiler/ico_rangeselected.png" :
"qrc:/qmlprofiler/ico_rangeselection.png"
iconSource: checked ? "qrc:/timeline/ico_rangeselected.png" :
"qrc:/timeline/ico_rangeselection.png"
tooltip: qsTr("Select range.")
checkable: true
checked: false
......@@ -145,7 +145,7 @@ ToolBar {
anchors.bottom: parent.bottom
implicitWidth: buttonWidth
iconSource: "qrc:/qmlprofiler/ico_selectionmode.png"
iconSource: "qrc:/timeline/ico_selectionmode.png"
tooltip: qsTr("View event information on mouseover.")
checkable: true
checked: false
......
<RCC>
<qresource prefix="/timeline">
<file>Detail.qml</file>
<file>CategoryLabel.qml</file>
<file>MainView.qml</file>
<file>RangeDetails.qml</file>
<file>RangeMover.qml</file>
<file>TimeDisplay.qml</file>
<file>lock_closed.png</file>
<file>lock_open.png</file>
<file>ico_edit.png</file>
<file>TimeMarks.qml</file>
<file>Overview.qml</file>
<file>SelectionRange.qml</file>
<file>SelectionRangeDetails.qml</file>
<file>arrow_down.png</file>
<file>arrow_right.png</file>
<file>dialog_shadow.png</file>
<file>range_handle.png</file>
<file>ico_selectionmode.png</file>
<file>ico_zoom.png</file>
<file>ico_prev.png</file>
<file>ico_next.png</file>
<file>ico_rangeselection.png</file>
<file>ico_rangeselected.png</file>
<file>ico_note.png</file>
<file>ButtonsBar.qml</file>
<file>ico_filter.png</file>
<file>timelineitems.vert</file>
<file>timelineitems.frag</file>
<file>notes.vert</file>
<file>notes.frag</file>
<file>TimelineLabels.qml</file>
<file>TimelineContent.qml</file>
</qresource>
</RCC>
QT += qml quick
DEFINES += TIMELINE_LIBRARY
include(../../qtcreatorlibrary.pri)
SOURCES += \
$$PWD/timelinemodel.cpp \
$$PWD/timelinemodelaggregator.cpp \
$$PWD/timelinerenderer.cpp \
$$PWD/timelinezoomcontrol.cpp \
$$PWD/timelineitemsrenderpass.cpp \
$$PWD/timelineselectionrenderpass.cpp \
$$PWD/timelinenotesrenderpass.cpp \
$$PWD/timelinerenderpass.cpp \
$$PWD/timelinerenderstate.cpp \
$$PWD/timelinenotesmodel.cpp \
$$PWD/timelineabstractrenderer.cpp \
$$PWD/timelineoverviewrenderer.cpp
HEADERS += \
$$PWD/timeline_global.h \
$$PWD/timelinemodel.h \
$$PWD/timelinemodel_p.h \
$$PWD/timelinemodelaggregator.h \
$$PWD/timelinerenderer.h \
$$PWD/timelinezoomcontrol.h \
$$PWD/timelineitemsrenderpass.h \
$$PWD/timelineselectionrenderpass.h \
$$PWD/timelinenotesrenderpass.h \
$$PWD/timelinerenderpass.h \
$$PWD/timelinerenderstate.h \
$$PWD/timelinenotesmodel.h \
$$PWD/timelinenotesmodel_p.h \
$$PWD/timelinerenderer_p.h \
$$PWD/timelinerenderstate_p.h \
$$PWD/timelineabstractrenderer.h \
$$PWD/timelineabstractrenderer_p.h \
$$PWD/timelineoverviewrenderer_p.h \
$$PWD/timelineoverviewrenderer.h
RESOURCES += \
$$PWD/qml/timeline.qrc
DISTFILES += README
import qbs 1.0
import QtcLibrary
QtcLibrary {
name: "Timeline"
Depends { name: "Qt"; submodules: ["qml", "quick", "gui"] }
Depends { name: "Utils" }
Group {
name: "General"
files: [
"README",
"timelineabstractrenderer.cpp", "timelineabstractrenderer.h",
"timelineabstractrenderer_p.h",
"timelineitemsrenderpass.cpp", "timelineitemsrenderpass.h",
"timelinemodel.cpp", "timelinemodel.h", "timelinemodel_p.h",
"timelinemodelaggregator.cpp", "timelinemodelaggregator.h",
"timelinenotesmodel.cpp", "timelinenotesmodel.h", "timelinenotesmodel_p.h",
"timelinenotesrenderpass.cpp", "timelinenotesrenderpass.h",
"timelineoverviewrenderer.cpp", "timelineoverviewrenderer.h",
"timelineoverviewrenderer_p.h",
"timelinerenderer.cpp", "timelinerenderer.h", "timelinerenderer_p.h",
"timelinerenderpass.cpp", "timelinerenderpass.h",
"timelinerenderstate.cpp", "timelinerenderstate.h", "timelinerenderstate_p.h",
"timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h",
"timelinezoomcontrol.cpp", "timelinezoomcontrol.h"
]
}
Group {
name: "QML"
prefix: "qml/"
files: ["timeline.qrc"]
}
}
QTC_LIB_NAME = Timeline
QTC_LIB_DEPENDS = utils
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef TIMELINE_GLOBAL_H
#define TIMELINE_GLOBAL_H
#include <QtGlobal>
#if defined(TIMELINE_LIBRARY)
# define TIMELINE_EXPORT Q_DECL_EXPORT
#else
# define TIMELINE_EXPORT Q_DECL_IMPORT
#endif
#endif // TIMELINE_GLOBAL_H
......@@ -31,21 +31,21 @@
#ifndef TIMELINEABSTRACTRENDERER_H
#define TIMELINEABSTRACTRENDERER_H
#include <QQuickItem>
#include <QSGTransformNode>
#include <QQuickItem>
#include "timelinezoomcontrol.h"
#include "timelinemodel.h"
#include "timelinenotesmodel.h"
#include "timelinerenderpass.h"
#include <QQuickItem>
#include <QSGTransformNode>
#include <QQuickItem>
namespace Timeline {
class TimelineRenderPass;
class TimelineRenderState;
class TimelineAbstractRenderer : public QQuickItem
class TIMELINE_EXPORT TimelineAbstractRenderer : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(Timeline::TimelineModel *model READ model WRITE setModel NOTIFY modelChanged)
......
......@@ -372,9 +372,8 @@ private:
TimelineItemsMaterialShader::TimelineItemsMaterialShader()
: QSGMaterialShader()
{
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qmlprofiler/timelineitems.vert"));
setShaderSourceFile(QOpenGLShader::Fragment,
QStringLiteral(":/qmlprofiler/timelineitems.frag"));
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/timeline/timelineitems.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/timeline/timelineitems.frag"));
}
void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial,
......
......@@ -37,7 +37,7 @@
namespace Timeline {
class TimelineItemsRenderPass : public TimelineRenderPass
class TIMELINE_EXPORT TimelineItemsRenderPass : public TimelineRenderPass
{
public:
static const TimelineItemsRenderPass *instance();
......
......@@ -40,7 +40,7 @@
namespace Timeline {
/*!
\class QmlProfiler::TimelineModel
\class Timeline::TimelineModel
\brief The TimelineModel class provides a sorted model for timeline data.
The TimelineModel lets you keep range data sorted by both start and end times, so that
......
......@@ -31,17 +31,14 @@
#ifndef TIMELINEMODEL_H
#define TIMELINEMODEL_H
#include "qmlprofiler_global.h"
#include "qmlprofilermodelmanager.h"
#include "qmlprofilerdatamodel.h"
#include "timeline_global.h"
#include "timelinerenderpass.h"
#include <QVariant>
#include <QColor>
namespace Timeline {
class QMLPROFILER_EXPORT TimelineModel : public QObject
class TIMELINE_EXPORT TimelineModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int modelId READ modelId CONSTANT)
......
......@@ -35,7 +35,7 @@
namespace Timeline {
class QMLPROFILER_EXPORT TimelineModel::TimelineModelPrivate {
class TIMELINE_EXPORT TimelineModel::TimelineModelPrivate {
public:
static const int DefaultRowHeight = 30;
......
......@@ -30,10 +30,8 @@
#include "timelinemodelaggregator.h"
#include "qmlprofilerrangemodel.h"
#include "qmlprofileranimationsmodel.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilernotesmodel.h"
#include "timelinemodel.h"
#include "timelinenotesmodel.h"
#include <QStringList>
#include <QVariant>
......
......@@ -31,13 +31,12 @@
#ifndef TIMELINEMODELAGGREGATOR_H
#define TIMELINEMODELAGGREGATOR_H
#include "qmlprofilertimelinemodel.h"
#include "qmlprofilermodelmanager.h"
#include "timelinerenderer.h"
#include "timelinemodel.h"
#include "timelinenotesmodel.h"
namespace Timeline {
class TimelineModelAggregator : public QObject
class TIMELINE_EXPORT TimelineModelAggregator : public QObject
{
Q_OBJECT
Q_PROPERTY(int height READ height NOTIFY heightChanged)
......
......@@ -35,7 +35,7 @@
namespace Timeline {
class QMLPROFILER_EXPORT TimelineNotesModel : public QObject
class TIMELINE_EXPORT TimelineNotesModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY changed)
......
......@@ -30,7 +30,7 @@
#include "timelinenotesrenderpass.h"
#include "timelinerenderstate.h"
#include "qmlprofilernotesmodel.h"
#include "timelinenotesmodel.h"
namespace Timeline {
......@@ -222,8 +222,8 @@ private:
NotesMaterialShader::NotesMaterialShader()
: QSGMaterialShader()
{
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qmlprofiler/notes.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qmlprofiler/notes.frag"));
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/timeline/notes.vert"));
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/timeline/notes.frag"));
}
void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
......
......@@ -36,7 +36,7 @@
namespace Timeline {
class TimelineNotesRenderPass : public TimelineRenderPass
class TIMELINE_EXPORT TimelineNotesRenderPass : public TimelineRenderPass
{
public:
static const TimelineNotesRenderPass *instance();
......
......@@ -35,7 +35,7 @@
namespace Timeline {
class TimelineOverviewRenderer : public TimelineAbstractRenderer
class TIMELINE_EXPORT TimelineOverviewRenderer : public TimelineAbstractRenderer
{
public:
TimelineOverviewRenderer(QQuickItem *parent = 0);
......
......@@ -30,9 +30,8 @@
#include "timelinerenderer_p.h"
#include "timelinerenderpass.h"
#include "qmlprofilernotesmodel.h"
#include "timelinenotesmodel.h"
#include "timelineitemsrenderpass.h"
#include "qmlprofilerbindingloopsrenderpass.h"
#include "timelineselectionrenderpass.h"
#include "timelinenotesrenderpass.h"
......@@ -41,7 +40,6 @@
#include <QQmlProperty>
#include <QTimer>
#include <QPixmap>
#include <QGraphicsSceneMouseEvent>
#include <QVarLengthArray>
#include <QSGTransformNode>
#include <QSGSimpleRectNode>
......
......@@ -31,19 +31,20 @@
#ifndef TIMELINERENDERER_H
#define TIMELINERENDERER_H
#include <QSGTransformNode>
#include <QQuickItem>
#include "timelinezoomcontrol.h"
#include "timelinemodel.h"
#include "timelinenotesmodel.h"
#include "timelineabstractrenderer.h"
#include <QSGTransformNode>
#include <QQuickItem>
namespace Timeline {
class TimelineRenderPass;
class TimelineRenderState;
class TimelineRenderer : public TimelineAbstractRenderer
class TIMELINE_EXPORT TimelineRenderer : public TimelineAbstractRenderer
{
Q_OBJECT
......
......@@ -31,6 +31,7 @@
#ifndef TIMELINERENDERPASS_H
#define TIMELINERENDERPASS_H
#include "timeline_global.h"
#include <QVector>
QT_FORWARD_DECLARE_CLASS(QSGNode)
......@@ -39,9 +40,9 @@ namespace Timeline {
class TimelineAbstractRenderer;
class TimelineRenderState;
class TimelineRenderPass {
class TIMELINE_EXPORT TimelineRenderPass {
public:
class State {
class TIMELINE_EXPORT State {
public: