Commit 38f4d6a5 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

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: default avatarKai Koehne <kai.koehne@digia.com>
parent 3af3878a
......@@ -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);
......
......@@ -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
......
......@@ -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]
......
......@@ -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;
......
......@@ -223,7 +223,7 @@ Item {
anchors.fill: parent
onClicked: {
root.hideRangeDetails();
view.selectFromId(view.selectedModel, -1);
view.selectFromEventIndex(view.selectedModel, -1);
}
}
}
......
......@@ -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());
}
}
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
}
}
......
......@@ -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:
......
......@@ -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)));
......
......@@ -67,7 +67,7 @@ QV8ProfilerDataModel::QV8EventData &QV8ProfilerDataModel::QV8EventData::operator
totalPercent = ref.totalPercent;
selfTime = ref.selfTime;