forked from qt-creator/qt-creator
QmlProfiler: Show notes in events view
Change-Id: I21542128c4cc9b7a31f7b834defbdf1dd15cd37a Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
This commit is contained in:
@@ -62,6 +62,7 @@ public:
|
||||
|
||||
QList<QmlDebug::RangeType> acceptedTypes;
|
||||
QSet<int> eventsInBindingLoop;
|
||||
QHash<int, QString> notes;
|
||||
};
|
||||
|
||||
QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager *modelManager, QObject *parent)
|
||||
@@ -69,6 +70,8 @@ QmlProfilerEventsModelProxy::QmlProfilerEventsModelProxy(QmlProfilerModelManager
|
||||
{
|
||||
d->modelManager = modelManager;
|
||||
connect(modelManager->qmlModel(), SIGNAL(changed()), this, SLOT(dataChanged()));
|
||||
connect(modelManager->notesModel(), SIGNAL(changed(int,int,int)),
|
||||
this, SLOT(notesChanged(int)));
|
||||
d->modelId = modelManager->registerModelProxy();
|
||||
|
||||
// We're iterating twice in loadData.
|
||||
@@ -107,11 +110,17 @@ const QVector<QmlProfilerDataModel::QmlEventTypeData> &QmlProfilerEventsModelPro
|
||||
return d->modelManager->qmlModel()->getEventTypes();
|
||||
}
|
||||
|
||||
const QHash<int, QString> &QmlProfilerEventsModelProxy::getNotes() const
|
||||
{
|
||||
return d->notes;
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::clear()
|
||||
{
|
||||
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
|
||||
d->data.clear();
|
||||
d->eventsInBindingLoop.clear();
|
||||
d->notes.clear();
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::limitToRange(qint64 rangeStart, qint64 rangeEnd)
|
||||
@@ -127,6 +136,38 @@ void QmlProfilerEventsModelProxy::dataChanged()
|
||||
clear();
|
||||
}
|
||||
|
||||
void QmlProfilerEventsModelProxy::notesChanged(int typeIndex)
|
||||
{
|
||||
const NotesModel *notesModel = d->modelManager->notesModel();
|
||||
if (typeIndex == -1) {
|
||||
d->notes.clear();
|
||||
for (int noteId = 0; noteId < notesModel->count(); ++noteId) {
|
||||
int noteType = notesModel->typeId(noteId);
|
||||
if (noteType != -1) {
|
||||
QString ¬e = d->notes[noteType];
|
||||
if (note.isEmpty()) {
|
||||
note = notesModel->text(noteId);
|
||||
} else {
|
||||
note.append(QStringLiteral("\n")).append(notesModel->text(noteId));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
d->notes.remove(typeIndex);
|
||||
QVariantList changedNotes = notesModel->byTypeId(typeIndex);
|
||||
if (!changedNotes.isEmpty()) {
|
||||
QStringList newNotes;
|
||||
for (QVariantList::ConstIterator it = changedNotes.begin(); it != changedNotes.end();
|
||||
++it) {
|
||||
newNotes << notesModel->text(it->toInt());
|
||||
}
|
||||
d->notes[typeIndex] = newNotes.join(QStringLiteral("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
emit notesAvailable(typeIndex);
|
||||
}
|
||||
|
||||
const QSet<int> &QmlProfilerEventsModelProxy::eventsInBindingLoop() const
|
||||
{
|
||||
return d->eventsInBindingLoop;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#define QMLPROFILEREVENTSMODELPROXY_H
|
||||
|
||||
#include "qmlprofilerdatamodel.h"
|
||||
#include "notesmodel.h"
|
||||
#include <QObject>
|
||||
#include <qmldebug/qmlprofilereventtypes.h>
|
||||
#include <qmldebug/qmlprofilereventlocation.h>
|
||||
@@ -71,6 +72,8 @@ public:
|
||||
|
||||
const QHash<int, QmlEventStats> &getData() const;
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
||||
const QHash<int, QString> &getNotes() const;
|
||||
|
||||
int count() const;
|
||||
void clear();
|
||||
|
||||
@@ -78,6 +81,7 @@ public:
|
||||
|
||||
signals:
|
||||
void dataAvailable();
|
||||
void notesAvailable(int typeIndex);
|
||||
|
||||
private:
|
||||
void loadData(qint64 rangeStart = -1, qint64 rangeEnd = -1);
|
||||
@@ -86,6 +90,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void dataChanged();
|
||||
void notesChanged(int typeIndex);
|
||||
|
||||
private:
|
||||
class QmlProfilerEventsModelProxyPrivate;
|
||||
@@ -116,8 +121,10 @@ public:
|
||||
void clear();
|
||||
|
||||
const QmlEventRelativesMap &getData(int typeId) const;
|
||||
QVariantList getNotes(int typeId) const;
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &getTypes() const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void loadData() = 0;
|
||||
|
||||
|
||||
@@ -58,11 +58,9 @@ namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
struct Colors {
|
||||
Colors () {
|
||||
this->bindingLoopBackground = QColor("orange").lighter();
|
||||
}
|
||||
|
||||
QColor bindingLoopBackground;
|
||||
Colors () : noteBackground(QColor("orange")), defaultBackground(QColor("white")) {}
|
||||
QColor noteBackground;
|
||||
QColor defaultBackground;
|
||||
};
|
||||
|
||||
struct RootEventType : public QmlProfilerDataModel::QmlEventTypeData {
|
||||
@@ -408,6 +406,7 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(QWidget *parent,
|
||||
|
||||
d->modelProxy = modelProxy;
|
||||
connect(d->modelProxy,SIGNAL(dataAvailable()), this, SLOT(buildModel()));
|
||||
connect(d->modelProxy,SIGNAL(notesAvailable(int)), this, SLOT(updateNotes(int)));
|
||||
d->m_firstNumericColumn = 0;
|
||||
d->m_preventSelectBounce = false;
|
||||
d->m_showExtendedStatistics = false;
|
||||
@@ -573,11 +572,42 @@ void QmlProfilerEventsMainView::buildModel()
|
||||
collapseAll();
|
||||
}
|
||||
|
||||
void QmlProfilerEventsMainView::updateNotes(int typeIndex)
|
||||
{
|
||||
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList =
|
||||
d->modelProxy->getData();
|
||||
const QHash<int, QString> ¬eList = d->modelProxy->getNotes();
|
||||
QStandardItem *parentItem = d->m_model->invisibleRootItem();
|
||||
|
||||
for (int rowIndex = 0; rowIndex < parentItem->rowCount(); ++rowIndex) {
|
||||
int rowType = parentItem->child(rowIndex, 0)->data(TypeIdRole).toInt();
|
||||
if (rowType != typeIndex && typeIndex != -1)
|
||||
continue;
|
||||
const QmlProfilerEventsModelProxy::QmlEventStats &stats = eventList[rowType];
|
||||
|
||||
for (int columnIndex = 0; columnIndex < parentItem->columnCount(); ++columnIndex) {
|
||||
QStandardItem *item = parentItem->child(rowIndex, columnIndex);
|
||||
QHash<int, QString>::ConstIterator it = noteList.find(rowType);
|
||||
if (it != noteList.end()) {
|
||||
item->setBackground(colors()->noteBackground);
|
||||
item->setToolTip(it.value());
|
||||
} else if (stats.isBindingLoop) {
|
||||
item->setBackground(colors()->noteBackground);
|
||||
item->setToolTip(tr("Binding loop detected."));
|
||||
} else if (!item->toolTip().isEmpty()){
|
||||
item->setBackground(colors()->defaultBackground);
|
||||
item->setToolTip(QString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QmlProfilerEventsMainView::parseModelProxy()
|
||||
{
|
||||
const QHash<int, QmlProfilerEventsModelProxy::QmlEventStats> &eventList = d->modelProxy->getData();
|
||||
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typeList = d->modelProxy->getTypes();
|
||||
|
||||
|
||||
QHash<int, QmlProfilerEventsModelProxy::QmlEventStats>::ConstIterator it;
|
||||
for (it = eventList.constBegin(); it != eventList.constEnd(); ++it) {
|
||||
int typeIndex = it.key();
|
||||
@@ -664,13 +694,6 @@ void QmlProfilerEventsMainView::parseModelProxy()
|
||||
newRow.at(0)->setData(QVariant(event.location.line),LineRole);
|
||||
newRow.at(0)->setData(QVariant(event.location.column),ColumnRole);
|
||||
|
||||
if (stats.isBindingLoop) {
|
||||
foreach (QStandardItem *item, newRow) {
|
||||
item->setBackground(colors()->bindingLoopBackground);
|
||||
item->setToolTip(tr("Binding loop detected."));
|
||||
}
|
||||
}
|
||||
|
||||
// append
|
||||
parentItem->appendRow(newRow);
|
||||
}
|
||||
@@ -925,7 +948,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
|
||||
|
||||
if (event.isBindingLoop) {
|
||||
foreach (QStandardItem *item, newRow) {
|
||||
item->setBackground(colors()->bindingLoopBackground);
|
||||
item->setBackground(colors()->noteBackground);
|
||||
item->setToolTip(tr("Part of binding loop."));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ public slots:
|
||||
void selectType(int typeIndex);
|
||||
void selectByLocation(const QString &filename, int line, int column);
|
||||
void buildModel();
|
||||
void updateNotes(int typeIndex);
|
||||
|
||||
private slots:
|
||||
void profilerDataModelStateChanged();
|
||||
|
||||
Reference in New Issue
Block a user