QmlProfiler: Fix note support in flamegraph view

The model didn't really support it and we didn't have any visualization
for it. Now the events with notes or binding loops get an orange border.

Change-Id: I903f1d42afaf3567484b615b22381d38fc81b9b5
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-03-02 11:12:12 +01:00
parent 443e75ba69
commit 0b7c63d69f
2 changed files with 34 additions and 27 deletions

View File

@@ -51,6 +51,9 @@ ScrollView {
property color blue2: Qt.rgba(0.375, 0, 1, 1) property color blue2: Qt.rgba(0.375, 0, 1, 1)
property color grey1: "#B0B0B0" property color grey1: "#B0B0B0"
property color grey2: "#A0A0A0" property color grey2: "#A0A0A0"
property color orange: "orange"
function checkBindingLoop(otherTypeId) {return false;}
id: flamegraph id: flamegraph
width: parent.width width: parent.width
@@ -62,22 +65,32 @@ ScrollView {
delegate: Item { delegate: Item {
id: flamegraphItem id: flamegraphItem
property int typeId: FlameGraph.data(FlameGraphModel.TypeId) || -1
property bool isBindingLoop: parent.checkBindingLoop(typeId)
property int level: parent.level + (rangeTypeVisible ? 1 : 0) property int level: parent.level + (rangeTypeVisible ? 1 : 0)
property bool isSelected: FlameGraph.data(FlameGraphModel.TypeId) === property bool isSelected: typeId !== -1 && typeId === root.selectedTypeId
root.selectedTypeId
property bool rangeTypeVisible: root.visibleRangeTypes & property bool rangeTypeVisible: root.visibleRangeTypes &
(1 << FlameGraph.data(FlameGraphModel.RangeType)) (1 << FlameGraph.data(FlameGraphModel.RangeType))
onIsSelectedChanged: { onIsSelectedChanged: {
if (isSelected && (tooltip.selectedNode === null || if (isSelected && (tooltip.selectedNode === null ||
tooltip.selectedNode.FlameGraph.data(FlameGraphModel.TypeId) !== tooltip.selectedNode.typeId !== root.selectedTypeId)) {
root.selectedTypeId)) {
tooltip.selectedNode = flamegraphItem; tooltip.selectedNode = flamegraphItem;
} else if (!isSelected && tooltip.selectedNode === flamegraphItem) { } else if (!isSelected && tooltip.selectedNode === flamegraphItem) {
tooltip.selectedNode = null; tooltip.selectedNode = null;
} }
} }
function checkBindingLoop(otherTypeId) {
if (typeId === otherTypeId) {
isBindingLoop = true;
return true;
} else {
return parent.checkBindingLoop(otherTypeId);
}
}
function details() { function details() {
var model = []; var model = [];
function addDetail(name, index, format) { function addDetail(name, index, format) {
@@ -129,11 +142,21 @@ ScrollView {
return flamegraph.blue2; return flamegraph.blue2;
else if (tooltip.hoveredNode === flamegraphItem) else if (tooltip.hoveredNode === flamegraphItem)
return flamegraph.blue1; return flamegraph.blue1;
else if (flamegraphItem.note() !== "" || flamegraphItem.isBindingLoop)
return flamegraph.orange;
else else
return flamegraph.grey1 return flamegraph.grey1;
}
border.width: {
if (tooltip.hoveredNode === flamegraphItem ||
tooltip.selectedNode === flamegraphItem) {
return 2;
} else if (flamegraphItem.note() !== "") {
return 3;
} else {
return 1;
}
} }
border.width: (tooltip.hoveredNode === flamegraphItem ||
tooltip.selectedNode === flamegraphItem) ? 2 : 1
color: Qt.hsla((level % 12) / 72, 0.9 + Math.random() / 10, color: Qt.hsla((level % 12) / 72, 0.9 + Math.random() / 10,
0.45 + Math.random() / 10, 0.9 + Math.random() / 10); 0.45 + Math.random() / 10, 0.9 + Math.random() / 10);
height: flamegraphItem.rangeTypeVisible ? flamegraph.itemHeight : 0; height: flamegraphItem.rangeTypeVisible ? flamegraph.itemHeight : 0;

View File

@@ -96,24 +96,8 @@ void FlameGraphModel::loadNotes(int typeIndex, bool emitSignal)
m_typeIdsWithNotes.insert(typeIndex); m_typeIdsWithNotes.insert(typeIndex);
} }
if (!emitSignal) if (emitSignal)
return; emit dataChanged(QModelIndex(), QModelIndex(), QVector<int>() << Note);
QQueue<QModelIndex> queue;
queue.append(QModelIndex());
QVector<int> roles = {Note};
while (!queue.isEmpty()) {
QModelIndex index = queue.takeFirst();
if (index.isValid()) {
FlameGraphData *data = static_cast<FlameGraphData *>(index.internalPointer());
if (changedNotes.contains(data->typeIndex))
emit dataChanged(index, index, roles);
for (int row = 0; row < rowCount(index); ++row)
queue.append(index.child(row, 0));
}
}
} }
void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd) void FlameGraphModel::loadData(qint64 rangeStart, qint64 rangeEnd)
@@ -203,9 +187,9 @@ QVariant FlameGraphModel::lookup(const FlameGraphData &stats, int role) const
QmlProfiler::QmlProfilerNotesModel *notes = m_modelManager->notesModel(); QmlProfiler::QmlProfilerNotesModel *notes = m_modelManager->notesModel();
foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) { foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) {
if (ret.isEmpty()) if (ret.isEmpty())
ret = item.toString(); ret = notes->text(item.toInt());
else else
ret += QChar::LineFeed + item.toString(); ret += QChar::LineFeed + notes->text(item.toInt());
} }
return ret; return ret;
} }