Commit 57fe9b7b authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Rename get* and find* methods to their canonical names



Also, all methods about events in models don't really need the "event"
prefix as that is what the models are about.

Change-Id: I7b995aa9c9dce7e01d4c862d094b1e73e6b6fb40
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent 00e6285e
...@@ -67,37 +67,37 @@ int AbstractTimelineModel::count() const ...@@ -67,37 +67,37 @@ int AbstractTimelineModel::count() const
return d->count(); return d->count();
} }
int AbstractTimelineModel::findFirstIndex(qint64 startTime) const int AbstractTimelineModel::firstIndex(qint64 startTime) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->findFirstIndex(startTime); return d->firstIndex(startTime);
} }
int AbstractTimelineModel::findFirstIndexNoParents(qint64 startTime) const int AbstractTimelineModel::firstIndexNoParents(qint64 startTime) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->findFirstIndexNoParents(startTime); return d->firstIndexNoParents(startTime);
} }
int AbstractTimelineModel::findLastIndex(qint64 endTime) const int AbstractTimelineModel::lastIndex(qint64 endTime) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->findLastIndex(endTime); return d->lastIndex(endTime);
} }
qint64 AbstractTimelineModel::getDuration(int index) const qint64 AbstractTimelineModel::duration(int index) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->duration(index); return d->duration(index);
} }
qint64 AbstractTimelineModel::getStartTime(int index) const qint64 AbstractTimelineModel::startTime(int index) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->startTime(index); return d->startTime(index);
} }
qint64 AbstractTimelineModel::getEndTime(int index) const qint64 AbstractTimelineModel::endTime(int index) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return d->startTime(index) + d->duration(index); return d->startTime(index) + d->duration(index);
...@@ -183,20 +183,20 @@ qint64 AbstractTimelineModel::traceDuration() const ...@@ -183,20 +183,20 @@ qint64 AbstractTimelineModel::traceDuration() const
return d->modelManager->traceTime()->duration(); return d->modelManager->traceTime()->duration();
} }
const QVariantMap AbstractTimelineModel::getEventLocation(int index) const QVariantMap AbstractTimelineModel::location(int index) const
{ {
Q_UNUSED(index); Q_UNUSED(index);
QVariantMap map; QVariantMap map;
return map; return map;
} }
int AbstractTimelineModel::getEventIdForTypeIndex(int typeIndex) const int AbstractTimelineModel::eventIdForTypeIndex(int typeIndex) const
{ {
Q_UNUSED(typeIndex); Q_UNUSED(typeIndex);
return -1; return -1;
} }
int AbstractTimelineModel::getEventIdForLocation(const QString &filename, int line, int column) const int AbstractTimelineModel::eventIdForLocation(const QString &filename, int line, int column) const
{ {
Q_UNUSED(filename); Q_UNUSED(filename);
Q_UNUSED(line); Q_UNUSED(line);
...@@ -204,13 +204,13 @@ int AbstractTimelineModel::getEventIdForLocation(const QString &filename, int li ...@@ -204,13 +204,13 @@ int AbstractTimelineModel::getEventIdForLocation(const QString &filename, int li
return -1; return -1;
} }
int AbstractTimelineModel::getBindingLoopDest(int index) const int AbstractTimelineModel::bindingLoopDest(int index) const
{ {
Q_UNUSED(index); Q_UNUSED(index);
return -1; return -1;
} }
float AbstractTimelineModel::getHeight(int index) const float AbstractTimelineModel::height(int index) const
{ {
Q_UNUSED(index); Q_UNUSED(index);
return 1.0f; return 1.0f;
...@@ -245,7 +245,7 @@ void AbstractTimelineModel::dataChanged() ...@@ -245,7 +245,7 @@ void AbstractTimelineModel::dataChanged()
d->rowOffsets.clear(); d->rowOffsets.clear();
} }
bool AbstractTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool AbstractTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
{ {
Q_D(const AbstractTimelineModel); Q_D(const AbstractTimelineModel);
return (event.rangeType == d->rangeType && event.message == d->message); return (event.rangeType == d->rangeType && event.message == d->message);
......
...@@ -58,38 +58,38 @@ public: ...@@ -58,38 +58,38 @@ public:
void setRowHeight(int rowNumber, int height); void setRowHeight(int rowNumber, int height);
int height() const; int height() const;
Q_INVOKABLE qint64 traceStartTime() const; qint64 traceStartTime() const;
Q_INVOKABLE qint64 traceEndTime() const; qint64 traceEndTime() const;
Q_INVOKABLE qint64 traceDuration() const; qint64 traceDuration() const;
Q_INVOKABLE qint64 getDuration(int index) const; qint64 duration(int index) const;
Q_INVOKABLE qint64 getStartTime(int index) const; qint64 startTime(int index) const;
Q_INVOKABLE qint64 getEndTime(int index) const; qint64 endTime(int index) const;
int findFirstIndex(qint64 startTime) const; int firstIndex(qint64 startTime) const;
int findFirstIndexNoParents(qint64 startTime) const; int firstIndexNoParents(qint64 startTime) const;
int findLastIndex(qint64 endTime) const; int lastIndex(qint64 endTime) const;
int count() const; int count() const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const; bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool expanded() const; bool expanded() const;
void setExpanded(bool expanded); void setExpanded(bool expanded);
QString displayName() const; QString displayName() const;
// Methods that have to be implemented by child models // Methods that have to be implemented by child models
virtual int rowCount() const = 0; virtual int rowCount() const = 0;
Q_INVOKABLE virtual int getEventId(int index) const = 0; virtual int eventId(int index) const = 0;
Q_INVOKABLE virtual QColor getColor(int index) const = 0; virtual QColor color(int index) const = 0;
virtual const QVariantList getLabels() const = 0; virtual QVariantList labels() const = 0;
Q_INVOKABLE virtual const QVariantList getEventDetails(int index) const = 0; virtual QVariantList details(int index) const = 0;
virtual int getEventRow(int index) const = 0; virtual int row(int index) const = 0;
virtual void loadData() = 0; virtual void loadData() = 0;
virtual void clear() = 0; virtual void clear() = 0;
// Methods which can optionally be implemented by child models. // Methods which can optionally be implemented by child models.
// returned map should contain "file", "line", "column" properties, or be empty // returned map should contain "file", "line", "column" properties, or be empty
Q_INVOKABLE virtual const QVariantMap getEventLocation(int index) const; virtual QVariantMap location(int index) const;
Q_INVOKABLE virtual int getEventIdForTypeIndex(int typeIndex) const; virtual int eventIdForTypeIndex(int typeIndex) const;
Q_INVOKABLE virtual int getEventIdForLocation(const QString &filename, int line, int column) const; virtual int eventIdForLocation(const QString &filename, int line, int column) const;
Q_INVOKABLE virtual int getBindingLoopDest(int index) const; virtual int bindingLoopDest(int index) const;
Q_INVOKABLE virtual float getHeight(int index) const; virtual float height(int index) const;
virtual int rowMinValue(int rowNumber) const; virtual int rowMinValue(int rowNumber) const;
virtual int rowMaxValue(int rowNumber) const; virtual int rowMaxValue(int rowNumber) const;
...@@ -108,17 +108,17 @@ protected: ...@@ -108,17 +108,17 @@ protected:
Lightness = 166 Lightness = 166
}; };
QColor getEventColor(int index) const QColor colorByEventId(int index) const
{ {
return getColorByHue(getEventId(index) * EventHueMultiplier); return colorByHue(eventId(index) * EventHueMultiplier);
} }
QColor getFractionColor(double fraction) const QColor colorByFraction(double fraction) const
{ {
return getColorByHue(fraction * FractionHueMultiplier + FractionHueMininimum); return colorByHue(fraction * FractionHueMultiplier + FractionHueMininimum);
} }
QColor getColorByHue(int hue) const QColor colorByHue(int hue) const
{ {
return QColor::fromHsl(hue % 360, Saturation, Lightness); return QColor::fromHsl(hue % 360, Saturation, Lightness);
} }
......
...@@ -43,9 +43,9 @@ public: ...@@ -43,9 +43,9 @@ public:
virtual qint64 startTime(int index) const = 0; virtual qint64 startTime(int index) const = 0;
virtual qint64 lastEndTime() const = 0; virtual qint64 lastEndTime() const = 0;
virtual qint64 firstStartTime() const = 0; virtual qint64 firstStartTime() const = 0;
virtual int findFirstIndex(qint64 startTime) const = 0; virtual int firstIndex(qint64 startTime) const = 0;
virtual int findFirstIndexNoParents(qint64 startTime) const = 0; virtual int firstIndexNoParents(qint64 startTime) const = 0;
virtual int findLastIndex(qint64 endTime) const = 0; virtual int lastIndex(qint64 endTime) const = 0;
QVector<int> rowOffsets; QVector<int> rowOffsets;
QmlProfilerModelManager *modelManager; QmlProfilerModelManager *modelManager;
......
...@@ -54,7 +54,7 @@ Item { ...@@ -54,7 +54,7 @@ Item {
height: trigger(qmlProfilerModelProxy.height(modelIndex)) height: trigger(qmlProfilerModelProxy.height(modelIndex))
width: 150 width: 150
function getDescriptions() { function updateDescriptions() {
bindingTrigger = -bindingTrigger; bindingTrigger = -bindingTrigger;
if (!visible) if (!visible)
return; return;
...@@ -62,7 +62,7 @@ Item { ...@@ -62,7 +62,7 @@ Item {
var desc=[]; var desc=[];
var ids=[]; var ids=[];
var extdesc=[]; var extdesc=[];
var labelList = qmlProfilerModelProxy.getLabels(modelIndex); var labelList = qmlProfilerModelProxy.labels(modelIndex);
for (var i = 0; i < labelList.length; i++ ) { for (var i = 0; i < labelList.length; i++ ) {
extdesc[i] = desc[i] = (labelList[i].description || qsTr("<bytecode>")); extdesc[i] = desc[i] = (labelList[i].description || qsTr("<bytecode>"));
ids[i] = labelList[i].id; ids[i] = labelList[i].id;
...@@ -76,9 +76,9 @@ Item { ...@@ -76,9 +76,9 @@ Item {
Connections { Connections {
target: qmlProfilerModelProxy target: qmlProfilerModelProxy
onExpandedChanged: getDescriptions(); onExpandedChanged: updateDescriptions();
onStateChanged: getDescriptions() onStateChanged: updateDescriptions()
onRowHeightChanged: getDescriptions() onRowHeightChanged: updateDescriptions()
} }
Text { Text {
......
...@@ -135,10 +135,10 @@ Rectangle { ...@@ -135,10 +135,10 @@ Rectangle {
return; return;
// if item is outside of the view, jump back to its position // if item is outside of the view, jump back to its position
if (qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex) < view.startTime || if (qmlProfilerModelProxy.endTime(modelIndex, itemIndex) < view.startTime ||
qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) > view.endTime) { qmlProfilerModelProxy.startTime(modelIndex, itemIndex) > view.endTime) {
recenter((qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) + recenter((qmlProfilerModelProxy.startTime(modelIndex, itemIndex) +
qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex)) / 2); qmlProfilerModelProxy.endTime(modelIndex, itemIndex)) / 2);
} }
} }
...@@ -155,7 +155,7 @@ Rectangle { ...@@ -155,7 +155,7 @@ Rectangle {
function selectById(modelIndex, eventId) function selectById(modelIndex, eventId)
{ {
if (eventId === -1 || (modelIndex === view.selectedModel && if (eventId === -1 || (modelIndex === view.selectedModel &&
eventId === qmlProfilerModelProxy.getEventId(modelIndex, view.selectedItem))) eventId === qmlProfilerModelProxy.eventId(modelIndex, view.selectedItem)))
return; return;
// this is a slot responding to events from the other pane // this is a slot responding to events from the other pane
...@@ -348,16 +348,18 @@ Rectangle { ...@@ -348,16 +348,18 @@ Rectangle {
onSelectionChanged: { onSelectionChanged: {
if (selectedItem !== -1) { if (selectedItem !== -1) {
// display details // display details
rangeDetails.showInfo(qmlProfilerModelProxy.getEventDetails(selectedModel, selectedItem)); rangeDetails.showInfo(qmlProfilerModelProxy.details(selectedModel,
rangeDetails.setLocation(qmlProfilerModelProxy.getEventLocation(selectedModel, selectedItem)); selectedItem));
rangeDetails.setLocation(qmlProfilerModelProxy.location(selectedModel,
selectedItem));
// center view (horizontally) // center view (horizontally)
recenterOnItem(selectedModel, selectedItem); recenterOnItem(selectedModel, selectedItem);
if (!lockItemSelection) { if (!lockItemSelection) {
lockItemSelection = true; lockItemSelection = true;
// update in other views // update in other views
var eventLocation = qmlProfilerModelProxy.getEventLocation( var eventLocation = qmlProfilerModelProxy.location(view.selectedModel,
view.selectedModel, view.selectedItem); view.selectedItem);
gotoSourceLocation(eventLocation.file, eventLocation.line, gotoSourceLocation(eventLocation.file, eventLocation.line,
eventLocation.column); eventLocation.column);
lockItemSelection = false; lockItemSelection = false;
...@@ -368,7 +370,7 @@ Rectangle { ...@@ -368,7 +370,7 @@ Rectangle {
} }
onItemPressed: { onItemPressed: {
var location = qmlProfilerModelProxy.getEventLocation(modelIndex, pressedItem); var location = qmlProfilerModelProxy.location(modelIndex, pressedItem);
if (location.hasOwnProperty("file")) // not empty if (location.hasOwnProperty("file")) // not empty
root.gotoSourceLocation(location.file, location.line, location.column); root.gotoSourceLocation(location.file, location.line, location.column);
} }
...@@ -470,7 +472,7 @@ Rectangle { ...@@ -470,7 +472,7 @@ Rectangle {
var fixedPoint = (view.startTime + view.endTime) / 2; var fixedPoint = (view.startTime + view.endTime) / 2;
if (view.selectedItem !== -1) { if (view.selectedItem !== -1) {
// center on selected item if it's inside the current screen // center on selected item if it's inside the current screen
var newFixedPoint = qmlProfilerModelProxy.getStartTime(view.selectedModel, view.selectedItem); var newFixedPoint = qmlProfilerModelProxy.startTime(view.selectedModel, view.selectedItem);
if (newFixedPoint >= view.startTime && newFixedPoint < view.endTime) if (newFixedPoint >= view.startTime && newFixedPoint < view.endTime)
fixedPoint = newFixedPoint; fixedPoint = newFixedPoint;
} }
......
...@@ -56,20 +56,20 @@ function drawData(canvas, ctxt) ...@@ -56,20 +56,20 @@ function drawData(canvas, ctxt)
for (var ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex); for (var ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) { ii += canvas.increment) {
var xx = (qmlProfilerModelProxy.getStartTime(modelIndex,ii) - var xx = (qmlProfilerModelProxy.startTime(modelIndex,ii) -
qmlProfilerModelProxy.traceStartTime()) * spacing; qmlProfilerModelProxy.traceStartTime()) * spacing;
var eventWidth = qmlProfilerModelProxy.getDuration(modelIndex,ii) * spacing; var eventWidth = qmlProfilerModelProxy.duration(modelIndex,ii) * spacing;
if (eventWidth < 1) if (eventWidth < 1)
eventWidth = 1; eventWidth = 1;
xx = Math.round(xx); xx = Math.round(xx);
var itemHeight = qmlProfilerModelProxy.getHeight(modelIndex,ii) * blockHeight; var itemHeight = qmlProfilerModelProxy.height(modelIndex,ii) * blockHeight;
var yy = (modelIndex + 1) * blockHeight - itemHeight ; var yy = (modelIndex + 1) * blockHeight - itemHeight ;
ctxt.fillStyle = qmlProfilerModelProxy.getColor(modelIndex, ii); ctxt.fillStyle = qmlProfilerModelProxy.color(modelIndex, ii);
ctxt.fillRect(xx, bump + yy, eventWidth, itemHeight); ctxt.fillRect(xx, bump + yy, eventWidth, itemHeight);
} }
} }
...@@ -81,9 +81,9 @@ function drawData(canvas, ctxt) ...@@ -81,9 +81,9 @@ function drawData(canvas, ctxt)
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) { for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
for (ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex); for (ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) { ii += canvas.increment) {
if (qmlProfilerModelProxy.getBindingLoopDest(modelIndex,ii) >= 0) { if (qmlProfilerModelProxy.bindingLoopDest(modelIndex,ii) >= 0) {
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(modelIndex,ii) + var xcenter = Math.round(qmlProfilerModelProxy.startTime(modelIndex,ii) +
qmlProfilerModelProxy.getDuration(modelIndex,ii) - qmlProfilerModelProxy.duration(modelIndex,ii) -
qmlProfilerModelProxy.traceStartTime()) * spacing; qmlProfilerModelProxy.traceStartTime()) * spacing;
var ycenter = Math.round(bump + blockHeight * modelIndex + blockHeight / 2); var ycenter = Math.round(bump + blockHeight * modelIndex + blockHeight / 2);
ctxt.beginPath(); ctxt.beginPath();
......
...@@ -78,9 +78,9 @@ void PaintEventsModelProxy::clear() ...@@ -78,9 +78,9 @@ void PaintEventsModelProxy::clear()
d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1); d->modelManager->modelProxyCountUpdated(d->modelId, 0, 1);
} }
bool PaintEventsModelProxy::eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const bool PaintEventsModelProxy::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
{ {
return AbstractTimelineModel::eventAccepted(event) && return AbstractTimelineModel::accepted(event) &&
event.detailType== QmlDebug::AnimationFrame; event.detailType== QmlDebug::AnimationFrame;
} }
...@@ -101,7 +101,7 @@ void PaintEventsModelProxy::loadData() ...@@ -101,7 +101,7 @@ void PaintEventsModelProxy::loadData()
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) { foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) {
const QmlProfilerDataModel::QmlEventTypeData &type = typeList[event.typeIndex]; const QmlProfilerDataModel::QmlEventTypeData &type = typeList[event.typeIndex];
if (!eventAccepted(type)) if (!accepted(type))
continue; continue;
lastEvent.threadId = (QmlDebug::AnimationThread)event.numericData3; lastEvent.threadId = (QmlDebug::AnimationThread)event.numericData3;
...@@ -160,7 +160,7 @@ int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId( ...@@ -160,7 +160,7 @@ int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId(
return (threadId == QmlDebug::GuiThread || maxGuiThreadAnimations == 0) ? 1 : 2; return (threadId == QmlDebug::GuiThread || maxGuiThreadAnimations == 0) ? 1 : 2;
} }
int PaintEventsModelProxy::getEventRow(int index) const int PaintEventsModelProxy::row(int index) const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
return d->rowFromThreadId(d->range(index).threadId); return d->rowFromThreadId(d->range(index).threadId);
...@@ -180,13 +180,13 @@ int PaintEventsModelProxy::rowMaxValue(int rowNumber) const ...@@ -180,13 +180,13 @@ int PaintEventsModelProxy::rowMaxValue(int rowNumber) const
} }
} }
int PaintEventsModelProxy::getEventId(int index) const int PaintEventsModelProxy::eventId(int index) const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
return d->range(index).threadId; return d->range(index).threadId;
} }
QColor PaintEventsModelProxy::getColor(int index) const QColor PaintEventsModelProxy::color(int index) const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
double fpsFraction = d->range(index).framerate / 60.0; double fpsFraction = d->range(index).framerate / 60.0;
...@@ -194,10 +194,10 @@ QColor PaintEventsModelProxy::getColor(int index) const ...@@ -194,10 +194,10 @@ QColor PaintEventsModelProxy::getColor(int index) const
fpsFraction = 1.0; fpsFraction = 1.0;
if (fpsFraction < 0.0) if (fpsFraction < 0.0)
fpsFraction = 0.0; fpsFraction = 0.0;
return getFractionColor(fpsFraction); return colorByFraction(fpsFraction);
} }
float PaintEventsModelProxy::getHeight(int index) const float PaintEventsModelProxy::height(int index) const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
const PaintEventsModelProxyPrivate::Range &range = d->range(index); const PaintEventsModelProxyPrivate::Range &range = d->range(index);
...@@ -212,7 +212,7 @@ float PaintEventsModelProxy::getHeight(int index) const ...@@ -212,7 +212,7 @@ float PaintEventsModelProxy::getHeight(int index) const
d->maxRenderThreadAnimations); d->maxRenderThreadAnimations);
} }
const QVariantList PaintEventsModelProxy::getLabels() const QVariantList PaintEventsModelProxy::labels() const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
QVariantList result; QVariantList result;
...@@ -236,7 +236,7 @@ const QVariantList PaintEventsModelProxy::getLabels() const ...@@ -236,7 +236,7 @@ const QVariantList PaintEventsModelProxy::getLabels() const
return result; return result;
} }
const QVariantList PaintEventsModelProxy::getEventDetails(int index) const QVariantList PaintEventsModelProxy::details(int index) const
{ {
Q_D(const PaintEventsModelProxy); Q_D(const PaintEventsModelProxy);
QVariantList result; QVariantList result;
......
...@@ -66,18 +66,18 @@ public: ...@@ -66,18 +66,18 @@ public:
int rowMaxValue(int rowNumber) const; int rowMaxValue(int rowNumber) const;
Q_INVOKABLE int rowCount() const; int rowCount() const;
Q_INVOKABLE int getEventId(int index) const;