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
return d->count();
}
int AbstractTimelineModel::findFirstIndex(qint64 startTime) const
int AbstractTimelineModel::firstIndex(qint64 startTime) const
{
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);
return d->findFirstIndexNoParents(startTime);
return d->firstIndexNoParents(startTime);
}
int AbstractTimelineModel::findLastIndex(qint64 endTime) const
int AbstractTimelineModel::lastIndex(qint64 endTime) const
{
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);
return d->duration(index);
}
qint64 AbstractTimelineModel::getStartTime(int index) const
qint64 AbstractTimelineModel::startTime(int index) const
{
Q_D(const AbstractTimelineModel);
return d->startTime(index);
}
qint64 AbstractTimelineModel::getEndTime(int index) const
qint64 AbstractTimelineModel::endTime(int index) const
{
Q_D(const AbstractTimelineModel);
return d->startTime(index) + d->duration(index);
......@@ -183,20 +183,20 @@ qint64 AbstractTimelineModel::traceDuration() const
return d->modelManager->traceTime()->duration();
}
const QVariantMap AbstractTimelineModel::getEventLocation(int index) const
QVariantMap AbstractTimelineModel::location(int index) const
{
Q_UNUSED(index);
QVariantMap map;
return map;
}
int AbstractTimelineModel::getEventIdForTypeIndex(int typeIndex) const
int AbstractTimelineModel::eventIdForTypeIndex(int typeIndex) const
{
Q_UNUSED(typeIndex);
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(line);
......@@ -204,13 +204,13 @@ int AbstractTimelineModel::getEventIdForLocation(const QString &filename, int li
return -1;
}
int AbstractTimelineModel::getBindingLoopDest(int index) const
int AbstractTimelineModel::bindingLoopDest(int index) const
{
Q_UNUSED(index);
return -1;
}
float AbstractTimelineModel::getHeight(int index) const
float AbstractTimelineModel::height(int index) const
{
Q_UNUSED(index);
return 1.0f;
......@@ -245,7 +245,7 @@ void AbstractTimelineModel::dataChanged()
d->rowOffsets.clear();
}
bool AbstractTimelineModel::eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
bool AbstractTimelineModel::accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const
{
Q_D(const AbstractTimelineModel);
return (event.rangeType == d->rangeType && event.message == d->message);
......
......@@ -58,38 +58,38 @@ public:
void setRowHeight(int rowNumber, int height);
int height() const;
Q_INVOKABLE qint64 traceStartTime() const;
Q_INVOKABLE qint64 traceEndTime() const;
Q_INVOKABLE qint64 traceDuration() const;
Q_INVOKABLE qint64 getDuration(int index) const;
Q_INVOKABLE qint64 getStartTime(int index) const;
Q_INVOKABLE qint64 getEndTime(int index) const;
int findFirstIndex(qint64 startTime) const;
int findFirstIndexNoParents(qint64 startTime) const;
int findLastIndex(qint64 endTime) const;
qint64 traceStartTime() const;
qint64 traceEndTime() const;
qint64 traceDuration() const;
qint64 duration(int index) const;
qint64 startTime(int index) const;
qint64 endTime(int index) const;
int firstIndex(qint64 startTime) const;
int firstIndexNoParents(qint64 startTime) const;
int lastIndex(qint64 endTime) const;
int count() const;
bool eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool expanded() const;
void setExpanded(bool expanded);
QString displayName() const;
// Methods that have to be implemented by child models
virtual int rowCount() const = 0;
Q_INVOKABLE virtual int getEventId(int index) const = 0;
Q_INVOKABLE virtual QColor getColor(int index) const = 0;
virtual const QVariantList getLabels() const = 0;
Q_INVOKABLE virtual const QVariantList getEventDetails(int index) const = 0;
virtual int getEventRow(int index) const = 0;
virtual int eventId(int index) const = 0;
virtual QColor color(int index) const = 0;
virtual QVariantList labels() const = 0;
virtual QVariantList details(int index) const = 0;
virtual int row(int index) const = 0;
virtual void loadData() = 0;
virtual void clear() = 0;
// Methods which can optionally be implemented by child models.
// returned map should contain "file", "line", "column" properties, or be empty
Q_INVOKABLE virtual const QVariantMap getEventLocation(int index) const;
Q_INVOKABLE virtual int getEventIdForTypeIndex(int typeIndex) const;
Q_INVOKABLE virtual int getEventIdForLocation(const QString &filename, int line, int column) const;
Q_INVOKABLE virtual int getBindingLoopDest(int index) const;
Q_INVOKABLE virtual float getHeight(int index) const;
virtual QVariantMap location(int index) const;
virtual int eventIdForTypeIndex(int typeIndex) const;
virtual int eventIdForLocation(const QString &filename, int line, int column) const;
virtual int bindingLoopDest(int index) const;
virtual float height(int index) const;
virtual int rowMinValue(int rowNumber) const;
virtual int rowMaxValue(int rowNumber) const;
......@@ -108,17 +108,17 @@ protected:
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);
}
......
......@@ -43,9 +43,9 @@ public:
virtual qint64 startTime(int index) const = 0;
virtual qint64 lastEndTime() const = 0;
virtual qint64 firstStartTime() const = 0;
virtual int findFirstIndex(qint64 startTime) const = 0;
virtual int findFirstIndexNoParents(qint64 startTime) const = 0;
virtual int findLastIndex(qint64 endTime) const = 0;
virtual int firstIndex(qint64 startTime) const = 0;
virtual int firstIndexNoParents(qint64 startTime) const = 0;
virtual int lastIndex(qint64 endTime) const = 0;
QVector<int> rowOffsets;
QmlProfilerModelManager *modelManager;
......
......@@ -54,7 +54,7 @@ Item {
height: trigger(qmlProfilerModelProxy.height(modelIndex))
width: 150
function getDescriptions() {
function updateDescriptions() {
bindingTrigger = -bindingTrigger;
if (!visible)
return;
......@@ -62,7 +62,7 @@ Item {
var desc=[];
var ids=[];
var extdesc=[];
var labelList = qmlProfilerModelProxy.getLabels(modelIndex);
var labelList = qmlProfilerModelProxy.labels(modelIndex);
for (var i = 0; i < labelList.length; i++ ) {
extdesc[i] = desc[i] = (labelList[i].description || qsTr("<bytecode>"));
ids[i] = labelList[i].id;
......@@ -76,9 +76,9 @@ Item {
Connections {
target: qmlProfilerModelProxy
onExpandedChanged: getDescriptions();
onStateChanged: getDescriptions()
onRowHeightChanged: getDescriptions()
onExpandedChanged: updateDescriptions();
onStateChanged: updateDescriptions()
onRowHeightChanged: updateDescriptions()
}
Text {
......
......@@ -135,10 +135,10 @@ Rectangle {
return;
// if item is outside of the view, jump back to its position
if (qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex) < view.startTime ||
qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) > view.endTime) {
recenter((qmlProfilerModelProxy.getStartTime(modelIndex, itemIndex) +
qmlProfilerModelProxy.getEndTime(modelIndex, itemIndex)) / 2);
if (qmlProfilerModelProxy.endTime(modelIndex, itemIndex) < view.startTime ||
qmlProfilerModelProxy.startTime(modelIndex, itemIndex) > view.endTime) {
recenter((qmlProfilerModelProxy.startTime(modelIndex, itemIndex) +
qmlProfilerModelProxy.endTime(modelIndex, itemIndex)) / 2);
}
}
......@@ -155,7 +155,7 @@ Rectangle {
function selectById(modelIndex, eventId)
{
if (eventId === -1 || (modelIndex === view.selectedModel &&
eventId === qmlProfilerModelProxy.getEventId(modelIndex, view.selectedItem)))
eventId === qmlProfilerModelProxy.eventId(modelIndex, view.selectedItem)))
return;
// this is a slot responding to events from the other pane
......@@ -348,16 +348,18 @@ Rectangle {
onSelectionChanged: {
if (selectedItem !== -1) {
// display details
rangeDetails.showInfo(qmlProfilerModelProxy.getEventDetails(selectedModel, selectedItem));
rangeDetails.setLocation(qmlProfilerModelProxy.getEventLocation(selectedModel, selectedItem));
rangeDetails.showInfo(qmlProfilerModelProxy.details(selectedModel,
selectedItem));
rangeDetails.setLocation(qmlProfilerModelProxy.location(selectedModel,
selectedItem));
// center view (horizontally)
recenterOnItem(selectedModel, selectedItem);
if (!lockItemSelection) {
lockItemSelection = true;
// update in other views
var eventLocation = qmlProfilerModelProxy.getEventLocation(
view.selectedModel, view.selectedItem);
var eventLocation = qmlProfilerModelProxy.location(view.selectedModel,
view.selectedItem);
gotoSourceLocation(eventLocation.file, eventLocation.line,
eventLocation.column);
lockItemSelection = false;
......@@ -368,7 +370,7 @@ Rectangle {
}
onItemPressed: {
var location = qmlProfilerModelProxy.getEventLocation(modelIndex, pressedItem);
var location = qmlProfilerModelProxy.location(modelIndex, pressedItem);
if (location.hasOwnProperty("file")) // not empty
root.gotoSourceLocation(location.file, location.line, location.column);
}
......@@ -470,7 +472,7 @@ Rectangle {
var fixedPoint = (view.startTime + view.endTime) / 2;
if (view.selectedItem !== -1) {
// 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)
fixedPoint = newFixedPoint;
}
......
......@@ -56,20 +56,20 @@ function drawData(canvas, ctxt)
for (var ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) {
var xx = (qmlProfilerModelProxy.getStartTime(modelIndex,ii) -
var xx = (qmlProfilerModelProxy.startTime(modelIndex,ii) -
qmlProfilerModelProxy.traceStartTime()) * spacing;
var eventWidth = qmlProfilerModelProxy.getDuration(modelIndex,ii) * spacing;
var eventWidth = qmlProfilerModelProxy.duration(modelIndex,ii) * spacing;
if (eventWidth < 1)
eventWidth = 1;
xx = Math.round(xx);
var itemHeight = qmlProfilerModelProxy.getHeight(modelIndex,ii) * blockHeight;
var itemHeight = qmlProfilerModelProxy.height(modelIndex,ii) * blockHeight;
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);
}
}
......@@ -81,9 +81,9 @@ function drawData(canvas, ctxt)
for (modelIndex = 0; modelIndex < qmlProfilerModelProxy.modelCount(); ++modelIndex) {
for (ii = canvas.offset; ii < qmlProfilerModelProxy.count(modelIndex);
ii += canvas.increment) {
if (qmlProfilerModelProxy.getBindingLoopDest(modelIndex,ii) >= 0) {
var xcenter = Math.round(qmlProfilerModelProxy.getStartTime(modelIndex,ii) +
qmlProfilerModelProxy.getDuration(modelIndex,ii) -
if (qmlProfilerModelProxy.bindingLoopDest(modelIndex,ii) >= 0) {
var xcenter = Math.round(qmlProfilerModelProxy.startTime(modelIndex,ii) +
qmlProfilerModelProxy.duration(modelIndex,ii) -
qmlProfilerModelProxy.traceStartTime()) * spacing;
var ycenter = Math.round(bump + blockHeight * modelIndex + blockHeight / 2);
ctxt.beginPath();
......
......@@ -78,9 +78,9 @@ void PaintEventsModelProxy::clear()
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;
}
......@@ -101,7 +101,7 @@ void PaintEventsModelProxy::loadData()
foreach (const QmlProfilerDataModel::QmlEventData &event, referenceList) {
const QmlProfilerDataModel::QmlEventTypeData &type = typeList[event.typeIndex];
if (!eventAccepted(type))
if (!accepted(type))
continue;
lastEvent.threadId = (QmlDebug::AnimationThread)event.numericData3;
......@@ -160,7 +160,7 @@ int PaintEventsModelProxy::PaintEventsModelProxyPrivate::rowFromThreadId(
return (threadId == QmlDebug::GuiThread || maxGuiThreadAnimations == 0) ? 1 : 2;
}
int PaintEventsModelProxy::getEventRow(int index) const
int PaintEventsModelProxy::row(int index) const
{
Q_D(const PaintEventsModelProxy);
return d->rowFromThreadId(d->range(index).threadId);
......@@ -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);
return d->range(index).threadId;
}
QColor PaintEventsModelProxy::getColor(int index) const
QColor PaintEventsModelProxy::color(int index) const
{
Q_D(const PaintEventsModelProxy);
double fpsFraction = d->range(index).framerate / 60.0;
......@@ -194,10 +194,10 @@ QColor PaintEventsModelProxy::getColor(int index) const
fpsFraction = 1.0;
if (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);
const PaintEventsModelProxyPrivate::Range &range = d->range(index);
......@@ -212,7 +212,7 @@ float PaintEventsModelProxy::getHeight(int index) const
d->maxRenderThreadAnimations);
}
const QVariantList PaintEventsModelProxy::getLabels() const
QVariantList PaintEventsModelProxy::labels() const
{
Q_D(const PaintEventsModelProxy);
QVariantList result;
......@@ -236,7 +236,7 @@ const QVariantList PaintEventsModelProxy::getLabels() const
return result;
}
const QVariantList PaintEventsModelProxy::getEventDetails(int index) const
QVariantList PaintEventsModelProxy::details(int index) const
{
Q_D(const PaintEventsModelProxy);
QVariantList result;
......
......@@ -66,18 +66,18 @@ public:
int rowMaxValue(int rowNumber) const;
Q_INVOKABLE int rowCount() const;
Q_INVOKABLE int getEventId(int index) const;
int getEventRow(int index) const;
int rowCount() const;
int eventId(int index) const;
int row(int index) const;
Q_INVOKABLE QColor getColor(int index) const;
Q_INVOKABLE float getHeight(int index) const;
QColor color(int index) const;
float height(int index) const;
Q_INVOKABLE const QVariantList getLabels() const;
Q_INVOKABLE const QVariantList getEventDetails(int index) const;
QVariantList labels() const;
QVariantList details(int index) const;
private slots:
bool eventAccepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
bool accepted(const QmlProfilerDataModel::QmlEventTypeData &event) const;
private:
class PaintEventsModelProxyPrivate;
......
......@@ -99,7 +99,7 @@ void RangeTimelineModel::loadData()
const QVector<QmlProfilerDataModel::QmlEventTypeData> &typesList = simpleModel->getEventTypes();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
const QmlProfilerDataModel::QmlEventTypeData &type = typesList[event.typeIndex];
if (!eventAccepted(type))
if (!accepted(type))
continue;
if (type.rangeType == QmlDebug::Painting)
d->seenPaintEvent = true;
......@@ -239,7 +239,7 @@ QString RangeTimelineModel::categoryLabel(int categoryIndex)
}
}
int RangeTimelineModel::getEventRow(int index) const
int RangeTimelineModel::row(int index) const
{
Q_D(const RangeTimelineModel);
if (d->expanded)
......@@ -248,24 +248,24 @@ int RangeTimelineModel::getEventRow(int index) const
return d->range(index).displayRowCollapsed;
}
int RangeTimelineModel::getEventId(int index) const
int RangeTimelineModel::eventId(int index) const
{
Q_D(const RangeTimelineModel);
return d->range(index).eventId;
}
int RangeTimelineModel::getBindingLoopDest(int index) const
int RangeTimelineModel::bindingLoopDest(int index) const
{
Q_D(const RangeTimelineModel);
return d->range(index).bindingLoopHead;
}
QColor RangeTimelineModel::getColor(int index) const
QColor RangeTimelineModel::color(int index) const
{
return getEventColor(index);
return colorByEventId(index);
}
const QVariantList RangeTimelineModel::getLabels() const
QVariantList RangeTimelineModel::labels() const
{
Q_D(const RangeTimelineModel);
QVariantList result;
......@@ -287,11 +287,11 @@ const QVariantList RangeTimelineModel::getLabels() const
return result;
}
const QVariantList RangeTimelineModel::getEventDetails(int index) const
QVariantList RangeTimelineModel::details(int index) const
{
Q_D(const RangeTimelineModel);
QVariantList result;
int eventId = getEventId(index);
int id = eventId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes();
......@@ -313,7 +313,7 @@ const QVariantList RangeTimelineModel::getEventDetails(int index) const
// details
{
QVariantMap valuePair;
QString detailsString = types[eventId].data;
QString detailsString = types[id].data;
if (detailsString.length() > 40)
detailsString = detailsString.left(40) + QLatin1String("...");
valuePair.insert(QCoreApplication::translate(trContext, "Details:"),
......@@ -325,25 +325,24 @@ const QVariantList RangeTimelineModel::getEventDetails(int index) const
{
QVariantMap valuePair;
valuePair.insert(QCoreApplication::translate(trContext, "Location:"),
QVariant(types[eventId].displayName));
QVariant(types[id].displayName));
result << valuePair;
}
// isbindingloop
{}
return result;
}
const QVariantMap RangeTimelineModel::getEventLocation(int index) const
QVariantMap RangeTimelineModel::location(int index) const
{
Q_D(const RangeTimelineModel);
QVariantMap result;
int eventId = getEventId(index);
int id = eventId(index);
const QmlDebug::QmlEventLocation &location
= d->modelManager->qmlModel()->getEventTypes().at(eventId).location;
= d->modelManager->qmlModel()->getEventTypes().at(id).location;
result.insert(QStringLiteral("file"), location.filename);
result.insert(QStringLiteral("line"), location.line);
......@@ -352,7 +351,7 @@ const QVariantMap RangeTimelineModel::getEventLocation(int index) const
return result;
}
int RangeTimelineModel::getEventIdForTypeIndex(int typeIndex) const
int RangeTimelineModel::eventIdForTypeIndex(int typeIndex) const
{
Q_D(const RangeTimelineModel);
if (typeIndex < 0)
......@@ -364,7 +363,7 @@ int RangeTimelineModel::getEventIdForTypeIndex(int typeIndex) const
return typeIndex;
}
int RangeTimelineModel::getEventIdForLocation(const QString &filename, int line, int column) const
int RangeTimelineModel::eventIdForLocation(const QString &filename, int line, int column) const
{
Q_D(const RangeTimelineModel);
// if this is called from v8 view, we don't have the column number, it will be -1
......
......@@ -71,20 +71,20 @@ public:
// QML interface
Q_INVOKABLE int rowCount() const;
int rowCount() const;
static QString categoryLabel(int categoryIndex);
int getEventRow(int index) const;
Q_INVOKABLE int getEventId(int index) const;
int getBindingLoopDest(int index) const;
Q_INVOKABLE QColor getColor(int index) const;
int row(int index) const;
int eventId(int index) const;
int bindingLoopDest(int index) const;
QColor color(int index) const;
Q_INVOKABLE const QVariantList getLabels() const;
Q_INVOKABLE const QVariantList getEventDetails(int index) const;
Q_INVOKABLE const QVariantMap getEventLocation(int index) const;
QVariantList labels() const;
QVariantList details(int index) const;
QVariantMap location(int index) const;
Q_INVOKABLE int getEventIdForTypeIndex(int typeIndex) const;
Q_INVOKABLE int getEventIdForLocation(const QString &filename, int line, int column) const;
int eventIdForTypeIndex(int typeIndex) const;
int eventIdForLocation(const QString &filename, int line, int column) const;
private:
class RangeTimelineModelPrivate;
......
......@@ -265,7 +265,7 @@ void QmlProfilerTraceView::selectByTypeIndex(int typeIndex)
return;