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; return map;
} }
int AbstractTimelineModel::eventIdForTypeIndex(int typeIndex) const bool AbstractTimelineModel::isSelectionIdValid(int typeIndex) const
{ {
Q_UNUSED(typeIndex); 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(filename);
Q_UNUSED(line); Q_UNUSED(line);

View File

@@ -73,7 +73,7 @@ public:
int rowCount() const; int rowCount() const;
// Methods that have to be implemented by child models // 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 QColor color(int index) const = 0;
virtual QVariantList labels() const = 0; virtual QVariantList labels() const = 0;
virtual QVariantMap details(int index) const = 0; virtual QVariantMap details(int index) const = 0;
@@ -83,8 +83,8 @@ public:
// 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
virtual QVariantMap location(int index) const; virtual QVariantMap location(int index) const;
virtual int eventIdForTypeIndex(int typeIndex) const; virtual bool isSelectionIdValid(int selectionId) const;
virtual int eventIdForLocation(const QString &filename, int line, int column) const; virtual int selectionIdForLocation(const QString &filename, int line, int column) const;
virtual int bindingLoopDest(int index) const; virtual int bindingLoopDest(int index) const;
virtual float relativeHeight(int index) const; virtual float relativeHeight(int index) const;
virtual int rowMinValue(int rowNumber) const; virtual int rowMinValue(int rowNumber) const;
@@ -100,16 +100,16 @@ protected:
static const int DefaultRowHeight = 30; static const int DefaultRowHeight = 30;
enum BoxColorProperties { enum BoxColorProperties {
EventHueMultiplier = 25, SelectionIdHueMultiplier = 25,
FractionHueMultiplier = 96, FractionHueMultiplier = 96,
FractionHueMininimum = 10, FractionHueMininimum = 10,
Saturation = 150, Saturation = 150,
Lightness = 166 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 QColor colorByFraction(double fraction) const

View File

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

View File

@@ -153,19 +153,19 @@ Rectangle {
rangeDetails.isBindingLoop = false; rangeDetails.isBindingLoop = false;
} }
function selectById(modelIndex, eventId) function selectBySelectionId(modelIndex, selectionId)
{ {
if (eventId === -1 || (modelIndex === view.selectedModel && if (selectionId === -1 || (modelIndex === view.selectedModel &&
eventId === qmlProfilerModelProxy.eventId(modelIndex, view.selectedItem))) selectionId === qmlProfilerModelProxy.selectionId(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
// which tracks only events from the basic model // which tracks only events from the basic model
if (!lockItemSelection) { if (!lockItemSelection) {
lockItemSelection = true; lockItemSelection = true;
var itemIndex = view.nextItemFromId(modelIndex, eventId); var itemIndex = view.nextItemFromSelectionId(modelIndex, selectionId);
// select an item, lock to it, and recenter if necessary // 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) if (itemIndex !== -1)
view.selectionLocked = true; view.selectionLocked = true;
lockItemSelection = false; lockItemSelection = false;

View File

@@ -223,7 +223,7 @@ Item {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
root.hideRangeDetails(); 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); 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(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
connect(d->m_eventTree, SIGNAL(eventSelected(int)), connect(d->m_eventTree, SIGNAL(typeSelected(int)), this, SIGNAL(typeSelected(int)));
this, SIGNAL(eventSelectedByTypeIndex(int)));
d->m_eventChildren = new QmlProfilerEventRelativesView( d->m_eventChildren = new QmlProfilerEventRelativesView(
profilerModelManager, profilerModelManager,
@@ -162,10 +161,10 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
profilerModelManager, profilerModelManager,
new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this), new QmlProfilerEventParentsModelProxy(profilerModelManager, d->modelProxy, this),
this); this);
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventChildren, SLOT(displayEvent(int))); connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventChildren, SLOT(displayType(int)));
connect(d->m_eventTree, SIGNAL(eventSelected(int)), d->m_eventParents, SLOT(displayEvent(int))); connect(d->m_eventTree, SIGNAL(typeSelected(int)), d->m_eventParents, SLOT(displayType(int)));
connect(d->m_eventChildren, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int))); connect(d->m_eventChildren, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
connect(d->m_eventParents, SIGNAL(eventClicked(int)), d->m_eventTree, SLOT(selectEvent(int))); connect(d->m_eventParents, SIGNAL(typeClicked(int)), d->m_eventTree, SLOT(selectType(int)));
// widget arrangement // widget arrangement
QVBoxLayout *groupLayout = new QVBoxLayout; QVBoxLayout *groupLayout = new QVBoxLayout;
@@ -214,9 +213,9 @@ void QmlProfilerEventsWidget::getStatisticsInRange(qint64 rangeStart, qint64 ran
d->modelProxy->limitToRange(rangeStart, rangeEnd); 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) void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
@@ -243,7 +242,7 @@ void QmlProfilerEventsWidget::contextMenuEvent(QContextMenuEvent *ev)
if (mouseOnTable(position)) { if (mouseOnTable(position)) {
menu.addSeparator(); menu.addSeparator();
if (selectedItem().isValid()) if (selectedModelIndex().isValid())
copyRowAction = menu.addAction(tr("Copy Row")); copyRowAction = menu.addAction(tr("Copy Row"));
copyTableAction = menu.addAction(tr("Copy Table")); copyTableAction = menu.addAction(tr("Copy Table"));
@@ -315,13 +314,13 @@ void QmlProfilerEventsWidget::copyRowToClipboard() const
void QmlProfilerEventsWidget::updateSelectedEvent(int typeIndex) const void QmlProfilerEventsWidget::updateSelectedEvent(int typeIndex) const
{ {
if (d->m_eventTree->selectedTypeIndex() != typeIndex) if (d->m_eventTree->selectedTypeId() != typeIndex)
d->m_eventTree->selectEvent(typeIndex); d->m_eventTree->selectType(typeIndex);
} }
void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column) 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 bool QmlProfilerEventsWidget::hasGlobalStats() const
@@ -659,7 +658,7 @@ void QmlProfilerEventsMainView::parseModelProxy()
item->setEditable(false); item->setEditable(false);
// metadata // 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.filename),FilenameRole);
newRow.at(0)->setData(QVariant(event.location.line),LineRole); newRow.at(0)->setData(QVariant(event.location.line),LineRole);
newRow.at(0)->setData(QVariant(event.location.column),ColumnRole); 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); d->modelProxy->limitToRange(rangeStart, rangeEnd);
} }
int QmlProfilerEventsMainView::selectedTypeIndex() const int QmlProfilerEventsMainView::selectedTypeId() const
{ {
QModelIndex index = selectedItem(); QModelIndex index = selectedModelIndex();
if (!index.isValid()) if (!index.isValid())
return -1; return -1;
QStandardItem *item = d->m_model->item(index.row(), 0); 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); emit gotoSourceLocation(fileName, line, column);
// show in callers/callees subwindow // show in callers/callees subwindow
emit eventSelected(infoItem->data(EventTypeIndexRole).toInt()); emit typeSelected(infoItem->data(TypeIdRole).toInt());
d->m_preventSelectBounce = false; 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++) { for (int i=0; i<d->m_model->rowCount(); i++) {
QStandardItem *infoItem = d->m_model->item(i, 0); QStandardItem *infoItem = d->m_model->item(i, 0);
if (infoItem->data(EventTypeIndexRole).toInt() == typeIndex) { if (infoItem->data(TypeIdRole).toInt() == typeIndex) {
selectItem(infoItem); selectItem(infoItem);
return; 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) if (d->m_preventSelectBounce)
return; return;
@@ -769,7 +768,7 @@ void QmlProfilerEventsMainView::selectEventByLocation(const QString &filename, i
} }
} }
QModelIndex QmlProfilerEventsMainView::selectedItem() const QModelIndex QmlProfilerEventsMainView::selectedModelIndex() const
{ {
QModelIndexList sel = selectedIndexes(); QModelIndexList sel = selectedIndexes();
if (sel.isEmpty()) if (sel.isEmpty())
@@ -833,7 +832,7 @@ void QmlProfilerEventsMainView::copyTableToClipboard() const
void QmlProfilerEventsMainView::copyRowToClipboard() const void QmlProfilerEventsMainView::copyRowToClipboard() const
{ {
QString str; QString str;
str = d->textForItem(d->m_model->itemFromIndex(selectedItem()), false); str = d->textForItem(d->m_model->itemFromIndex(selectedModelIndex()), false);
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(str, QClipboard::Selection); clipboard->setText(str, QClipboard::Selection);
@@ -876,7 +875,7 @@ QmlProfilerEventRelativesView::~QmlProfilerEventRelativesView()
delete d; delete d;
} }
void QmlProfilerEventRelativesView::displayEvent(int typeIndex) void QmlProfilerEventRelativesView::displayType(int typeIndex)
{ {
rebuildTree(d->modelProxy->getData(typeIndex)); rebuildTree(d->modelProxy->getData(typeIndex));
@@ -914,7 +913,7 @@ void QmlProfilerEventRelativesView::rebuildTree(
newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") : newRow << new EventsViewItem(type.data.isEmpty() ? tr("Source code not available") :
type.data); 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.filename),FilenameRole);
newRow.at(0)->setData(QVariant(type.location.line),LineRole); newRow.at(0)->setData(QVariant(type.location.line),LineRole);
newRow.at(0)->setData(QVariant(type.location.column),ColumnRole); newRow.at(0)->setData(QVariant(type.location.column),ColumnRole);
@@ -981,7 +980,7 @@ void QmlProfilerEventRelativesView::jumpToItem(const QModelIndex &index)
{ {
if (treeModel()) { if (treeModel()) {
QStandardItem *infoItem = treeModel()->item(index.row(), 0); 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 { enum ItemRole {
SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string SortRole = Qt::UserRole + 1, // Sort by data, not by displayed string
EventTypeIndexRole, TypeIdRole,
FilenameRole, FilenameRole,
LineRole, LineRole,
ColumnRole, ColumnRole
EventIdRole
}; };
class QmlProfilerEventsWidget : public QWidget class QmlProfilerEventsWidget : public QWidget
@@ -69,7 +68,7 @@ public:
void clear(); void clear();
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd); void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
QModelIndex selectedItem() const; QModelIndex selectedModelIndex() const;
bool mouseOnTable(const QPoint &position) const; bool mouseOnTable(const QPoint &position) const;
void copyTableToClipboard() const; void copyTableToClipboard() const;
void copyRowToClipboard() const; void copyRowToClipboard() const;
@@ -86,7 +85,7 @@ public:
signals: signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelectedByTypeIndex(int typeIndex); void typeSelected(int typeIndex);
void resized(); void resized();
public slots: public slots:
@@ -116,14 +115,14 @@ public:
void setFieldViewable(Fields field, bool show); void setFieldViewable(Fields field, bool show);
void setShowAnonymousEvents( bool showThem ); void setShowAnonymousEvents( bool showThem );
QModelIndex selectedItem() const; QModelIndex selectedModelIndex() const;
void copyTableToClipboard() const; void copyTableToClipboard() const;
void copyRowToClipboard() const; void copyRowToClipboard() const;
static QString nameForType(QmlDebug::RangeType typeNumber); static QString nameForType(QmlDebug::RangeType typeNumber);
void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd); void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd);
int selectedTypeIndex() const; int selectedTypeId() const;
void setShowExtendedStatistics(bool); void setShowExtendedStatistics(bool);
bool showExtendedStatistics() const; bool showExtendedStatistics() const;
@@ -131,13 +130,13 @@ public:
signals: signals:
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber); void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelected(int typeIndex); void typeSelected(int typeIndex);
public slots: public slots:
void clear(); void clear();
void jumpToItem(const QModelIndex &index); void jumpToItem(const QModelIndex &index);
void selectEvent(int typeIndex); void selectType(int typeIndex);
void selectEventByLocation(const QString &filename, int line, int column); void selectByLocation(const QString &filename, int line, int column);
void buildModel(); void buildModel();
private slots: private slots:
@@ -164,10 +163,10 @@ public:
~QmlProfilerEventRelativesView(); ~QmlProfilerEventRelativesView();
signals: signals:
void eventClicked(int typeIndex); void typeClicked(int typeIndex);
public slots: public slots:
void displayEvent(int typeIndex); void displayType(int typeIndex);
void jumpToItem(const QModelIndex &); void jumpToItem(const QModelIndex &);
void clear(); 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); Q_D(const PaintEventsModelProxy);
return d->data[index].threadId; return d->data[index].threadId;

View File

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

View File

@@ -162,12 +162,12 @@ void RangeTimelineModel::RangeTimelineModelPrivate::computeExpandedLevels()
QHash<int, int> eventRow; QHash<int, int> eventRow;
int eventCount = q->count(); int eventCount = q->count();
for (int i = 0; i < eventCount; i++) { for (int i = 0; i < eventCount; i++) {
int eventId = data[i].eventId; int typeId = data[i].typeId;
if (!eventRow.contains(eventId)) { if (!eventRow.contains(typeId)) {
eventRow[eventId] = expandedRowTypes.size(); eventRow[typeId] = expandedRowTypes.size();
expandedRowTypes << eventId; expandedRowTypes << typeId;
} }
data[i].displayRowExpanded = eventRow[eventId]; data[i].displayRowExpanded = eventRow[typeId];
} }
expandedRowCount = expandedRowTypes.size(); expandedRowCount = expandedRowTypes.size();
} }
@@ -194,14 +194,14 @@ void RangeTimelineModel::RangeTimelineModelPrivate::findBindingLoops()
// check whether event is already in stack // check whether event is already in stack
for (int ii = 0; ii < callStack.size(); ++ii) { 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; data[i].bindingLoopHead = callStack.at(ii).second;
break; break;
} }
} }
CallStackEntry newEntry(data[i].eventId, i); CallStackEntry newEntry(data[i].typeId, i);
callStack.push(newEntry); callStack.push(newEntry);
} }
@@ -224,10 +224,10 @@ int RangeTimelineModel::row(int index) const
return d->data[index].displayRowCollapsed; return d->data[index].displayRowCollapsed;
} }
int RangeTimelineModel::eventId(int index) const int RangeTimelineModel::selectionId(int index) const
{ {
Q_D(const RangeTimelineModel); Q_D(const RangeTimelineModel);
return d->data[index].eventId; return d->data[index].typeId;
} }
int RangeTimelineModel::bindingLoopDest(int index) const int RangeTimelineModel::bindingLoopDest(int index) const
@@ -238,7 +238,7 @@ int RangeTimelineModel::bindingLoopDest(int index) const
QColor RangeTimelineModel::color(int index) const QColor RangeTimelineModel::color(int index) const
{ {
return colorByEventId(index); return colorBySelectionId(index);
} }
QVariantList RangeTimelineModel::labels() const QVariantList RangeTimelineModel::labels() const
@@ -266,7 +266,7 @@ QVariantMap RangeTimelineModel::details(int index) const
{ {
Q_D(const RangeTimelineModel); Q_D(const RangeTimelineModel);
QVariantMap result; QVariantMap result;
int id = eventId(index); int id = selectionId(index);
const QVector<QmlProfilerDataModel::QmlEventTypeData> &types = const QVector<QmlProfilerDataModel::QmlEventTypeData> &types =
d->modelManager->qmlModel()->getEventTypes(); d->modelManager->qmlModel()->getEventTypes();
@@ -282,7 +282,7 @@ QVariantMap RangeTimelineModel::location(int index) const
{ {
Q_D(const RangeTimelineModel); Q_D(const RangeTimelineModel);
QVariantMap result; QVariantMap result;
int id = eventId(index); int id = selectionId(index);
const QmlDebug::QmlEventLocation &location const QmlDebug::QmlEventLocation &location
= d->modelManager->qmlModel()->getEventTypes().at(id).location; = d->modelManager->qmlModel()->getEventTypes().at(id).location;
@@ -294,19 +294,19 @@ QVariantMap RangeTimelineModel::location(int index) const
return result; return result;
} }
int RangeTimelineModel::eventIdForTypeIndex(int typeIndex) const bool RangeTimelineModel::isSelectionIdValid(int typeId) const
{ {
Q_D(const RangeTimelineModel); Q_D(const RangeTimelineModel);
if (typeIndex < 0) if (typeId < 0)
return -1; return false;
const QmlProfilerDataModel::QmlEventTypeData &type = 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) if (type.message != d->message || type.rangeType != d->rangeType)
return -1; return false;
return typeIndex; 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); Q_D(const RangeTimelineModel);
// if this is called from v8 view, we don't have the column number, it will be -1 // 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: public:
struct QmlRangeEventStartInstance { struct QmlRangeEventStartInstance {
QmlRangeEventStartInstance(int eventId = -1) : QmlRangeEventStartInstance(int typeId = -1) :
eventId(eventId), typeId(typeId),
displayRowExpanded(QmlDebug::Constants::QML_MIN_LEVEL), displayRowExpanded(QmlDebug::Constants::QML_MIN_LEVEL),
displayRowCollapsed(QmlDebug::Constants::QML_MIN_LEVEL), displayRowCollapsed(QmlDebug::Constants::QML_MIN_LEVEL),
bindingLoopHead(-1) {} bindingLoopHead(-1) {}
int eventId; int typeId;
// not-expanded, per type // not-expanded, per type
int displayRowExpanded; int displayRowExpanded;
@@ -69,7 +69,7 @@ public:
quint64 features() const; quint64 features() const;
int row(int index) const; int row(int index) const;
int eventId(int index) const; int selectionId(int index) const;
int bindingLoopDest(int index) const; int bindingLoopDest(int index) const;
QColor color(int index) const; QColor color(int index) const;
@@ -77,8 +77,8 @@ public:
QVariantMap details(int index) const; QVariantMap details(int index) const;
QVariantMap location(int index) const; QVariantMap location(int index) const;
int eventIdForTypeIndex(int typeIndex) const; bool isSelectionIdValid(int typeIndex) const;
int eventIdForLocation(const QString &filename, int line, int column) const; int selectionIdForLocation(const QString &filename, int line, int column) const;
protected: protected:
void loadData(); void loadData();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -220,9 +220,9 @@ qint64 TimelineModelAggregator::endTime(int modelIndex, int index) const
return d->modelList[modelIndex]->endTime(index); 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 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); 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 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) 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 duration(int modelIndex, int index) const;
Q_INVOKABLE qint64 startTime(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 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 int bindingLoopDest(int modelIndex, int index) const;
Q_INVOKABLE QColor color(int modelIndex, int index) const; Q_INVOKABLE QColor color(int modelIndex, int index) const;
Q_INVOKABLE float relativeHeight(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 details(int modelIndex, int index) const;
Q_INVOKABLE QVariantMap location(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 bool isSelectionIdValid(int modelIndex, int typeIndex) const;
Q_INVOKABLE int eventIdForLocation(int modelIndex, const QString &filename, int line, Q_INVOKABLE int selectionIdForLocation(int modelIndex, const QString &filename, int line,
int column) const; int column) const;
Q_INVOKABLE void swapModels(int modelIndex1, int modelIndex2); Q_INVOKABLE void swapModels(int modelIndex1, int modelIndex2);

View File

@@ -199,7 +199,7 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
return; return;
int id = m_profilerModelProxy->eventId(modelIndex, m_selectedItem); int id = m_profilerModelProxy->selectionId(modelIndex, m_selectedItem);
int modelRowStart = 0; int modelRowStart = 0;
for (int mi = 0; mi < modelIndex; mi++) for (int mi = 0; mi < modelIndex; mi++)
@@ -219,7 +219,7 @@ void TimelineRenderer::drawSelectionBoxes(QPainter *p, int modelIndex, int fromI
int currentX, currentY, itemWidth; int currentX, currentY, itemWidth;
QRect selectedItemRect(0,0,0,0); QRect selectedItemRect(0,0,0,0);
for (int i = fromIndex; i <= toIndex; i++) { for (int i = fromIndex; i <= toIndex; i++) {
if (m_profilerModelProxy->eventId(modelIndex, i) != id) if (m_profilerModelProxy->selectionId(modelIndex, i) != id)
continue; continue;
int row = m_profilerModelProxy->row(modelIndex, i); 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 // 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. // 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); emit itemPressed(m_currentSelection.modelIndex, m_currentSelection.eventIndex);
} else { } else {
setSelectionLocked(false); 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.row = row;
m_currentSelection.modelIndex = modelIndex; m_currentSelection.modelIndex = modelIndex;
if (!m_selectionLocked) if (!m_selectionLocked)
selectFromId(modelIndex, i); selectFromEventIndex(modelIndex, i);
return; return;
} }
} }
@@ -528,7 +528,7 @@ void TimelineRenderer::selectNext()
} }
} }
selectFromId(candidateModelIndex, itemIndex); selectFromEventIndex(candidateModelIndex, itemIndex);
} }
void TimelineRenderer::selectPrev() 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; int ndx = -1;
if (m_selectedItem == -1) if (m_selectedItem == -1)
@@ -596,14 +596,14 @@ int TimelineRenderer::nextItemFromId(int modelIndex, int eventId) const
ndx = 0; ndx = 0;
int startIndex = ndx; int startIndex = ndx;
do { do {
if (m_profilerModelProxy->eventId(modelIndex, ndx) == eventId) if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
return ndx; return ndx;
ndx = (ndx + 1) % m_profilerModelProxy->count(modelIndex); ndx = (ndx + 1) % m_profilerModelProxy->count(modelIndex);
} while (ndx != startIndex); } while (ndx != startIndex);
return -1; return -1;
} }
int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const int TimelineRenderer::prevItemFromSelectionId(int modelIndex, int selectionId) const
{ {
int ndx = -1; int ndx = -1;
if (m_selectedItem == -1) if (m_selectedItem == -1)
@@ -614,7 +614,7 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
ndx = m_profilerModelProxy->count(modelIndex) - 1; ndx = m_profilerModelProxy->count(modelIndex) - 1;
int startIndex = ndx; int startIndex = ndx;
do { do {
if (m_profilerModelProxy->eventId(modelIndex, ndx) == eventId) if (m_profilerModelProxy->selectionId(modelIndex, ndx) == selectionId)
return ndx; return ndx;
if (--ndx < 0) if (--ndx < 0)
ndx = m_profilerModelProxy->count(modelIndex)-1; ndx = m_profilerModelProxy->count(modelIndex)-1;
@@ -622,7 +622,7 @@ int TimelineRenderer::prevItemFromId(int modelIndex, int eventId) const
return -1; return -1;
} }
void TimelineRenderer::selectFromId(int modelIndex, int eventIndex) void TimelineRenderer::selectFromEventIndex(int modelIndex, int eventIndex)
{ {
if (modelIndex != m_selectedModel || eventIndex != m_selectedItem) { if (modelIndex != m_selectedModel || eventIndex != m_selectedItem) {
setSelectedModel(modelIndex); 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 selectNext();
Q_INVOKABLE void selectPrev(); Q_INVOKABLE void selectPrev();
Q_INVOKABLE int nextItemFromId(int modelIndex, int eventId) const; Q_INVOKABLE int nextItemFromSelectionId(int modelIndex, int selectionId) const;
Q_INVOKABLE int prevItemFromId(int modelIndex, int eventId) const; Q_INVOKABLE int prevItemFromSelectionId(int modelIndex, int selectionId) const;
Q_INVOKABLE void selectFromId(int modelIndex, int eventId); Q_INVOKABLE void selectFromEventIndex(int modelIndex, int index);
Q_INVOKABLE void selectNextFromId(int modelIndex, int eventId); Q_INVOKABLE void selectNextFromSelectionId(int modelIndex, int selectionId);
Q_INVOKABLE void selectPrevFromId(int modelIndex, int eventId); Q_INVOKABLE void selectPrevFromSelectionId(int modelIndex, int selectionId);
signals: signals:
void startTimeChanged(qint64 arg); void startTimeChanged(qint64 arg);

View File

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