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

View File

@@ -96,24 +96,8 @@ void FlameGraphModel::loadNotes(int typeIndex, bool emitSignal)
m_typeIdsWithNotes.insert(typeIndex);
}
if (!emitSignal)
return;
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));
}
}
if (emitSignal)
emit dataChanged(QModelIndex(), QModelIndex(), QVector<int>() << Note);
}
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();
foreach (const QVariant &item, notes->byTypeId(stats.typeIndex)) {
if (ret.isEmpty())
ret = item.toString();
ret = notes->text(item.toInt());
else
ret += QChar::LineFeed + item.toString();
ret += QChar::LineFeed + notes->text(item.toInt());
}
return ret;
}