forked from qt-creator/qt-creator
QmlProfiler: Don't access QmlProfilerTool from QmlProfilerTextMark
Only QmlProfilerViewManager is needed, so use that, as a step to reduce the interface of the QmlProfilerTool singleton. Change-Id: I19e55e3b22b3c64ff98b8ea29cbc5164a60ee15d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
@@ -22,8 +22,12 @@
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmlprofilertextmark.h"
|
||||
|
||||
#include "qmlprofilerconstants.h"
|
||||
#include "qmlprofilerviewmanager.h"
|
||||
#include "qmlprofilerstatisticsview.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
@@ -32,9 +36,9 @@
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
QmlProfilerTextMark::QmlProfilerTextMark(QmlProfilerTool *tool, int typeId, const QString &fileName,
|
||||
int lineNumber) :
|
||||
TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY, 3.5), m_tool(tool),
|
||||
QmlProfilerTextMark::QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId,
|
||||
const QString &fileName, int lineNumber) :
|
||||
TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY, 3.5), m_viewManager(viewManager),
|
||||
m_typeIds(1, typeId)
|
||||
{
|
||||
}
|
||||
@@ -50,7 +54,8 @@ void QmlProfilerTextMark::paintIcon(QPainter *painter, const QRect &paintRect) c
|
||||
painter->setPen(Qt::black);
|
||||
painter->fillRect(paintRect, Qt::white);
|
||||
painter->drawRect(paintRect);
|
||||
painter->drawText(paintRect, m_tool->summary(m_typeIds), Qt::AlignRight | Qt::AlignVCenter);
|
||||
painter->drawText(paintRect, m_viewManager->statisticsView()->summary(m_typeIds),
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@@ -58,7 +63,7 @@ void QmlProfilerTextMark::clicked()
|
||||
{
|
||||
int typeId = m_typeIds.takeFirst();
|
||||
m_typeIds.append(typeId);
|
||||
m_tool->selectType(typeId);
|
||||
m_viewManager->typeSelected(typeId);
|
||||
}
|
||||
|
||||
QmlProfilerTextMarkModel::QmlProfilerTextMarkModel(QObject *parent) : QObject(parent)
|
||||
@@ -82,7 +87,8 @@ void QmlProfilerTextMarkModel::addTextMarkId(int typeId, const QmlEventLocation
|
||||
m_ids.insert(location.filename(), {typeId, location.line(), location.column()});
|
||||
}
|
||||
|
||||
void QmlProfilerTextMarkModel::createMarks(QmlProfilerTool *tool, const QString &fileName)
|
||||
void QmlProfilerTextMarkModel::createMarks(QmlProfilerViewManager *viewManager,
|
||||
const QString &fileName)
|
||||
{
|
||||
auto first = m_ids.find(fileName);
|
||||
QVarLengthArray<TextMarkId> ids;
|
||||
@@ -103,7 +109,7 @@ void QmlProfilerTextMarkModel::createMarks(QmlProfilerTool *tool, const QString
|
||||
m_marks.last()->addTypeId(it->typeId);
|
||||
} else {
|
||||
lineNumber = it->lineNumber;
|
||||
m_marks.append(new QmlProfilerTextMark(tool, it->typeId, fileName, it->lineNumber));
|
||||
m_marks << new QmlProfilerTextMark(viewManager, it->typeId, fileName, it->lineNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +119,7 @@ bool QmlProfilerTextMark::addToolTipContent(QLayout *target) const
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
layout->setHorizontalSpacing(10);
|
||||
for (int row = 0, rowEnd = m_typeIds.length(); row != rowEnd; ++row) {
|
||||
const QStringList typeDetails = m_tool->details(m_typeIds[row]);
|
||||
const QStringList typeDetails = m_viewManager->statisticsView()->details(m_typeIds[row]);
|
||||
for (int column = 0, columnEnd = typeDetails.length(); column != columnEnd; ++column) {
|
||||
QLabel *label = new QLabel;
|
||||
label->setAlignment(column == columnEnd - 1 ? Qt::AlignRight : Qt::AlignLeft);
|
||||
|
||||
Reference in New Issue
Block a user