Commit 35204e11 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Apply d-pointer pattern to TimelineRenderState

It will be a public class in the timeline library.

Change-Id: I77a3bedd9e63b57c199680e89da1950ed7b7e3d1
Reviewed-by: default avatarKai Koehne <kai.koehne@theqtcompany.com>
parent f87622c3
......@@ -87,7 +87,8 @@ HEADERS += \
timelinerenderstate.h \
timelinenotesmodel.h \
timelinenotesmodel_p.h \
timelinerenderer_p.h
timelinerenderer_p.h \
timelinerenderstate_p.h
RESOURCES += \
qml/qmlprofiler.qrc
......
......@@ -57,7 +57,7 @@ QtcPlugin {
"timelinenotesrenderpass.cpp", "timelinenotesrenderpass.h",
"timelinerenderer.cpp", "timelinerenderer.h", "timelinerenderer_p.h",
"timelinerenderpass.cpp", "timelinerenderpass.h",
"timelinerenderstate.cpp", "timelinerenderstate.h",
"timelinerenderstate.cpp", "timelinerenderstate.h", "timelinerenderstate_p.h",
"timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h",
"timelinezoomcontrol.cpp", "timelinezoomcontrol.h"
]
......
......@@ -28,83 +28,128 @@
**
****************************************************************************/
#include "timelinerenderstate.h"
#include "timelinerenderstate_p.h"
namespace Timeline {
TimelineRenderState::TimelineRenderState(qint64 start, qint64 end, qreal scale, int numPasses) :
m_expandedRowRoot(new QSGNode), m_collapsedRowRoot(new QSGNode),
m_expandedOverlayRoot(new QSGNode), m_collapsedOverlayRoot(new QSGNode),
m_start(start), m_end(end), m_scale(scale), m_passes(numPasses)
d_ptr(new TimelineRenderStatePrivate)
{
m_expandedRowRoot->setFlag(QSGNode::OwnedByParent, false);
m_collapsedRowRoot->setFlag(QSGNode::OwnedByParent, false);
m_expandedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
m_collapsedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
Q_D(TimelineRenderState);
d->expandedRowRoot = new QSGNode;
d->collapsedRowRoot = new QSGNode;
d->expandedOverlayRoot = new QSGNode;
d->collapsedOverlayRoot = new QSGNode;
d->start = start;
d->end = end;
d->scale = scale;
d->passes.resize(numPasses);
d->expandedRowRoot->setFlag(QSGNode::OwnedByParent, false);
d->collapsedRowRoot->setFlag(QSGNode::OwnedByParent, false);
d->expandedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
d->collapsedOverlayRoot->setFlag(QSGNode::OwnedByParent, false);
}
TimelineRenderState::~TimelineRenderState()
{
delete m_expandedRowRoot;
delete m_collapsedRowRoot;
delete m_expandedOverlayRoot;
delete m_collapsedOverlayRoot;
Q_D(TimelineRenderState);
delete d->expandedRowRoot;
delete d->collapsedRowRoot;
delete d->expandedOverlayRoot;
delete d->collapsedOverlayRoot;
delete d;
}
qint64 TimelineRenderState::start() const
{
return m_start;
Q_D(const TimelineRenderState);
return d->start;
}
qint64 TimelineRenderState::end() const
{
return m_end;
Q_D(const TimelineRenderState);
return d->end;
}
qreal TimelineRenderState::scale() const
{
return m_scale;
Q_D(const TimelineRenderState);
return d->scale;
}
QSGNode *TimelineRenderState::expandedRowRoot() const
const QSGNode *TimelineRenderState::expandedRowRoot() const
{
return m_expandedRowRoot;
Q_D(const TimelineRenderState);
return d->expandedRowRoot;
}
QSGNode *TimelineRenderState::collapsedRowRoot() const
const QSGNode *TimelineRenderState::collapsedRowRoot() const
{
return m_collapsedRowRoot;
Q_D(const TimelineRenderState);
return d->collapsedRowRoot;
}
QSGNode *TimelineRenderState::expandedOverlayRoot() const
const QSGNode *TimelineRenderState::expandedOverlayRoot() const
{
return m_expandedOverlayRoot;
Q_D(const TimelineRenderState);
return d->expandedOverlayRoot;
}
QSGNode *TimelineRenderState::collapsedOverlayRoot() const
const QSGNode *TimelineRenderState::collapsedOverlayRoot() const
{
return m_collapsedOverlayRoot;
Q_D(const TimelineRenderState);
return d->collapsedOverlayRoot;
}
QSGNode *TimelineRenderState::expandedRowRoot()
{
Q_D(TimelineRenderState);
return d->expandedRowRoot;
}
QSGNode *TimelineRenderState::collapsedRowRoot()
{
Q_D(TimelineRenderState);
return d->collapsedRowRoot;
}
QSGNode *TimelineRenderState::expandedOverlayRoot()
{
Q_D(TimelineRenderState);
return d->expandedOverlayRoot;
}
QSGNode *TimelineRenderState::collapsedOverlayRoot()
{
Q_D(TimelineRenderState);
return d->collapsedOverlayRoot;
}
bool TimelineRenderState::isEmpty() const
{
return m_collapsedRowRoot->childCount() == 0 && m_expandedRowRoot->childCount() == 0 &&
m_collapsedOverlayRoot->childCount() == 0 && m_expandedOverlayRoot->childCount() == 0;
Q_D(const TimelineRenderState);
return d->collapsedRowRoot->childCount() == 0 && d->expandedRowRoot->childCount() == 0 &&
d->collapsedOverlayRoot->childCount() == 0 && d->expandedOverlayRoot->childCount() == 0;
}
TimelineRenderPass::State *TimelineRenderState::passState(int i)
{
return m_passes[i];
Q_D(TimelineRenderState);
return d->passes[i];
}
const TimelineRenderPass::State *TimelineRenderState::passState(int i) const
{
return m_passes[i];
Q_D(const TimelineRenderState);
return d->passes[i];
}
void TimelineRenderState::setPassState(int i, TimelineRenderPass::State *state)
{
m_passes[i] = state;
Q_D(TimelineRenderState);
d->passes[i] = state;
}
} // namespace Timeline
......@@ -49,25 +49,22 @@ public:
const TimelineRenderPass::State *passState(int i) const;
void setPassState(int i, TimelineRenderPass::State *state);
QSGNode *expandedRowRoot() const;
QSGNode *collapsedRowRoot() const;
QSGNode *expandedOverlayRoot() const;
QSGNode *collapsedOverlayRoot() const;
const QSGNode *expandedRowRoot() const;
const QSGNode *collapsedRowRoot() const;
const QSGNode *expandedOverlayRoot() const;
const QSGNode *collapsedOverlayRoot() const;
QSGNode *expandedRowRoot();
QSGNode *collapsedRowRoot();
QSGNode *expandedOverlayRoot();
QSGNode *collapsedOverlayRoot();
bool isEmpty() const;
private:
QSGNode *m_expandedRowRoot;
QSGNode *m_collapsedRowRoot;
QSGNode *m_expandedOverlayRoot;
QSGNode *m_collapsedOverlayRoot;
qint64 m_start;
qint64 m_end;
qreal m_scale; // "native" scale, this stays the same through the life time of a state
QVector<TimelineRenderPass::State *> m_passes;
class TimelineRenderStatePrivate;
TimelineRenderStatePrivate *d_ptr;
Q_DECLARE_PRIVATE(TimelineRenderState)
};
} // namespace Timeline
......
/****************************************************************************
**
** 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 TIMELINERENDERSTATE_P_H
#define TIMELINERENDERSTATE_P_H
#include "timelinerenderstate.h"
namespace Timeline {
class TimelineRenderState::TimelineRenderStatePrivate {
public:
QSGNode *expandedRowRoot;
QSGNode *collapsedRowRoot;
QSGNode *expandedOverlayRoot;
QSGNode *collapsedOverlayRoot;
qint64 start;
qint64 end;
qreal scale; // "native" scale, this stays the same through the life time of a state
QVector<TimelineRenderPass::State *> passes;
};
} // namespace Timeline
#endif // TIMELINERENDERSTATE_P_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment