QmlProfiler: rename "eventId" fields to "typeId" and "selectionId"

The convention is now that selections are the rows in the expanded
timeline, "types" are the types in the QmlProfilerDataModel, and
events are the single boxes in the timeline. Thus, the event view
shows only types and for consistency the V8 view does so, too.

Having eventId as synonym for "type index" and "event index" as
actual index into the list of events is confusing.

Change-Id: I6b7c4c3f1ab0a8b71c511de52ab296a2e91cf5f0
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
Ulf Hermann
2014-08-29 16:32:42 +02:00
parent 3af3878ace
commit 38f4d6a5f2
23 changed files with 160 additions and 164 deletions

View File

@@ -152,13 +152,13 @@ QVariantMap AbstractTimelineModel::location(int index) const
return map;
}
int AbstractTimelineModel::eventIdForTypeIndex(int typeIndex) const
bool AbstractTimelineModel::isSelectionIdValid(int typeIndex) const
{
Q_UNUSED(typeIndex);
return -1;
return false;
}
int AbstractTimelineModel::eventIdForLocation(const QString &filename, int line, int column) const
int AbstractTimelineModel::selectionIdForLocation(const QString &filename, int line, int column) const
{
Q_UNUSED(filename);
Q_UNUSED(line);

View File

@@ -73,7 +73,7 @@ public:
int rowCount() const;
// Methods that have to be implemented by child models
virtual int eventId(int index) const = 0;
virtual int selectionId(int index) const = 0;
virtual QColor color(int index) const = 0;
virtual QVariantList labels() const = 0;
virtual QVariantMap details(int index) const = 0;
@@ -83,8 +83,8 @@ public:
// Methods which can optionally be implemented by child models.
// returned map should contain "file", "line", "column" properties, or be empty
virtual QVariantMap location(int index) const;
virtual int eventIdForTypeIndex(int typeIndex) const;
virtual int eventIdForLocation(const QString &filename, int line, int column) const;
virtual bool isSelectionIdValid(int selectionId) const;
virtual int selectionIdForLocation(const QString &filename, int line, int column) const;
virtual int bindingLoopDest(int index) const;
virtual float relativeHeight(int index) const;
virtual int rowMinValue(int rowNumber) const;
@@ -100,16 +100,16 @@ protected:
static const int DefaultRowHeight = 30;
enum BoxColorProperties {
EventHueMultiplier = 25,
SelectionIdHueMultiplier = 25,
FractionHueMultiplier = 96,
FractionHueMininimum = 10,
Saturation = 150,
Lightness = 166
};
QColor colorByEventId(int index) const
QColor colorBySelectionId(int index) const
{
return colorByHue(eventId(index) * EventHueMultiplier);
return colorByHue(selectionId(index) * SelectionIdHueMultiplier);
}
QColor colorByFraction(double fraction) const

View File

@@ -39,7 +39,7 @@ Item {
property int bindingTrigger: 1
property var descriptions: []
property var extdescriptions: []
property var eventIds: []
property var selectionIds: []
property bool dragging
property Item draggerParent
@@ -75,7 +75,7 @@ Item {
extdesc[i] += " (" + labelList[i].displayName + ")";
}
descriptions = desc;
eventIds = ids;
selectionIds = ids;
extdescriptions = extdesc;
}
@@ -148,9 +148,9 @@ Item {
action: Action {
onTriggered: {
if (reverseSelect)
view.selectPrevFromId(modelIndex,eventIds[index]);
view.selectPrevFromSelectionId(modelIndex,selectionIds[index]);
else
view.selectNextFromId(modelIndex,eventIds[index]);
view.selectNextFromSelectionId(modelIndex,selectionIds[index]);
}
tooltip: extdescriptions[index]

View File

@@ -153,19 +153,19 @@ Rectangle {
rangeDetails.isBindingLoop = false;
}
function selectById(modelIndex, eventId)
function selectBySelectionId(modelIndex, selectionId)
{
if (eventId === -1 || (modelIndex === view.selectedModel &&
eventId === qmlProfilerModelProxy.eventId(modelIndex, view.selectedItem)))
if (selectionId === -1 || (modelIndex === view.selectedModel &&
selectionId === qmlProfilerModelProxy.selectionId(modelIndex, view.selectedItem)))
return;
// this is a slot responding to events from the other pane
// which tracks only events from the basic model
if (!lockItemSelection) {
lockItemSelection = true;
var itemIndex = view.nextItemFromId(modelIndex, eventId);
var itemIndex = view.nextItemFromSelectionId(modelIndex, selectionId);
// select an item, lock to it, and recenter if necessary
view.selectFromId(modelIndex, itemIndex); // triggers recentering
view.selectFromEventIndex(modelIndex, itemIndex); // triggers recentering
if (itemIndex !== -1)
view.selectionLocked = true;
lockItemSelection = false;

View File

@@ -223,7 +223,7 @@ Item {
anchors.fill: parent
onClicked: {
root.hideRangeDetails();
view.selectFromId(view.selectedModel, -1);
view.selectFromEventIndex(view.selectedModel, -1);
}
}
}

View File

@@ -151,8 +151,7 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
d->m_eventTree = new QmlProfilerEventsMainView(this, d->modelProxy);
connect(d->m_eventTree, SIGNAL(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
connect(d->m_eventTree, SIGNAL(eventSelected(int)),
this, SIGNAL(eventSelectedByTypeIndex(int)));
connect(d->m_eventTree, SIGNAL(typeSelected(int)), this, SIGNAL(typeSelected(int)));
d->m_eventChildren = new QmlProfilerEventRelativesView(
profilerModelManager,
@@ -162,10 +161,10 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
profilerModelManager,
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
this);
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventChildren, SLOT(displayEvent(int)));
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventParents, SLOT(displayEvent(int)));
connect(d->m_eventChildren, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
connect(d->m_eventParents, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventChildren, SLOT(displayType(int)));
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventParents, SLOT(displayType(int)));
connect(d->m_eventChildren, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
connect(d->m_eventParents, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
// widget arrangement
QVBoxLayout *groupLayout = new QVBoxLayout;
@@ -214,9 +213,9 @@ void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 ran
d->modelProxy->limitToRange(rangeStart, rangeEnd);
}
QModelIndex QmlProfilerEventsWidget::selectedItem() const
QModelIndex QmlProfilerEventsWidget::selectedModelIndex() const
{
return d->m_eventTree->selectedItem();
return d->m_eventTree->selectedModelIndex();
}
void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
@@ -243,7 +242,7 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
if (mouseOnTable(position)) {
menu.addSeparator();
if (selectedItem().isValid())
if (selectedModelIndex().isValid())
copyRowAction = menu.addAction(tr("Copy Row"));
copyTableAction = menu.addAction(tr("Copy Table"));
@@ -315,13 +314,13 @@ void QmlProfilerEventsWidget::copyRowToClipboard() const
void QmlProfilerEventsWidget::updateSelectedEvent(int typeIndex) const
{
if (d->m_eventTree->selectedTypeIndex() != typeIndex)
d->m_eventTree->selectEvent(typeIndex);
if (d->m_eventTree->selectedTypeId() != typeIndex)
d->m_eventTree->selectType(typeIndex);
}
void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column)
{
d->m_eventTree->selectEventByLocation(filename, line, column);
d->m_eventTree->selectByLocation(filename, line, column);
}
bool QmlProfilerEventsWidget::hasGlobalStats() const
@@ -659,7 +658,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
item->setEditable(false);
// metadata
newRow.at(0)->setData(QVariant(typeIndex),EventTypeIndexRole);
newRow.at(0)->setData(QVariant(typeIndex),TypeIdRole);
newRow.at(0)->setData(QVariant(event.location.filename),FilenameRole);
newRow.at(0)->setData(QVariant(event.location.line),LineRole);
newRow.at(0)->setData(QVariant(event.location.column),ColumnRole);
@@ -695,13 +694,13 @@ void QmlProfilerEventsMainView::getStatisticsInRange(qint64 rangeStart, qint64 r
d->modelProxy->limitToRange(rangeStart, rangeEnd);
}
int QmlProfilerEventsMainView::selectedTypeIndex() const
int QmlProfilerEventsMainView::selectedTypeId() const
{
QModelIndex index = selectedItem();
QModelIndex index = selectedModelIndex();
if (!index.isValid())
return -1;
QStandardItem *item = d->m_model->item(index.row(), 0);
return item->data(EventTypeIndexRole).toInt();
return item->data(TypeIdRole).toInt();
}
@@ -726,7 +725,7 @@ void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
emit gotoSourceLocation(fileName, line, column);
// show in callers/callees subwindow
emit eventSelected(infoItem->data(EventTypeIndexRole).toInt());
emit typeSelected(infoItem->data(TypeIdRole).toInt());
d->m_preventSelectBounce = false;
}
@@ -741,18 +740,18 @@ void QmlProfilerEventsMainView::selectItem(const QStandardItem *item)
}
}
void QmlProfilerEventsMainView::selectEvent(int typeIndex)
void QmlProfilerEventsMainView::selectType(int typeIndex)
{
for (int i=0; i<d->m_model->rowCount(); i++) {
QStandardItem *infoItem = d->m_model->item(i, 0);
if (infoItem->data(EventTypeIndexRole).toInt() == typeIndex) {
if (infoItem->data(TypeIdRole).toInt() == typeIndex) {
selectItem(infoItem);
return;
}
}
}
void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, int line, int column)
void QmlProfilerEventsMainView::selectByLocation(const QString &filename, int line, int column)
{
if (d->m_preventSelectBounce)
return;
@@ -769,7 +768,7 @@ void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, i
}
}
QModelIndex QmlProfilerEventsMainView::selectedItem() const
QModelIndex QmlProfilerEventsMainView::selectedModelIndex() const
{
QModelIndexList sel = selectedIndexes();
if (sel.isEmpty())
@@ -833,7 +832,7 @@ void QmlProfilerEventsMainView::copyTableToClipboard() const
void QmlProfilerEventsMainView::copyRowToClipboard() const
{
QString str;
str = d->textForItem(d->m_model->itemFromIndex(selectedItem()), false);
str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false);
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(str, QClipboard::Selection);
@@ -876,7 +875,7 @@ QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView()
delete d;
}
void QmlProfilerEventRelativesView::displayEvent(int typeIndex)
void QmlProfilerEventRelativesView::displayType(int typeIndex)
{
rebuildTree(d->modelProxy->getData(typeIndex));
@@ -914,7 +913,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") :
type.data);
newRow.at(0)->setData(QVariant(typeIndex), EventTypeIndexRole);
newRow.at(0)->setData(QVariant(typeIndex), TypeIdRole);
newRow.at(0)->setData(QVariant(type.location.filename),FilenameRole);
newRow.at(0)->setData(QVariant(type.location.line),LineRole);
newRow.at(0)->setData(QVariant(type.location.column),ColumnRole);
@@ -981,7 +980,7 @@ void QmlProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
{
if (treeModel()) {
QStandardItem *infoItem = treeModel()->item(index.row(), 0);
emit eventClicked(infoItem->data(EventTypeIndexRole).toInt());
emit typeClicked(infoItem->data(TypeIdRole).toInt());
}
}

View File

@@ -49,11 +49,10 @@ class QmlProfilerEventRelativesView;
enum ItemRole {
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string
EventTypeIndexRole,
TypeIdRole,
FilenameRole,
LineRole,
ColumnRole,
EventIdRole
ColumnRole
};
class QmlProfilerEventsWidget : public QWidget
@@ -69,7 +68,7 @@ public:
void clear();
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
QModelIndex selectedItem() const;
QModelIndex selectedModelIndex() const;
bool mouseOnTable(const QPoint &position) const;
void copyTableToClipboard() const;
void copyRowToClipboard() const;
@@ -86,7 +85,7 @@ public:
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelectedByTypeIndex(int typeIndex);
void typeSelected(int typeIndex);
void resized();
public slots:
@@ -116,14 +115,14 @@ public:
void setFieldViewable(Fields field, bool show);
void setShowAnonymousEvents( bool showThem );
QModelIndex selectedItem() const;
QModelIndex selectedModelIndex() const;
void copyTableToClipboard() const;
void copyRowToClipboard() const;
static QString nameForType(QmlDebug::RangeType typeNumber);
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
int selectedTypeIndex() const;
int selectedTypeId() const;
void setShowExtendedStatistics(bool);
bool showExtendedStatistics() const;
@@ -131,13 +130,13 @@ public:
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelected(int typeIndex);
void typeSelected(int typeIndex);
public slots:
void clear();
void jumpToItem(const QModelIndex &index);
void selectEvent(int typeIndex);
void selectEventByLocation(const QString &filename, int line, int column);
void selectType(int typeIndex);
void selectByLocation(const QString &filename, int line, int column);
void buildModel();
private slots:
@@ -164,10 +163,10 @@ public:
~QmlProfilerEventRelativesView();
signals:
void eventClicked(int typeIndex);
void typeClicked(int typeIndex);
public slots:
void displayEvent(int typeIndex);
void displayType(int typeIndex);
void jumpToItem(const QModelIndex &);
void clear();

View File

@@ -173,7 +173,7 @@ int PaintEventsModelProxy::rowMaxValue(int rowNumber) const
}
}
int PaintEventsModelProxy::eventId(int index) const
int PaintEventsModelProxy::selectionId(int index) const
{
Q_D(const PaintEventsModelProxy);
return d->data[index].threadId;

View File

@@ -63,7 +63,7 @@ public:
int rowMaxValue(int rowNumber) const;
int eventId(int index) const;
int selectionId(int index) const;
int row(int index) const;
QColor color(int index) const;

View File

@@ -162,12 +162,12 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeExpandedLevels()
QHash<int, int> eventRow;
int eventCount = q->count();
for (int i = 0; i < eventCount; i++) {
int eventId = data[i].eventId;
if (!eventRow.contains(eventId)) {
eventRow[eventId] = expandedRowTypes.size();
expandedRowTypes << eventId;
int typeId = data[i].typeId;
if (!eventRow.contains(typeId)) {
eventRow[typeId] = expandedRowTypes.size();
expandedRowTypes << typeId;
}
data[i].displayRowExpanded = eventRow[eventId];
data[i].displayRowExpanded = eventRow[typeId];
}
expandedRowCount = expandedRowTypes.size();
}
@@ -194,14 +194,14 @@ void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops()
// check whether event is already in stack
for (int ii = 0; ii < callStack.size(); ++ii) {
if (callStack.at(ii).first == data[i].eventId) {
if (callStack.at(ii).first == data[i].typeId) {
data[i].bindingLoopHead = callStack.at(ii).second;
break;
}
}
CallStackEntry newEntry(data[i].eventId, i);
CallStackEntry newEntry(data[i].typeId, i);
callStack.push(newEntry);
}
@@ -224,10 +224,10 @@ int RangeTimelineModel::row(int index) const
return d->data[index].displayRowCollapsed;
}
int RangeTimelineModel::eventId(int index) const
int RangeTimelineModel::selectionId(int index) const
{
Q_D(const RangeTimelineModel);
return d->data[index].eventId;
return d->data[index].typeId;
}
int RangeTimelineModel::bindingLoopDest(int index) const
@@ -238,7 +238,7 @@ int RangeTimelineModel::bindingLoopDest(int index) const
QColor RangeTimelineModel::color(int index) const
{
return colorByEventId(index);
return colorBySelectionId(index);
}
QVariantList RangeTimelineModel::labels() const
@@ -266,7 +266,7 @@ QVariantMap RangeTimelineModel::details(int index) const
{
Q_D(const RangeTimelineModel);
QVariantMap result;
int id = eventId(index);
int id = selectionId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes();
@@ -282,7 +282,7 @@ QVariantMap RangeTimelineModel::location(int index) const
{
Q_D(const RangeTimelineModel);
QVariantMap result;
int id = eventId(index);
int id = selectionId(index);
const QmlDebug::QmlEventLocation &location
= d->modelManager->qmlModel()->getEventTypes().at(id).location;
@@ -294,19 +294,19 @@ QVariantMap RangeTimelineModel::location(int index) const
return result;
}
int RangeTimelineModel::eventIdForTypeIndex(int typeIndex) const
bool RangeTimelineModel::isSelectionIdValid(int typeId) const
{
Q_D(const RangeTimelineModel);
if (typeIndex < 0)
return -1;
if (typeId < 0)
return false;
const QmlProfilerDataModel::QmlEventTypeData &type =
d->modelManager->qmlModel()->getEventTypes().at(typeIndex);
d->modelManager->qmlModel()->getEventTypes().at(typeId);
if (type.message != d->message || type.rangeType != d->rangeType)
return -1;
return typeIndex;
return false;
return true;
}
int RangeTimelineModel::eventIdForLocation(const QString &filename, int line, int column) const
int RangeTimelineModel::selectionIdForLocation(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

View File

@@ -49,13 +49,13 @@ class RangeTimelineModel : public AbstractTimelineModel
public:
struct QmlRangeEventStartInstance {
QmlRangeEventStartInstance(int eventId = -1) :
eventId(eventId),
QmlRangeEventStartInstance(int typeId = -1) :
typeId(typeId),
displayRowExpanded(QmlDebug::Constants::QML_MIN_LEVEL),
displayRowCollapsed(QmlDebug::Constants::QML_MIN_LEVEL),
bindingLoopHead(-1) {}
int eventId;
int typeId;
// not-expanded, per type
int displayRowExpanded;
@@ -69,7 +69,7 @@ public:
quint64 features() const;
int row(int index) const;
int eventId(int index) const;
int selectionId(int index) const;
int bindingLoopDest(int index) const;
QColor color(int index) const;
@@ -77,8 +77,8 @@ public:
QVariantMap details(int index) const;
QVariantMap location(int index) const;
int eventIdForTypeIndex(int typeIndex) const;
int eventIdForLocation(const QString &filename, int line, int column) const;
bool isSelectionIdValid(int typeIndex) const;
int selectionIdForLocation(const QString &filename, int line, int column) const;
protected:
void loadData();

View File

@@ -258,18 +258,17 @@ void QmlProfilerTraceView::clear()
QMetaObject::invokeMethod(d->m_mainView->rootObject(), "clear");
}
void QmlProfilerTraceView::selectByTypeIndex(int typeIndex)
void QmlProfilerTraceView::selectByTypeId(int typeId)
{
QQuickItem *rootObject = d->m_mainView->rootObject();
if (!rootObject)
return;
for (int modelIndex = 0; modelIndex < d->m_modelProxy->modelCount(); ++modelIndex) {
int eventId = d->m_modelProxy->eventIdForTypeIndex(modelIndex, typeIndex);
if (eventId != -1) {
QMetaObject::invokeMethod(rootObject, "selectById",
if (d->m_modelProxy->isSelectionIdValid(modelIndex, typeId)) {
QMetaObject::invokeMethod(rootObject, "selectBySelectionId",
Q_ARG(QVariant,QVariant(modelIndex)),
Q_ARG(QVariant,QVariant(eventId)));
Q_ARG(QVariant,QVariant(typeId)));
return;
}
}
@@ -282,11 +281,11 @@ void QmlProfilerTraceView::selectBySourceLocation(const QString &filename, int l
return;
for (int modelIndex = 0; modelIndex < d->m_modelProxy->modelCount(); ++modelIndex) {
int eventId = d->m_modelProxy->eventIdForLocation(modelIndex, filename, line, column);
if (eventId != -1) {
QMetaObject::invokeMethod(rootObject, "selectById",
int typeId = d->m_modelProxy->selectionIdForLocation(modelIndex, filename, line, column);
if (typeId != -1) {
QMetaObject::invokeMethod(rootObject, "selectBySelectionId",
Q_ARG(QVariant,QVariant(modelIndex)),
Q_ARG(QVariant,QVariant(eventId)));
Q_ARG(QVariant,QVariant(typeId)));
return;
}
}

View File

@@ -100,7 +100,7 @@ public:
public slots:
void clear();
void selectByTypeIndex(int typeIndex);
void selectByTypeId(int typeId);
void selectBySourceLocation(const QString &filename, int line, int column);
private slots:

View File

@@ -107,8 +107,7 @@ void QmlProfilerViewManager::createViews()
d->eventsView->setWindowTitle(tr("Events"));
connect(d->eventsView, SIGNAL(gotoSourceLocation(QString,int,int)), this,
SIGNAL(gotoSourceLocation(QString,int,int)));
connect(d->eventsView, SIGNAL(eventSelectedByTypeIndex(int)),
d->traceView, SLOT(selectByTypeIndex(int)));
connect(d->eventsView, SIGNAL(typeSelected(int)), d->traceView, SLOT(selectByTypeId(int)));
connect(d->traceView, SIGNAL(gotoSourceLocation(QString,int,int)),
d->eventsView, SLOT(selectBySourceLocation(QString,int,int)));

View File

@@ -67,7 +67,7 @@ QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator
totalPercent = ref.totalPercent;
selfTime = ref.selfTime;
SelfTimeInPercent = ref.SelfTimeInPercent;
eventId = ref.eventId;
typeId = ref.typeId;
qDeleteAll(parentHash);
parentHash = cloneEventHash(ref.parentHash);
@@ -81,7 +81,7 @@ QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator
QV8ProfilerDataModel::QV8EventData::QV8EventData()
{
line = -1;
eventId = -1;
typeId = -1;
totalTime = 0;
selfTime = 0;
totalPercent = 0;
@@ -141,11 +141,11 @@ bool QV8ProfilerDataModel::isEmpty() const
return d->v8EventHash.isEmpty();
}
QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int eventId) const
QV8ProfilerDataModel::QV8EventData *QV8ProfilerDataModel::v8EventDescription(int typeId) const
{
Q_D(const QV8ProfilerDataModel);
foreach (QV8EventData *event, d->v8EventHash) {
if (event->eventId == eventId)
if (event->typeId == typeId)
return event;
}
return 0;
@@ -287,13 +287,13 @@ void QV8ProfilerDataModel::complete()
int index = d->pendingRewrites.size();
foreach (QV8EventData *v8event, d->v8EventHash.values()) {
v8event->eventId = index++;
v8event->typeId = index++;
d->pendingRewrites << v8event;
d->detailsRewriter->requestDetailsForLocation(index,
QmlDebug::QmlEventLocation(v8event->filename, v8event->line, 1));
}
d->v8RootEvent.eventId = d->v8EventHash[rootEventHash]->eventId;
d->v8RootEvent.typeId = d->v8EventHash[rootEventHash]->typeId;
} else {
// On empty data, still add a fake root event
clearV8RootEvent();
@@ -314,7 +314,7 @@ void QV8ProfilerDataModel::clearV8RootEvent()
d->v8RootEvent.totalPercent = 0;
d->v8RootEvent.selfTime = 0;
d->v8RootEvent.SelfTimeInPercent = 0;
d->v8RootEvent.eventId = -1;
d->v8RootEvent.typeId = -1;
qDeleteAll(d->v8RootEvent.parentHash.values());
qDeleteAll(d->v8RootEvent.childrenHash.values());
@@ -347,7 +347,7 @@ void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
QStringList childrenTimes;
QStringList parentTimes;
foreach (const QV8EventSub *v8child, v8event->childrenHash) {
childrenIndexes << QString::number(v8child->reference->eventId);
childrenIndexes << QString::number(v8child->reference->typeId);
childrenTimes << QString::number(v8child->totalTime);
parentTimes << QString::number(v8child->totalTime);
}

View File

@@ -63,7 +63,7 @@ public:
double SelfTimeInPercent;
QHash <QString, QV8EventSub *> parentHash;
QHash <QString, QV8EventSub *> childrenHash;
int eventId;
int typeId;
QV8EventData &operator=(const QV8EventData &ref);
};
@@ -81,7 +81,7 @@ public:
void clear();
bool isEmpty() const;
QList<QV8EventData *> getV8Events() const;
QV8EventData *v8EventDescription(int eventId) const;
QV8EventData *v8EventDescription(int typeId) const;
qint64 v8MeasuredTime() const;

View File

@@ -61,7 +61,7 @@ enum ItemRole {
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed text
FilenameRole,
LineRole,
EventIdRole
TypeIdRole
};
////////////////////////////////////////////////////////////////////////////////////
@@ -132,10 +132,10 @@ QV8ProfilerEventsWidget::QV8ProfilerEventsWidget(QWidget *parent,
d->m_eventParents = new QV8ProfilerEventRelativesView(d->v8Model,
QV8ProfilerEventRelativesView::ParentsView,
this);
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventChildren, SLOT(displayEvent(int)));
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventParents, SLOT(displayEvent(int)));
connect(d->m_eventChildren, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
connect(d->m_eventParents, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int)));
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventChildren, SLOT(displayType(int)));
connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventParents, SLOT(displayType(int)));
connect(d->m_eventChildren, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
connect(d->m_eventParents, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
connect(d->v8Model, SIGNAL(changed()), this, SLOT(updateEnabledState()));
// widget arrangement
@@ -242,10 +242,10 @@ void QV8ProfilerEventsWidget::copyRowToClipboard() const
d->m_eventTree->copyRowToClipboard();
}
void QV8ProfilerEventsWidget::updateSelectedEvent(int eventId) const
void QV8ProfilerEventsWidget::updateSelectedType(int typeId) const
{
if (d->m_eventTree->selectedEventId() != eventId)
d->m_eventTree->selectEvent(eventId);
if (d->m_eventTree->selectedTypeId() != typeId)
d->m_eventTree->selectType(typeId);
}
void QV8ProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column)
@@ -474,7 +474,7 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
QStandardItem *firstItem = newRow.at(0);
firstItem->setData(QVariant(v8event->filename), FilenameRole);
firstItem->setData(QVariant(v8event->line), LineRole);
firstItem->setData(QVariant(v8event->eventId), EventIdRole);
firstItem->setData(QVariant(v8event->typeId), TypeIdRole);
// append
m_model->invisibleRootItem()->appendRow(newRow);
@@ -482,13 +482,13 @@ void QV8ProfilerEventsMainView::QV8ProfilerEventsMainViewPrivate::buildV8ModelFr
}
}
int QV8ProfilerEventsMainView::selectedEventId() const
int QV8ProfilerEventsMainView::selectedTypeId() const
{
QModelIndex index = selectedItem();
if (!index.isValid())
return -1;
QStandardItem *item = d->m_model->item(index.row(), 0);
return item->data(EventIdRole).toInt();
return item->data(TypeIdRole).toInt();
}
void QV8ProfilerEventsMainView::jumpToItem(const QModelIndex &index)
@@ -511,16 +511,16 @@ void QV8ProfilerEventsMainView::jumpToItem(const QModelIndex &index)
emit gotoSourceLocation(fileName, line, -1);
// show in callers/callees subwindow
emit eventSelected(infoItem->data(EventIdRole).toInt());
emit typeSelected(infoItem->data(TypeIdRole).toInt());
d->m_preventSelectBounce = false;
}
void QV8ProfilerEventsMainView::selectEvent(int eventId)
void QV8ProfilerEventsMainView::selectType(int typeId)
{
for (int i=0; i<d->m_model->rowCount(); i++) {
QStandardItem *infoItem = d->m_model->item(i, 0);
if (infoItem->data(EventIdRole).toInt() == eventId) {
if (infoItem->data(TypeIdRole).toInt() == typeId) {
setCurrentIndex(d->m_model->indexFromItem(infoItem));
jumpToItem(currentIndex());
return;
@@ -639,7 +639,7 @@ QV8ProfilerEventRelativesView::~QV8ProfilerEventRelativesView()
{
}
void QV8ProfilerEventRelativesView::displayEvent(int index)
void QV8ProfilerEventRelativesView::displayType(int index)
{
QV8ProfilerDataModel::QV8EventData *event = m_v8Model->v8EventDescription(index);
QTC_CHECK(event);
@@ -670,7 +670,7 @@ void QV8ProfilerEventRelativesView::rebuildTree(QList<QV8ProfilerDataModel::QV8E
newRow << new V8ViewItem(QmlProfilerBaseModel::formatTime(event->totalTime));
newRow << new V8ViewItem(event->reference->functionName);
newRow.at(0)->setData(QVariant(event->reference->eventId), EventIdRole);
newRow.at(0)->setData(QVariant(event->reference->typeId), TypeIdRole);
newRow.at(0)->setData(QVariant(event->reference->filename), FilenameRole);
newRow.at(0)->setData(QVariant(event->reference->line), LineRole);
newRow.at(1)->setData(QVariant(event->totalTime));
@@ -709,7 +709,7 @@ void QV8ProfilerEventRelativesView::updateHeader()
void QV8ProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
{
QStandardItem *infoItem = m_model->item(index.row(), 0);
emit eventClicked(infoItem->data(EventIdRole).toInt());
emit typeClicked(infoItem->data(TypeIdRole).toInt());
}
} // namespace Internal

View File

@@ -72,7 +72,7 @@ signals:
void resized();
public slots:
void updateSelectedEvent(int eventId) const;
void updateSelectedType(int typeId) const;
void selectBySourceLocation(const QString &filename, int line, int column);
void updateEnabledState();
@@ -101,19 +101,19 @@ public:
void copyTableToClipboard() const;
void copyRowToClipboard() const;
int selectedEventId() const;
int selectedTypeId() const;
void setShowExtendedStatistics(bool);
bool showExtendedStatistics() const;
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelected(int eventId);
void typeSelected(int typeId);
public slots:
void clear();
void jumpToItem(const QModelIndex &index);
void selectEvent(int eventId);
void selectType(int typeId);
void selectEventByLocation(const QString &filename, int line);
void buildModel();
@@ -139,10 +139,10 @@ public:
~QV8ProfilerEventRelativesView();
signals:
void eventClicked(int eventId);
void typeClicked(int typeId);
public slots:
void displayEvent(int eventId);
void displayType(int typeId);
void jumpToItem(const QModelIndex &);
void clear();

View File

@@ -220,9 +220,9 @@ qint64 TimelineModelAggregator::endTime(int modelIndex, int index) const
return d->modelList[modelIndex]->endTime(index);
}
int TimelineModelAggregator::eventId(int modelIndex, int index) const
int TimelineModelAggregator::selectionId(int modelIndex, int index) const
{
return d->modelList[modelIndex]->eventId(index);
return d->modelList[modelIndex]->selectionId(index);
}
int TimelineModelAggregator::bindingLoopDest(int modelIndex,int index) const
@@ -255,15 +255,15 @@ QVariantMap TimelineModelAggregator::location(int modelIndex, int index) const
return d->modelList[modelIndex]->location(index);
}
int TimelineModelAggregator::eventIdForTypeIndex(int modelIndex, int typeIndex) const
bool TimelineModelAggregator::isSelectionIdValid(int modelIndex, int typeIndex) const
{
return d->modelList[modelIndex]->eventIdForTypeIndex(typeIndex);
return d->modelList[modelIndex]->isSelectionIdValid(typeIndex);
}
int TimelineModelAggregator::eventIdForLocation(int modelIndex, const QString &filename,
int TimelineModelAggregator::selectionIdForLocation(int modelIndex, const QString &filename,
int line, int column) const
{
return d->modelList[modelIndex]->eventIdForLocation(filename, line, column);
return d->modelList[modelIndex]->selectionIdForLocation(filename, line, column);
}
void TimelineModelAggregator::swapModels(int modelIndex1, int modelIndex2)

View File

@@ -82,7 +82,7 @@ public:
Q_INVOKABLE qint64 duration(int modelIndex, int index) const;
Q_INVOKABLE qint64 startTime(int modelIndex, int index) const;
Q_INVOKABLE qint64 endTime(int modelIndex, int index) const;
Q_INVOKABLE int eventId(int modelIndex, int index) const;
Q_INVOKABLE int selectionId(int modelIndex, int index) const;
Q_INVOKABLE int bindingLoopDest(int modelIndex, int index) const;
Q_INVOKABLE QColor color(int modelIndex, int index) const;
Q_INVOKABLE float relativeHeight(int modelIndex, int index) const;
@@ -92,8 +92,8 @@ public:
Q_INVOKABLE QVariantMap details(int modelIndex, int index) const;
Q_INVOKABLE QVariantMap location(int modelIndex, int index) const;
Q_INVOKABLE int eventIdForTypeIndex(int modelIndex, int typeIndex) const;
Q_INVOKABLE int eventIdForLocation(int modelIndex, const QString &filename, int line,
Q_INVOKABLE bool isSelectionIdValid(int modelIndex, int typeIndex) const;
Q_INVOKABLE int selectionIdForLocation(int modelIndex, const QString &filename, int line,
int column) const;
Q_INVOKABLE void swapModels(int modelIndex1, int modelIndex2);

View File

@@ -199,7 +199,7 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
return;
int id = m_profilerModelProxy->eventId(modelIndex, m_selectedItem);
int id = m_profilerModelProxy->selectionId(modelIndex, m_selectedItem);
int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++)
@@ -219,7 +219,7 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
int currentX, currentY, itemWidth;
QRect selectedItemRect(0,0,0,0);
for (int i = fromIndex; i <= toIndex; i++) {
if (m_profilerModelProxy->eventId(modelIndex, i) != id)
if (m_profilerModelProxy->selectionId(modelIndex, i) != id)
continue;
int row = m_profilerModelProxy->row(modelIndex, i);
@@ -377,11 +377,11 @@ void TimelineRenderer::manageClicked()
// itemPressed() will trigger an update of the events and JavaScript views. Make sure the
// correct event is already selected when that happens, to prevent confusion.
selectFromId(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
selectFromEventIndex(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
emit itemPressed(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
} else {
setSelectionLocked(false);
selectFromId(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
selectFromEventIndex(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
}
}
@@ -436,7 +436,7 @@ void TimelineRenderer::manageHovered(int mouseX, int mouseY)
m_currentSelection.row = row;
m_currentSelection.modelIndex = modelIndex;
if (!m_selectionLocked)
selectFromId(modelIndex, i);
selectFromEventIndex(modelIndex, i);
return;
}
}
@@ -528,7 +528,7 @@ void TimelineRenderer::selectNext()
}
}
selectFromId(candidateModelIndex, itemIndex);
selectFromEventIndex(candidateModelIndex, itemIndex);
}
void TimelineRenderer::selectPrev()
@@ -580,10 +580,10 @@ void TimelineRenderer::selectPrev()
}
}
selectFromId(candidateModelIndex, itemIndex);
selectFromEventIndex(candidateModelIndex, itemIndex);
}
int TimelineRenderer::nextItemFromId(int modelIndex, int eventId) const
int TimelineRenderer::nextItemFromSelectionId(int modelIndex, int selectionId) const
{
int ndx = -1;
if (m_selectedItem == -1)
@@ -596,14 +596,14 @@ int TimelineRenderer::nextItemFromId(int modelIndex, int eventId) const
ndx = 0;
int startIndex = ndx;
do {
if (m_profilerModelProxy->eventId(modelIndex, ndx) == eventId)
if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
return ndx;
ndx = (ndx + 1) % m_profilerModelProxy->count(modelIndex);
} while (ndx != startIndex);
return -1;
}
int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
int TimelineRenderer::prevItemFromSelectionId(int modelIndex, int selectionId) const
{
int ndx = -1;
if (m_selectedItem == -1)
@@ -614,7 +614,7 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
ndx = m_profilerModelProxy->count(modelIndex) - 1;
int startIndex = ndx;
do {
if (m_profilerModelProxy->eventId(modelIndex, ndx) == eventId)
if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
return ndx;
if (--ndx < 0)
ndx = m_profilerModelProxy->count(modelIndex)-1;
@@ -622,7 +622,7 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
return -1;
}
void TimelineRenderer::selectFromId(int modelIndex, int eventIndex)
void TimelineRenderer::selectFromEventIndex(int modelIndex, int eventIndex)
{
if (modelIndex != m_selectedModel || eventIndex != m_selectedItem) {
setSelectedModel(modelIndex);
@@ -631,12 +631,12 @@ void TimelineRenderer::selectFromId(int modelIndex, int eventIndex)
}
}
void TimelineRenderer::selectNextFromId(int modelIndex, int eventId)
void TimelineRenderer::selectNextFromSelectionId(int modelIndex, int typeId)
{
selectFromId(modelIndex, nextItemFromId(modelIndex, eventId));
selectFromEventIndex(modelIndex, nextItemFromSelectionId(modelIndex, typeId));
}
void TimelineRenderer::selectPrevFromId(int modelIndex, int eventId)
void TimelineRenderer::selectPrevFromSelectionId(int modelIndex, int typeId)
{
selectFromId(modelIndex, prevItemFromId(modelIndex, eventId));
selectFromEventIndex(modelIndex, prevItemFromSelectionId(modelIndex, typeId));
}

View File

@@ -95,11 +95,11 @@ public:
Q_INVOKABLE void selectNext();
Q_INVOKABLE void selectPrev();
Q_INVOKABLE int nextItemFromId(int modelIndex, int eventId) const;
Q_INVOKABLE int prevItemFromId(int modelIndex, int eventId) const;
Q_INVOKABLE void selectFromId(int modelIndex, int eventId);
Q_INVOKABLE void selectNextFromId(int modelIndex, int eventId);
Q_INVOKABLE void selectPrevFromId(int modelIndex, int eventId);
Q_INVOKABLE int nextItemFromSelectionId(int modelIndex, int selectionId) const;
Q_INVOKABLE int prevItemFromSelectionId(int modelIndex, int selectionId) const;
Q_INVOKABLE void selectFromEventIndex(int modelIndex, int index);
Q_INVOKABLE void selectNextFromSelectionId(int modelIndex, int selectionId);
Q_INVOKABLE void selectPrevFromSelectionId(int modelIndex, int selectionId);
signals:
void startTimeChanged(qint64 arg);

View File

@@ -48,7 +48,7 @@ public:
DummyModel(QString displayName = tr("dummy"), QObject *parent = 0);
const QmlProfilerModelManager *modelManager() const;
int rowCount() const;
int eventId(int index) const { return index; }
int selectionId(int index) const { return index; }
QColor color(int) const { return QColor(); }
QVariantList labels() const { return QVariantList(); }
QVariantMap details(int) const { return QVariantMap(); }
@@ -82,7 +82,7 @@ private slots:
void displayName();
void defaultValues();
void colorByHue();
void colorByEventId();
void colorByTypeId();
void colorByFraction();
};
@@ -284,8 +284,8 @@ void tst_AbstractTimelineModel::defaultValues()
DummyModel dummy;
dummy.loadData();
QCOMPARE(dummy.location(0), QVariantMap());
QCOMPARE(dummy.eventIdForTypeIndex(0), -1);
QCOMPARE(dummy.eventIdForLocation(QString(), 0, 0), -1);
QCOMPARE(dummy.isSelectionIdValid(0), false);
QCOMPARE(dummy.selectionIdForLocation(QString(), 0, 0), -1);
QCOMPARE(dummy.bindingLoopDest(0), -1);
QCOMPARE(dummy.relativeHeight(0), 1.0);
QCOMPARE(dummy.rowMinValue(0), 0);
@@ -299,11 +299,11 @@ void tst_AbstractTimelineModel::colorByHue()
QCOMPARE(dummy.colorByHue(500), QColor::fromHsl(140, 150, 166));
}
void tst_AbstractTimelineModel::colorByEventId()
void tst_AbstractTimelineModel::colorByTypeId()
{
DummyModel dummy;
dummy.loadData();
QCOMPARE(dummy.colorByEventId(5), QColor::fromHsl(5 * 25, 150, 166));
QCOMPARE(dummy.colorBySelectionId(5), QColor::fromHsl(5 * 25, 150, 166));
}
void tst_AbstractTimelineModel::colorByFraction()