QmlProfiler: reading column information in bindings

Change-Id: I1a99c3508de733d98eb99f41419eccfdca030fe0
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Christiaan Janssen
2012-01-12 16:36:40 +01:00
parent 4894c559ac
commit 1958fd82d5
15 changed files with 104 additions and 66 deletions

View File

@@ -62,6 +62,7 @@ Rectangle {
signal updateCursorPosition
property string fileName: ""
property int lineNumber: -1
property int columnNumber: 0
property real elapsedTime
signal updateTimer
@@ -131,9 +132,10 @@ Rectangle {
}
// ***** functions
function gotoSourceLocation(file,line) {
function gotoSourceLocation(file,line,column) {
root.fileName = file;
root.lineNumber = line;
root.columnNumber = column;
root.updateCursorPosition();
}
@@ -265,6 +267,7 @@ Rectangle {
rangeDetails.type = "";
rangeDetails.file = "";
rangeDetails.line = -1;
rangeDetails.column = 0;
}
function selectNextWithId( eventId )
@@ -418,6 +421,7 @@ Rectangle {
rangeDetails.label = qmlEventList.getDetails(selectedItem);
rangeDetails.file = qmlEventList.getFilename(selectedItem);
rangeDetails.line = qmlEventList.getLine(selectedItem);
rangeDetails.column = qmlEventList.getColumn(selectedItem);
rangeDetails.type = root.names[qmlEventList.getType(selectedItem)];
rangeDetails.visible = true;
@@ -441,7 +445,7 @@ Rectangle {
onItemPressed: {
if (pressedItem !== -1) {
root.gotoSourceLocation(qmlEventList.getFilename(pressedItem), qmlEventList.getLine(pressedItem));
root.gotoSourceLocation(qmlEventList.getFilename(pressedItem), qmlEventList.getLine(pressedItem), qmlEventList.getColumn(pressedItem));
}
}

View File

@@ -41,6 +41,7 @@ Item {
property string type
property string file
property int line
property int column
property bool locked: view.selectionLocked
@@ -155,7 +156,7 @@ Item {
height: col.height + 30
drag.target: parent
onClicked: {
root.gotoSourceLocation(file, line);
root.gotoSourceLocation(file, line, column);
root.recenterOnItem(view.selectedItem);
}
}

View File

@@ -86,7 +86,7 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QmlJsDebugClient::QmlProfilerEv
m_eventTree = new QmlProfilerEventsMainView(model, this);
m_eventTree->setViewType(QmlProfilerEventsMainView::EventsView);
connect(m_eventTree, SIGNAL(gotoSourceLocation(QString,int)), this, SIGNAL(gotoSourceLocation(QString,int)));
connect(m_eventTree, SIGNAL(gotoSourceLocation(QString,int,int)), this, SIGNAL(gotoSourceLocation(QString,int,int)));
connect(m_eventTree, SIGNAL(showEventInTimeline(int)), this, SIGNAL(showEventInTimeline(int)));
m_eventChildren = new QmlProfilerEventsParentsAndChildrenView(model, QmlProfilerEventsParentsAndChildrenView::ChildrenView, this);
@@ -181,8 +181,12 @@ void QmlProfilerEventsWidget::updateSelectedEvent(int eventId) const
m_eventTree->selectEvent(eventId);
}
void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line)
void QmlProfilerEventsWidget::selectBySourceLocation(const QString &filename, int line, int column)
{
// This slot is used to connect the javascript pane with the qml events pane
// Our javascript trace data does not store column information
// thus we ignore it here
Q_UNUSED(column);
m_eventTree->selectEventByLocation(filename, line);
}
@@ -453,8 +457,9 @@ void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildModelFrom
// metadata
newRow.at(0)->setData(QVariant(binding->eventHashStr),EventHashStrRole);
newRow.at(0)->setData(QVariant(binding->filename),FilenameRole);
newRow.at(0)->setData(QVariant(binding->line),LineRole);
newRow.at(0)->setData(QVariant(binding->location.filename),FilenameRole);
newRow.at(0)->setData(QVariant(binding->location.line),LineRole);
newRow.at(0)->setData(QVariant(binding->location.column),ColumnRole);
newRow.at(0)->setData(QVariant(binding->eventId),EventIdRole);
// append
@@ -507,6 +512,7 @@ void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildV8ModelFr
newRow.at(0)->setData(QString("%1:%2").arg(v8event->filename, QString::number(v8event->line)), EventHashStrRole);
newRow.at(0)->setData(QVariant(v8event->filename), FilenameRole);
newRow.at(0)->setData(QVariant(v8event->line), LineRole);
newRow.at(0)->setData(QVariant(0),ColumnRole); // v8 events have no column info
newRow.at(0)->setData(QVariant(v8event->eventId), EventIdRole);
// append
@@ -569,9 +575,10 @@ void QmlProfilerEventsMainView::jumpToItem(const QModelIndex &index)
// show in editor
int line = infoItem->data(LineRole).toInt();
int column = infoItem->data(ColumnRole).toInt();
QString fileName = infoItem->data(FilenameRole).toString();
if (line!=-1 && !fileName.isEmpty())
emit gotoSourceLocation(fileName, line);
emit gotoSourceLocation(fileName, line, column);
// show in callers/callees subwindow
emit eventSelected(infoItem->data(EventIdRole).toInt());

View File

@@ -51,7 +51,8 @@ enum ItemRole {
EventHashStrRole = Qt::UserRole+1,
FilenameRole = Qt::UserRole+2,
LineRole = Qt::UserRole+3,
EventIdRole = Qt::UserRole+4
ColumnRole = Qt::UserRole+4,
EventIdRole = Qt::UserRole+5
};
class QmlProfilerEventsWidget : public QWidget
@@ -73,13 +74,13 @@ public:
bool hasGlobalStats() const;
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber);
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void contextMenuRequested(const QPoint &position);
void showEventInTimeline(int eventId);
public slots:
void updateSelectedEvent(int eventId) const;
void selectBySourceLocation(const QString &filename, int line);
void selectBySourceLocation(const QString &filename, int line, int column);
protected:
void contextMenuEvent(QContextMenuEvent *ev);
@@ -142,7 +143,7 @@ public:
int selectedEventId() const;
signals:
void gotoSourceLocation(const QString &fileName, int lineNumber);
void gotoSourceLocation(const QString &fileName, int lineNumber, int columnNumber);
void eventSelected(int eventId);
void showEventInTimeline(int eventId);

View File

@@ -443,7 +443,7 @@ QWidget *QmlProfilerTool::createWidgets()
d->m_traceWindow = new TraceWindow(mw);
d->m_traceWindow->reset(d->m_client);
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int)),this, SLOT(gotoSourceLocation(QString,int)));
connect(d->m_traceWindow, SIGNAL(gotoSourceLocation(QString,int,int)),this, SLOT(gotoSourceLocation(QString,int,int)));
connect(d->m_traceWindow, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(d->m_traceWindow->getEventList(), SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString)));
connect(d->m_traceWindow->getEventList(), SIGNAL(dataReady()), this, SLOT(showSaveOption()));
@@ -451,18 +451,18 @@ QWidget *QmlProfilerTool::createWidgets()
connect(d->m_traceWindow, SIGNAL(profilerStateChanged(bool,bool)), this, SLOT(profilerStateChanged(bool,bool)));
d->m_eventsView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int,int)), this, SLOT(gotoSourceLocation(QString,int,int)));
connect(d->m_eventsView, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(d->m_eventsView, SIGNAL(showEventInTimeline(int)), d->m_traceWindow, SLOT(selectNextEvent(int)));
connect(d->m_traceWindow, SIGNAL(selectedEventIdChanged(int)), d->m_eventsView, SLOT(updateSelectedEvent(int)));
d->m_v8profilerView = new QmlProfilerEventsWidget(d->m_traceWindow->getEventList(), mw);
d->m_v8profilerView->switchToV8View();
connect(d->m_v8profilerView, SIGNAL(gotoSourceLocation(QString,int)), this, SLOT(gotoSourceLocation(QString,int)));
connect(d->m_v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), this, SLOT(gotoSourceLocation(QString,int,int)));
connect(d->m_v8profilerView, SIGNAL(contextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(d->m_v8profilerView, SIGNAL(gotoSourceLocation(QString,int)), d->m_eventsView, SLOT(selectBySourceLocation(QString,int)));
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int)), d->m_v8profilerView, SLOT(selectBySourceLocation(QString,int)));
connect(d->m_v8profilerView, SIGNAL(gotoSourceLocation(QString,int,int)), d->m_eventsView, SLOT(selectBySourceLocation(QString,int,int)));
connect(d->m_eventsView, SIGNAL(gotoSourceLocation(QString,int,int)), d->m_v8profilerView, SLOT(selectBySourceLocation(QString,int,int)));
QDockWidget *eventsDock = AnalyzerManager::createDockWidget
(this, tr("Events"), d->m_eventsView, Qt::BottomDockWidgetArea);
@@ -602,7 +602,7 @@ void QmlProfilerTool::setAppIsStopped()
updateTimers();
}
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber)
{
if (lineNumber < 0 || fileUrl.isEmpty())
return;
@@ -619,7 +619,7 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber)
if (textEditor) {
editorManager->addCurrentPositionToNavigationHistory();
textEditor->gotoLine(lineNumber);
textEditor->gotoLine(lineNumber, columnNumber);
textEditor->widget()->setFocus();
}
}

View File

@@ -83,7 +83,7 @@ public slots:
void setAppIsRunning();
void setAppIsStopped();
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columnNumber);
void updateTimers();
void profilerStateChanged(bool qmlActive, bool v8active);

View File

@@ -134,7 +134,7 @@ TraceWindow::TraceWindow(QWidget *parent)
setLayout(groupLayout);
m_eventList = new QmlProfilerEventList(this);
connect(this,SIGNAL(range(int,qint64,qint64,QStringList,QString,int)), m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QString,int)));
connect(this,SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)), m_eventList, SLOT(addRangedEvent(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
connect(this, SIGNAL(traceFinished(qint64)), m_eventList, SLOT(setTraceEndTime(qint64)));
connect(this, SIGNAL(traceStarted(qint64)), m_eventList, SLOT(setTraceStartTime(qint64)));
connect(this, SIGNAL(frameEvent(qint64,int,int)), m_eventList, SLOT(addFrameEvent(qint64,int,int)));
@@ -309,8 +309,8 @@ void TraceWindow::connectClientSignals()
{
if (m_plugin) {
connect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
connect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
this, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
connect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)),
this, SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
connect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
connect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
connect(m_plugin.data(), SIGNAL(frame(qint64,int,int)), this, SIGNAL(frameEvent(qint64,int,int)));
@@ -329,8 +329,8 @@ void TraceWindow::disconnectClientSignals()
{
if (m_plugin) {
disconnect(m_plugin.data(), SIGNAL(complete()), this, SLOT(qmlComplete()));
disconnect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QString,int)),
this, SIGNAL(range(int,qint64,qint64,QStringList,QString,int)));
disconnect(m_plugin.data(), SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)),
this, SIGNAL(range(int,qint64,qint64,QStringList,QmlJsDebugClient::QmlEventLocation)));
disconnect(m_plugin.data(), SIGNAL(traceFinished(qint64)), this, SIGNAL(traceFinished(qint64)));
disconnect(m_plugin.data(), SIGNAL(traceStarted(qint64)), this, SIGNAL(traceStarted(qint64)));
disconnect(m_plugin.data(), SIGNAL(enabledChanged()), this, SLOT(updateProfilerState()));
@@ -362,7 +362,8 @@ void TraceWindow::contextMenuEvent(QContextMenuEvent *ev)
void TraceWindow::updateCursorPosition()
{
emit gotoSourceLocation(m_mainView->rootObject()->property("fileName").toString(),
m_mainView->rootObject()->property("lineNumber").toInt());
m_mainView->rootObject()->property("lineNumber").toInt(),
m_mainView->rootObject()->property("columnNumber").toInt());
}
void TraceWindow::updateTimer()

View File

@@ -131,8 +131,8 @@ public slots:
signals:
void viewUpdated();
void profilerStateChanged(bool qmlActive, bool v8active);
void gotoSourceLocation(const QString &fileUrl, int lineNumber);
void range(int type, qint64 startTime, qint64 length, const QStringList &data, const QString &fileName, int line);
void gotoSourceLocation(const QString &fileUrl, int lineNumber, int columNumber);
void range(int type, qint64 startTime, qint64 length, const QStringList &data, const QmlJsDebugClient::QmlEventLocation &location);
void v8range(int depth,const QString &function,const QString &filename,
int lineNumber, double totalTime, double selfTime);
void traceFinished(qint64);