QmlProfiler: Compile with QT_NO_CAST_FROM_ASCII

Change-Id: I99c96e723e80ec318acd9300b4f44e7c3ce37485
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com>
This commit is contained in:
Orgad Shaneh
2012-11-26 21:18:13 +02:00
committed by Orgad Shaneh
parent dba973c933
commit f739c85c72
16 changed files with 208 additions and 205 deletions

View File

@@ -67,7 +67,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
Context2D *getContext(const QString & = QString("2d")); Context2D *getContext(const QString & = QLatin1String("2d"));
void requestPaint(); void requestPaint();
FillMode fillMode() const; FillMode fillMode() const;

View File

@@ -66,22 +66,22 @@ static QList<qreal> parseNumbersList(QString::const_iterator &itr)
while ((*itr).isSpace()) while ((*itr).isSpace())
++itr; ++itr;
while ((*itr).isNumber() || while ((*itr).isNumber() ||
(*itr) == '-' || (*itr) == '+' || (*itr) == '.') { (*itr) == QLatin1Char('-') || (*itr) == QLatin1Char('+') || (*itr) == QLatin1Char('.')) {
temp.clear(); temp.clear();
if ((*itr) == '-') if ((*itr) == QLatin1Char('-'))
temp += *itr++; temp += *itr++;
else if ((*itr) == '+') else if ((*itr) == QLatin1Char('+'))
temp += *itr++; temp += *itr++;
while ((*itr).isDigit()) while ((*itr).isDigit())
temp += *itr++; temp += *itr++;
if ((*itr) == '.') if ((*itr) == QLatin1Char('.'))
temp += *itr++; temp += *itr++;
while ((*itr).isDigit()) while ((*itr).isDigit())
temp += *itr++; temp += *itr++;
while ((*itr).isSpace()) while ((*itr).isSpace())
++itr; ++itr;
if ((*itr) == ',') if ((*itr) == QLatin1Char(','))
++itr; ++itr;
points.append(temp.toDouble()); points.append(temp.toDouble());
//eat spaces //eat spaces
@@ -96,7 +96,7 @@ QColor colorFromString(const QString &name)
{ {
QString::const_iterator itr = name.constBegin(); QString::const_iterator itr = name.constBegin();
QList<qreal> compo; QList<qreal> compo;
if (name.startsWith("rgba(")) { if (name.startsWith(QLatin1String("rgba("))) {
++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr); compo = parseNumbersList(itr);
if (compo.size() != 4) { if (compo.size() != 4) {
@@ -106,7 +106,7 @@ QColor colorFromString(const QString &name)
compo[3] *= 255; compo[3] *= 255;
return QColor((int)compo[0], (int)compo[1], return QColor((int)compo[0], (int)compo[1],
(int)compo[2], (int)compo[3]); (int)compo[2], (int)compo[3]);
} else if (name.startsWith("rgb(")) { } else if (name.startsWith(QLatin1String("rgb("))) {
++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr); compo = parseNumbersList(itr);
if (compo.size() != 3) { if (compo.size() != 3) {
@@ -115,7 +115,7 @@ QColor colorFromString(const QString &name)
return QColor((int)qClamp(compo[0], qreal(0), qreal(255)), return QColor((int)qClamp(compo[0], qreal(0), qreal(255)),
(int)qClamp(compo[1], qreal(0), qreal(255)), (int)qClamp(compo[1], qreal(0), qreal(255)),
(int)qClamp(compo[2], qreal(0), qreal(255))); (int)qClamp(compo[2], qreal(0), qreal(255)));
} else if (name.startsWith("hsla(")){ } else if (name.startsWith(QLatin1String("hsla("))) {
++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr); compo = parseNumbersList(itr);
if (compo.size() != 4) { if (compo.size() != 4) {
@@ -123,7 +123,7 @@ QColor colorFromString(const QString &name)
} }
return QColor::fromHslF(compo[0], compo[1], return QColor::fromHslF(compo[0], compo[1],
compo[2], compo[3]); compo[2], compo[3]);
} else if (name.startsWith("hsl(")){ } else if (name.startsWith(QLatin1String("hsl("))) {
++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr; ++itr;
compo = parseNumbersList(itr); compo = parseNumbersList(itr);
if (compo.size() != 3) { if (compo.size() != 3) {
@@ -174,53 +174,53 @@ static QString compositeOperatorToString(QPainter::CompositionMode op)
{ {
switch (op) { switch (op) {
case QPainter::CompositionMode_SourceOver: case QPainter::CompositionMode_SourceOver:
return "source-over"; return QLatin1String("source-over");
case QPainter::CompositionMode_DestinationOver: case QPainter::CompositionMode_DestinationOver:
return "destination-over"; return QLatin1String("destination-over");
case QPainter::CompositionMode_Clear: case QPainter::CompositionMode_Clear:
return "clear"; return QLatin1String("clear");
case QPainter::CompositionMode_Source: case QPainter::CompositionMode_Source:
return "source"; return QLatin1String("source");
case QPainter::CompositionMode_Destination: case QPainter::CompositionMode_Destination:
return "destination"; return QLatin1String("destination");
case QPainter::CompositionMode_SourceIn: case QPainter::CompositionMode_SourceIn:
return "source-in"; return QLatin1String("source-in");
case QPainter::CompositionMode_DestinationIn: case QPainter::CompositionMode_DestinationIn:
return "destination-in"; return QLatin1String("destination-in");
case QPainter::CompositionMode_SourceOut: case QPainter::CompositionMode_SourceOut:
return "source-out"; return QLatin1String("source-out");
case QPainter::CompositionMode_DestinationOut: case QPainter::CompositionMode_DestinationOut:
return "destination-out"; return QLatin1String("destination-out");
case QPainter::CompositionMode_SourceAtop: case QPainter::CompositionMode_SourceAtop:
return "source-atop"; return QLatin1String("source-atop");
case QPainter::CompositionMode_DestinationAtop: case QPainter::CompositionMode_DestinationAtop:
return "destination-atop"; return QLatin1String("destination-atop");
case QPainter::CompositionMode_Xor: case QPainter::CompositionMode_Xor:
return "xor"; return QLatin1String("xor");
case QPainter::CompositionMode_Plus: case QPainter::CompositionMode_Plus:
return "plus"; return QLatin1String("plus");
case QPainter::CompositionMode_Multiply: case QPainter::CompositionMode_Multiply:
return "multiply"; return QLatin1String("multiply");
case QPainter::CompositionMode_Screen: case QPainter::CompositionMode_Screen:
return "screen"; return QLatin1String("screen");
case QPainter::CompositionMode_Overlay: case QPainter::CompositionMode_Overlay:
return "overlay"; return QLatin1String("overlay");
case QPainter::CompositionMode_Darken: case QPainter::CompositionMode_Darken:
return "darken"; return QLatin1String("darken");
case QPainter::CompositionMode_Lighten: case QPainter::CompositionMode_Lighten:
return "lighten"; return QLatin1String("lighten");
case QPainter::CompositionMode_ColorDodge: case QPainter::CompositionMode_ColorDodge:
return "color-dodge"; return QLatin1String("color-dodge");
case QPainter::CompositionMode_ColorBurn: case QPainter::CompositionMode_ColorBurn:
return "color-burn"; return QLatin1String("color-burn");
case QPainter::CompositionMode_HardLight: case QPainter::CompositionMode_HardLight:
return "hard-light"; return QLatin1String("hard-light");
case QPainter::CompositionMode_SoftLight: case QPainter::CompositionMode_SoftLight:
return "soft-light"; return QLatin1String("soft-light");
case QPainter::CompositionMode_Difference: case QPainter::CompositionMode_Difference:
return "difference"; return QLatin1String("difference");
case QPainter::CompositionMode_Exclusion: case QPainter::CompositionMode_Exclusion:
return "exclusion"; return QLatin1String("exclusion");
default: default:
break; break;
} }
@@ -379,11 +379,11 @@ QString Context2D::lineCap() const
{ {
switch (m_state.lineCap) { switch (m_state.lineCap) {
case Qt::FlatCap: case Qt::FlatCap:
return "butt"; return QLatin1String("butt");
case Qt::SquareCap: case Qt::SquareCap:
return "square"; return QLatin1String("square");
case Qt::RoundCap: case Qt::RoundCap:
return "round"; return QLatin1String("round");
default: ; default: ;
} }
return QString(); return QString();
@@ -396,7 +396,7 @@ void Context2D::setLineCap(const QString &capString)
style = Qt::RoundCap; style = Qt::RoundCap;
else if (capString == QLatin1String("square")) else if (capString == QLatin1String("square"))
style = Qt::SquareCap; style = Qt::SquareCap;
else //if (capString == "butt") else //if (capString == QLatin1String("butt"))
style = Qt::FlatCap; style = Qt::FlatCap;
m_state.lineCap = style; m_state.lineCap = style;
m_state.flags |= DirtyLineCap; m_state.flags |= DirtyLineCap;
@@ -528,7 +528,7 @@ void Context2D::setTextBaseline(const QString &baseline)
m_state.textBaseline = Context2D::Middle; m_state.textBaseline = Context2D::Middle;
else { else {
m_state.textBaseline = Context2D::Alphabetic; m_state.textBaseline = Context2D::Alphabetic;
qWarning() << ("Context2D: invalid baseline:" + baseline); qWarning() << (QLatin1String("Context2D: invalid baseline:") + baseline);
} }
m_state.flags |= DirtyTextBaseline; m_state.flags |= DirtyTextBaseline;
} }
@@ -577,7 +577,7 @@ void Context2D::setFont(const QString &fontString)
{ {
QFont font; QFont font;
// ### this is simplified and incomplete // ### this is simplified and incomplete
QStringList tokens = fontString.split(QLatin1Char(' ')); QStringList tokens = fontString.split(QLatin1Char(QLatin1Char(' ')));
foreach (const QString &token, tokens) { foreach (const QString &token, tokens) {
if (token == QLatin1String("italic")) if (token == QLatin1String("italic"))
font.setItalic(true); font.setItalic(true);
@@ -585,7 +585,7 @@ void Context2D::setFont(const QString &fontString)
font.setBold(true); font.setBold(true);
else if (token.endsWith(QLatin1String("px"))) { else if (token.endsWith(QLatin1String("px"))) {
QString number = token; QString number = token;
number.remove("px"); number.remove(QLatin1String("px"));
#ifdef Q_OS_MACX #ifdef Q_OS_MACX
// compensating the extra antialias space with bigger fonts // compensating the extra antialias space with bigger fonts
// this class is only used by the QML Profiler // this class is only used by the QML Profiler

View File

@@ -43,11 +43,10 @@ LocalQmlProfilerRunner::LocalQmlProfilerRunner(const Configuration &configuratio
void LocalQmlProfilerRunner::start() void LocalQmlProfilerRunner::start()
{ {
QString arguments = QString("-qmljsdebugger=port:%1,block").arg( QString arguments = QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_configuration.port);
QString::number(m_configuration.port));
if (!m_configuration.executableArguments.isEmpty()) if (!m_configuration.executableArguments.isEmpty())
arguments += QChar(' ') + m_configuration.executableArguments; arguments += QLatin1Char(' ') + m_configuration.executableArguments;
if (QmlProfilerPlugin::debugOutput) if (QmlProfilerPlugin::debugOutput)
qWarning("QmlProfiler: Launching %s:%d", qPrintable(m_configuration.executable), qWarning("QmlProfiler: Launching %s:%d", qPrintable(m_configuration.executable),

View File

@@ -1,7 +1,7 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = QmlProfiler TARGET = QmlProfiler
DEFINES += QMLPROFILER_LIBRARY DEFINES += QMLPROFILER_LIBRARY QT_NO_CAST_FROM_ASCII
QT += network script declarative QT += network script declarative

View File

@@ -21,6 +21,7 @@ QtcPlugin {
Depends { name: "cpp" } Depends { name: "cpp" }
cpp.includePaths: base.concat("canvas") cpp.includePaths: base.concat("canvas")
cpp.defines: base.concat(["QT_NO_CAST_FROM_ASCII"])
files: [ files: [
"abstractqmlprofilerrunner.h", "abstractqmlprofilerrunner.h",

View File

@@ -75,7 +75,7 @@ public:
QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) : QmlProfilerClientManager::QmlProfilerClientManager(QObject *parent) :
QObject(parent), d(new QmlProfilerClientManagerPrivate(this)) QObject(parent), d(new QmlProfilerClientManagerPrivate(this))
{ {
setObjectName("QML Profiler Connections"); setObjectName(QLatin1String("QML Profiler Connections"));
d->profilerState = 0; d->profilerState = 0;
@@ -224,7 +224,8 @@ void QmlProfilerClientManager::connectToClient()
if (!d->connection || d->connection->state() != QAbstractSocket::UnconnectedState) if (!d->connection || d->connection->state() != QAbstractSocket::UnconnectedState)
return; return;
QmlProfilerTool::logStatus(QString("QML Profiler: Connecting to %1:%2 ...").arg(d->tcpHost, QString::number(d->tcpPort))); QmlProfilerTool::logStatus(QString::fromLatin1("QML Profiler: Connecting to %1:%2 ...")
.arg(d->tcpHost, QString::number(d->tcpPort)));
d->connection->connectToHost(d->tcpHost, d->tcpPort); d->connection->connectToHost(d->tcpHost, d->tcpPort);
} }
@@ -321,14 +322,14 @@ void QmlProfilerClientManager::retryMessageBoxFinished(int result)
break; break;
} }
case QMessageBox::Help: { case QMessageBox::Help: {
QmlProfilerTool::handleHelpRequest(QString("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html")); QmlProfilerTool::handleHelpRequest(QLatin1String("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"));
// fall through // fall through
} }
default: { default: {
if (d->connection) { if (d->connection) {
QmlProfilerTool::logStatus("QML Profiler: Failed to connect! " + d->connection->errorString()); QmlProfilerTool::logStatus(QLatin1String("QML Profiler: Failed to connect! ") + d->connection->errorString());
} else { } else {
QmlProfilerTool::logStatus("QML Profiler: Failed to connect!"); QmlProfilerTool::logStatus(QLatin1String("QML Profiler: Failed to connect!"));
} }
emit connectionFailed(); emit connectionFailed();

View File

@@ -215,7 +215,7 @@ public:
QmlProfilerDataModel::QmlProfilerDataModel(QObject *parent) : QmlProfilerDataModel::QmlProfilerDataModel(QObject *parent) :
QObject(parent), d(new QmlProfilerDataModelPrivate(this)) QObject(parent), d(new QmlProfilerDataModelPrivate(this))
{ {
setObjectName("QmlProfilerDataModel"); setObjectName(QLatin1String("QmlProfilerDataModel"));
d->listState = Empty; d->listState = Empty;
@@ -309,14 +309,14 @@ void QmlProfilerDataModel::addRangedEvent(int type, int bindingType, qint64 star
if (data.isEmpty()) if (data.isEmpty())
details = tr("Source code not available"); details = tr("Source code not available");
else { else {
details = data.join(" ").replace('\n'," ").simplified(); details = data.join(QLatin1String(" ")).replace(QLatin1Char('\n'),QLatin1Char(' ')).simplified();
QRegExp rewrite("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"); QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
bool match = rewrite.exactMatch(details); bool match = rewrite.exactMatch(details);
if (match) { if (match) {
details = rewrite.cap(1) + ": " + rewrite.cap(3); details = rewrite.cap(1) + QLatin1String(": ") + rewrite.cap(3);
} }
if (details.startsWith(QString("file://"))) if (details.startsWith(QLatin1String("file://")))
details = details.mid(details.lastIndexOf(QChar('/')) + 1); details = details.mid(details.lastIndexOf(QLatin1Char('/')) + 1);
} }
// backwards compatibility: "compiling" events don't have a proper location in older // backwards compatibility: "compiling" events don't have a proper location in older
@@ -333,7 +333,7 @@ void QmlProfilerDataModel::addRangedEvent(int type, int bindingType, qint64 star
eventHashStr = getHashStringForQmlEvent(eventLocation, type); eventHashStr = getHashStringForQmlEvent(eventLocation, type);
} else { } else {
const QString filePath = QUrl(eventLocation.filename).path(); const QString filePath = QUrl(eventLocation.filename).path();
displayName = filePath.mid(filePath.lastIndexOf(QChar('/')) + 1) + colon + displayName = filePath.mid(filePath.lastIndexOf(QLatin1Char('/')) + 1) + colon +
QString::number(eventLocation.line); QString::number(eventLocation.line);
eventHashStr = getHashStringForQmlEvent(eventLocation, type); eventHashStr = getHashStringForQmlEvent(eventLocation, type);
} }
@@ -450,7 +450,7 @@ void QmlProfilerDataModel::setTraceStartTime(qint64 time)
QString QmlProfilerDataModel::getHashStringForQmlEvent( QString QmlProfilerDataModel::getHashStringForQmlEvent(
const QmlDebug::QmlEventLocation &location, int eventType) const QmlDebug::QmlEventLocation &location, int eventType)
{ {
return QString("%1:%2:%3:%4").arg(location.filename, return QString::fromLatin1("%1:%2:%3:%4").arg(location.filename,
QString::number(location.line), QString::number(location.line),
QString::number(location.column), QString::number(location.column),
QString::number(eventType)); QString::number(eventType));
@@ -459,7 +459,7 @@ QString QmlProfilerDataModel::getHashStringForQmlEvent(
QString QmlProfilerDataModel::getHashStringForV8Event(const QString &displayName, QString QmlProfilerDataModel::getHashStringForV8Event(const QString &displayName,
const QString &function) const QString &function)
{ {
return QString("%1:%2").arg(displayName, function); return QString::fromLatin1("%1:%2").arg(displayName, function);
} }
QString QmlProfilerDataModel::rootEventName() QString QmlProfilerDataModel::rootEventName()
@@ -806,7 +806,7 @@ void QmlProfilerDataModel::complete()
compileStatistics(traceStartTime(), traceEndTime()); compileStatistics(traceStartTime(), traceEndTime());
setState(Done); setState(Done);
} else { } else {
emit error("Unexpected complete signal in data model"); emit error(tr("Unexpected complete signal in data model"));
} }
} }
@@ -1363,42 +1363,42 @@ bool QmlProfilerDataModel::save(const QString &filename)
stream.setAutoFormatting(true); stream.setAutoFormatting(true);
stream.writeStartDocument(); stream.writeStartDocument();
stream.writeStartElement("trace"); stream.writeStartElement(QLatin1String("trace"));
stream.writeAttribute("version", Constants::PROFILER_FILE_VERSION); stream.writeAttribute(QLatin1String("version"), QLatin1String(Constants::PROFILER_FILE_VERSION));
stream.writeAttribute("traceStart", QString::number(traceStartTime())); stream.writeAttribute(QLatin1String("traceStart"), QString::number(traceStartTime()));
stream.writeAttribute("traceEnd", QString::number(traceEndTime())); stream.writeAttribute(QLatin1String("traceEnd"), QString::number(traceEndTime()));
stream.writeStartElement("eventData"); stream.writeStartElement(QLatin1String("eventData"));
stream.writeAttribute("totalTime", QString::number(d->qmlMeasuredTime)); stream.writeAttribute(QLatin1String("totalTime"), QString::number(d->qmlMeasuredTime));
foreach (const QmlRangeEventData *eventData, d->rangeEventDictionary.values()) { foreach (const QmlRangeEventData *eventData, d->rangeEventDictionary.values()) {
stream.writeStartElement("event"); stream.writeStartElement(QLatin1String("event"));
stream.writeAttribute("index", QString::number(d->rangeEventDictionary.keys().indexOf(eventData->eventHashStr))); stream.writeAttribute(QLatin1String("index"), QString::number(d->rangeEventDictionary.keys().indexOf(eventData->eventHashStr)));
stream.writeTextElement("displayname", eventData->displayName); stream.writeTextElement(QLatin1String("displayname"), eventData->displayName);
stream.writeTextElement("type", qmlEventTypeAsString(eventData->eventType)); stream.writeTextElement(QLatin1String("type"), qmlEventTypeAsString(eventData->eventType));
if (!eventData->location.filename.isEmpty()) { if (!eventData->location.filename.isEmpty()) {
stream.writeTextElement("filename", eventData->location.filename); stream.writeTextElement(QLatin1String("filename"), eventData->location.filename);
stream.writeTextElement("line", QString::number(eventData->location.line)); stream.writeTextElement(QLatin1String("line"), QString::number(eventData->location.line));
stream.writeTextElement("column", QString::number(eventData->location.column)); stream.writeTextElement(QLatin1String("column"), QString::number(eventData->location.column));
} }
stream.writeTextElement("details", eventData->details); stream.writeTextElement(QLatin1String("details"), eventData->details);
if (eventData->eventType == Binding) if (eventData->eventType == Binding)
stream.writeTextElement("bindingType", QString::number((int)eventData->bindingType)); stream.writeTextElement(QLatin1String("bindingType"), QString::number((int)eventData->bindingType));
stream.writeEndElement(); stream.writeEndElement();
} }
stream.writeEndElement(); // eventData stream.writeEndElement(); // eventData
stream.writeStartElement("profilerDataModel"); stream.writeStartElement(QLatin1String("profilerDataModel"));
foreach (const QmlRangeEventStartInstance &rangedEvent, d->startInstanceList) { foreach (const QmlRangeEventStartInstance &rangedEvent, d->startInstanceList) {
stream.writeStartElement("range"); stream.writeStartElement(QLatin1String("range"));
stream.writeAttribute("startTime", QString::number(rangedEvent.startTime)); stream.writeAttribute(QLatin1String("startTime"), QString::number(rangedEvent.startTime));
stream.writeAttribute("duration", QString::number(rangedEvent.duration)); stream.writeAttribute(QLatin1String("duration"), QString::number(rangedEvent.duration));
stream.writeAttribute("eventIndex", QString::number(d->rangeEventDictionary.keys().indexOf(rangedEvent.statsInfo->eventHashStr))); stream.writeAttribute(QLatin1String("eventIndex"), QString::number(d->rangeEventDictionary.keys().indexOf(rangedEvent.statsInfo->eventHashStr)));
if (rangedEvent.statsInfo->eventType == QmlDebug::Painting && rangedEvent.animationCount >= 0) { if (rangedEvent.statsInfo->eventType == QmlDebug::Painting && rangedEvent.animationCount >= 0) {
// animation frame // animation frame
stream.writeAttribute("framerate", QString::number(rangedEvent.frameRate)); stream.writeAttribute(QLatin1String("framerate"), QString::number(rangedEvent.frameRate));
stream.writeAttribute("animationcount", QString::number(rangedEvent.animationCount)); stream.writeAttribute(QLatin1String("animationcount"), QString::number(rangedEvent.animationCount));
} }
stream.writeEndElement(); stream.writeEndElement();
} }
@@ -1458,52 +1458,52 @@ void QmlProfilerDataModel::load()
switch (token) { switch (token) {
case QXmlStreamReader::StartDocument : continue; case QXmlStreamReader::StartDocument : continue;
case QXmlStreamReader::StartElement : { case QXmlStreamReader::StartElement : {
if (elementName == "trace") { if (elementName == QLatin1String("trace")) {
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("version")) if (attributes.hasAttribute(QLatin1String("version")))
validVersion = attributes.value("version").toString() == Constants::PROFILER_FILE_VERSION; validVersion = attributes.value(QLatin1String("version")).toString() == QLatin1String(Constants::PROFILER_FILE_VERSION);
else else
validVersion = false; validVersion = false;
if (attributes.hasAttribute("traceStart")) if (attributes.hasAttribute(QLatin1String("traceStart")))
setTraceStartTime(attributes.value("traceStart").toString().toLongLong()); setTraceStartTime(attributes.value(QLatin1String("traceStart")).toString().toLongLong());
if (attributes.hasAttribute("traceEnd")) if (attributes.hasAttribute(QLatin1String("traceEnd")))
setTraceEndTime(attributes.value("traceEnd").toString().toLongLong()); setTraceEndTime(attributes.value(QLatin1String("traceEnd")).toString().toLongLong());
} }
if (elementName == "eventData") { if (elementName == QLatin1String("eventData")) {
readingQmlEvents = true; readingQmlEvents = true;
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("totalTime")) if (attributes.hasAttribute(QLatin1String("totalTime")))
d->qmlMeasuredTime = attributes.value("totalTime").toString().toDouble(); d->qmlMeasuredTime = attributes.value(QLatin1String("totalTime")).toString().toDouble();
break; break;
} }
if (elementName == "v8profile" && !readingQmlEvents) { if (elementName == QLatin1String("v8profile") && !readingQmlEvents) {
d->v8DataModel->load(stream); d->v8DataModel->load(stream);
break; break;
} }
if (elementName == "trace") { if (elementName == QLatin1String("trace")) {
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("traceStart")) if (attributes.hasAttribute(QLatin1String("traceStart")))
setTraceStartTime(attributes.value("traceStart").toString().toLongLong()); setTraceStartTime(attributes.value(QLatin1String("traceStart")).toString().toLongLong());
if (attributes.hasAttribute("traceEnd")) if (attributes.hasAttribute(QLatin1String("traceEnd")))
setTraceEndTime(attributes.value("traceEnd").toString().toLongLong()); setTraceEndTime(attributes.value(QLatin1String("traceEnd")).toString().toLongLong());
} }
if (elementName == "range") { if (elementName == QLatin1String("range")) {
QmlRangeEventStartInstance rangedEvent; QmlRangeEventStartInstance rangedEvent;
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("startTime")) if (attributes.hasAttribute(QLatin1String("startTime")))
rangedEvent.startTime = attributes.value("startTime").toString().toLongLong(); rangedEvent.startTime = attributes.value(QLatin1String("startTime")).toString().toLongLong();
if (attributes.hasAttribute("duration")) if (attributes.hasAttribute(QLatin1String("duration")))
rangedEvent.duration = attributes.value("duration").toString().toLongLong(); rangedEvent.duration = attributes.value(QLatin1String("duration")).toString().toLongLong();
if (attributes.hasAttribute("framerate")) if (attributes.hasAttribute(QLatin1String("framerate")))
rangedEvent.frameRate = attributes.value("framerate").toString().toInt(); rangedEvent.frameRate = attributes.value(QLatin1String("framerate")).toString().toInt();
if (attributes.hasAttribute("animationcount")) if (attributes.hasAttribute(QLatin1String("animationcount")))
rangedEvent.animationCount = attributes.value("animationcount").toString().toInt(); rangedEvent.animationCount = attributes.value(QLatin1String("animationcount")).toString().toInt();
else else
rangedEvent.animationCount = -1; rangedEvent.animationCount = -1;
if (attributes.hasAttribute("eventIndex")) { if (attributes.hasAttribute(QLatin1String("eventIndex"))) {
int ndx = attributes.value("eventIndex").toString().toInt(); int ndx = attributes.value(QLatin1String("eventIndex")).toString().toInt();
if (!descriptionBuffer.value(ndx)) if (!descriptionBuffer.value(ndx))
descriptionBuffer[ndx] = new QmlRangeEventData; descriptionBuffer[ndx] = new QmlRangeEventData;
rangedEvent.statsInfo = descriptionBuffer.value(ndx); rangedEvent.statsInfo = descriptionBuffer.value(ndx);
@@ -1524,10 +1524,10 @@ void QmlProfilerDataModel::load()
} }
if (readingQmlEvents) { if (readingQmlEvents) {
if (elementName == "event") { if (elementName == QLatin1String("event")) {
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("index")) { if (attributes.hasAttribute(QLatin1String("index"))) {
int ndx = attributes.value("index").toString().toInt(); int ndx = attributes.value(QLatin1String("index")).toString().toInt();
if (!descriptionBuffer.value(ndx)) if (!descriptionBuffer.value(ndx))
descriptionBuffer[ndx] = new QmlRangeEventData; descriptionBuffer[ndx] = new QmlRangeEventData;
currentEvent = descriptionBuffer[ndx]; currentEvent = descriptionBuffer[ndx];
@@ -1548,30 +1548,30 @@ void QmlProfilerDataModel::load()
break; break;
QString readData = stream.text().toString(); QString readData = stream.text().toString();
if (elementName == "displayname") { if (elementName == QLatin1String("displayname")) {
currentEvent->displayName = readData; currentEvent->displayName = readData;
break; break;
} }
if (elementName == "type") { if (elementName == QLatin1String("type")) {
currentEvent->eventType = qmlEventTypeAsEnum(readData); currentEvent->eventType = qmlEventTypeAsEnum(readData);
break; break;
} }
if (elementName == "filename") { if (elementName == QLatin1String("filename")) {
currentEvent->location.filename = readData; currentEvent->location.filename = readData;
break; break;
} }
if (elementName == "line") { if (elementName == QLatin1String("line")) {
currentEvent->location.line = readData.toInt(); currentEvent->location.line = readData.toInt();
break; break;
} }
if (elementName == "column") { if (elementName == QLatin1String("column")) {
currentEvent->location.column = readData.toInt(); currentEvent->location.column = readData.toInt();
} }
if (elementName == "details") { if (elementName == QLatin1String("details")) {
currentEvent->details = readData; currentEvent->details = readData;
break; break;
} }
if (elementName == "bindingType") { if (elementName == QLatin1String("bindingType")) {
currentEvent->bindingType = readData.toInt(); currentEvent->bindingType = readData.toInt();
break; break;
} }
@@ -1579,11 +1579,11 @@ void QmlProfilerDataModel::load()
break; break;
} }
case QXmlStreamReader::EndElement : { case QXmlStreamReader::EndElement : {
if (elementName == "event") { if (elementName == QLatin1String("event")) {
currentEvent = 0; currentEvent = 0;
break; break;
} }
if (elementName == "eventData") { if (elementName == QLatin1String("eventData")) {
readingQmlEvents = false; readingQmlEvents = false;
break; break;
} }
@@ -1666,7 +1666,7 @@ void QmlProfilerDataModel::setState(QmlProfilerDataModel::State state)
QTC_ASSERT(d->listState == ProcessingData || d->listState == Empty, return); QTC_ASSERT(d->listState == ProcessingData || d->listState == Empty, return);
break; break;
default: default:
emit error("Trying to set unknown state in events list"); emit error(tr("Trying to set unknown state in events list"));
break; break;
} }

View File

@@ -167,7 +167,7 @@ void QmlProfilerDetailsRewriter::rewriteDetailsForLocation(QTextStream &textDoc,
qint64 len = node->lastSourceLocation().end() - startPos; qint64 len = node->lastSourceLocation().end() - startPos;
textDoc.seek(startPos); textDoc.seek(startPos);
QString details = textDoc.read(len).replace('\n'," ").simplified(); QString details = textDoc.read(len).replace(QLatin1Char('\n'), QLatin1Char(' ')).simplified();
emit rewriteDetailsString(type, location, details); emit rewriteDetailsString(type, location, details);
} }

View File

@@ -304,8 +304,8 @@ void QmlProfilerEngine::wrongSetupMessageBoxFinished(int button)
{ {
if (button == QMessageBox::Help) { if (button == QMessageBox::Help) {
Core::HelpManager *helpManager = Core::HelpManager::instance(); Core::HelpManager *helpManager = Core::HelpManager::instance();
helpManager->handleHelpRequest("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html" helpManager->handleHelpRequest(QLatin1String("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"
"#setting-up-qml-debugging"); "#setting-up-qml-debugging"));
} }
} }

View File

@@ -117,7 +117,7 @@ QmlProfilerEventsWidget::QmlProfilerEventsWidget(QWidget *parent,
QmlProfilerDataModel *profilerDataModel ) QmlProfilerDataModel *profilerDataModel )
: QWidget(parent), d(new QmlProfilerEventsWidgetPrivate(this)) : QWidget(parent), d(new QmlProfilerEventsWidgetPrivate(this))
{ {
setObjectName("QmlProfilerEventsView"); setObjectName(QLatin1String("QmlProfilerEventsView"));
d->m_profilerDataModel = profilerDataModel; d->m_profilerDataModel = profilerDataModel;
connect(d->m_profilerDataModel, SIGNAL(stateChanged()), connect(d->m_profilerDataModel, SIGNAL(stateChanged()),
@@ -179,7 +179,7 @@ void QmlProfilerEventsWidget::profilerDataModelStateChanged()
void QmlProfilerEventsWidget::switchToV8View() void QmlProfilerEventsWidget::switchToV8View()
{ {
setObjectName("QmlProfilerV8ProfileView"); setObjectName(QLatin1String("QmlProfilerV8ProfileView"));
d->m_eventTree->setViewType(QmlProfilerEventsMainView::V8ProfileView); d->m_eventTree->setViewType(QmlProfilerEventsMainView::V8ProfileView);
d->m_eventParents->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ParentsView); d->m_eventParents->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ParentsView);
d->m_eventChildren->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ChildrenView); d->m_eventChildren->setViewType(QmlProfilerEventsParentsAndChildrenView::V8ChildrenView);
@@ -368,7 +368,7 @@ QmlProfilerEventsMainView::QmlProfilerEventsMainView(ViewTypes viewType,
QmlProfilerDataModel *dataModel) QmlProfilerDataModel *dataModel)
: QTreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this)) : QTreeView(parent), d(new QmlProfilerEventsMainViewPrivate(this))
{ {
setObjectName("QmlProfilerEventsTable"); setObjectName(QLatin1String("QmlProfilerEventsTable"));
header()->setResizeMode(QHeaderView::Interactive); header()->setResizeMode(QHeaderView::Interactive);
header()->setDefaultSectionSize(100); header()->setDefaultSectionSize(100);
header()->setMinimumSectionSize(50); header()->setMinimumSectionSize(50);
@@ -430,7 +430,7 @@ void QmlProfilerEventsMainView::setViewType(ViewTypes type)
d->m_viewType = type; d->m_viewType = type;
switch (type) { switch (type) {
case EventsView: { case EventsView: {
setObjectName("QmlProfilerEventsTable"); setObjectName(QLatin1String("QmlProfilerEventsTable"));
setFieldViewable(Name, true); setFieldViewable(Name, true);
setFieldViewable(Type, true); setFieldViewable(Type, true);
setFieldViewable(Percent, true); setFieldViewable(Percent, true);
@@ -446,7 +446,7 @@ void QmlProfilerEventsMainView::setViewType(ViewTypes type)
break; break;
} }
case V8ProfileView: { case V8ProfileView: {
setObjectName("QmlProfilerV8ProfileTable"); setObjectName(QLatin1String("QmlProfilerV8ProfileTable"));
setFieldViewable(Name, true); setFieldViewable(Name, true);
setFieldViewable(Type, false); setFieldViewable(Type, false);
setFieldViewable(Percent, true); setFieldViewable(Percent, true);
@@ -730,7 +730,7 @@ void QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::buildV8ModelFr
item->setEditable(false); item->setEditable(false);
// metadata // metadata
newRow.at(0)->setData(QString("%1:%2").arg(v8event->filename, QString::number(v8event->line)), EventHashStrRole); newRow.at(0)->setData(QString::fromLatin1("%1:%2").arg(v8event->filename, QString::number(v8event->line)), EventHashStrRole);
newRow.at(0)->setData(QVariant(v8event->filename), FilenameRole); newRow.at(0)->setData(QVariant(v8event->filename), FilenameRole);
newRow.at(0)->setData(QVariant(v8event->line), LineRole); 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(0),ColumnRole); // v8 events have no column info
@@ -880,7 +880,7 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
// indentation // indentation
QStandardItem *itemParent = item->parent(); QStandardItem *itemParent = item->parent();
while (itemParent) { while (itemParent) {
str += " "; str += QLatin1String(" ");
itemParent = itemParent->parent(); itemParent = itemParent->parent();
} }
} }
@@ -890,9 +890,9 @@ QString QmlProfilerEventsMainView::QmlProfilerEventsMainViewPrivate::textForItem
for (int j = 0; j < colCount; ++j) { for (int j = 0; j < colCount; ++j) {
QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) : m_model->item(item->row(),j); QStandardItem *colItem = item->parent() ? item->parent()->child(item->row(),j) : m_model->item(item->row(),j);
str += colItem->data(Qt::DisplayRole).toString(); str += colItem->data(Qt::DisplayRole).toString();
if (j < colCount-1) str += '\t'; if (j < colCount-1) str += QLatin1Char('\t');
} }
str += '\n'; str += QLatin1Char('\n');
// recursively print children // recursively print children
if (recursive && item->child(0)) if (recursive && item->child(0))
@@ -910,9 +910,9 @@ void QmlProfilerEventsMainView::copyTableToClipboard() const
for (int i = 0; i < columnCount; ++i) { for (int i = 0; i < columnCount; ++i) {
str += d->m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); str += d->m_model->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString();
if (i < columnCount - 1) if (i < columnCount - 1)
str += '\t'; str += QLatin1Char('\t');
else else
str += '\n'; str += QLatin1Char('\n');
} }
// data // data
int rowCount = d->m_model->rowCount(); int rowCount = d->m_model->rowCount();

View File

@@ -40,14 +40,14 @@ namespace Internal {
inline QString stringForState(int state) { inline QString stringForState(int state) {
switch (state) { switch (state) {
case QmlProfilerStateManager::Idle: return QString("Idle"); case QmlProfilerStateManager::Idle: return QLatin1String("Idle");
case QmlProfilerStateManager::AppStarting: return QString("AppStarting"); case QmlProfilerStateManager::AppStarting: return QLatin1String("AppStarting");
case QmlProfilerStateManager::AppRunning: return QString("AppRunning"); case QmlProfilerStateManager::AppRunning: return QLatin1String("AppRunning");
case QmlProfilerStateManager::AppStopRequested: return QString("AppStopRequested"); case QmlProfilerStateManager::AppStopRequested: return QLatin1String("AppStopRequested");
case QmlProfilerStateManager::AppReadyToStop: return QString("AppReadyToStop"); case QmlProfilerStateManager::AppReadyToStop: return QLatin1String("AppReadyToStop");
case QmlProfilerStateManager::AppStopped: return QString("AppStopped"); case QmlProfilerStateManager::AppStopped: return QLatin1String("AppStopped");
case QmlProfilerStateManager::AppDying: return QString("AppDying"); case QmlProfilerStateManager::AppDying: return QLatin1String("AppDying");
case QmlProfilerStateManager::AppKilled: return QString("AppKilled"); case QmlProfilerStateManager::AppKilled: return QLatin1String("AppKilled");
default: break; default: break;
} }
return QString(); return QString();

View File

@@ -66,7 +66,7 @@ QmlProfilerStateWidget::QmlProfilerStateWidget(QmlProfilerStateManager *stateMan
QmlProfilerDataModel *dataModel, QWidget *parent) : QmlProfilerDataModel *dataModel, QWidget *parent) :
QWidget(parent), d(new QmlProfilerStateWidgetPrivate(this)) QWidget(parent), d(new QmlProfilerStateWidgetPrivate(this))
{ {
setObjectName("QML Profiler State Display"); setObjectName(QLatin1String("QML Profiler State Display"));
// UI elements // UI elements
QVBoxLayout *layout = new QVBoxLayout(this); QVBoxLayout *layout = new QVBoxLayout(this);

View File

@@ -123,7 +123,7 @@ public:
QmlProfilerTool::QmlProfilerTool(QObject *parent) QmlProfilerTool::QmlProfilerTool(QObject *parent)
: IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this)) : IAnalyzerTool(parent), d(new QmlProfilerToolPrivate(this))
{ {
setObjectName("QmlProfilerTool"); setObjectName(QLatin1String("QmlProfilerTool"));
d->m_profilerState = 0; d->m_profilerState = 0;
d->m_viewContainer = 0; d->m_viewContainer = 0;
@@ -589,7 +589,8 @@ void QmlProfilerTool::showSaveOption()
void QmlProfilerTool::showSaveDialog() void QmlProfilerTool::showSaveDialog()
{ {
QString filename = QFileDialog::getSaveFileName(Core::ICore::mainWindow(), tr("Save QML Trace"), QString(), tr("QML traces (*%1)").arg(TraceFileExtension)); QString filename = QFileDialog::getSaveFileName(Core::ICore::mainWindow(), tr("Save QML Trace"), QString(),
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
if (!filename.endsWith(QLatin1String(TraceFileExtension))) if (!filename.endsWith(QLatin1String(TraceFileExtension)))
filename += QLatin1String(TraceFileExtension); filename += QLatin1String(TraceFileExtension);
@@ -605,7 +606,8 @@ void QmlProfilerTool::showLoadDialog()
if (AnalyzerManager::currentSelectedTool() != this) if (AnalyzerManager::currentSelectedTool() != this)
AnalyzerManager::selectTool(this, StartRemote); AnalyzerManager::selectTool(this, StartRemote);
QString filename = QFileDialog::getOpenFileName(Core::ICore::mainWindow(), tr("Load QML Trace"), QString(), tr("QML traces (*%1)").arg(TraceFileExtension)); QString filename = QFileDialog::getOpenFileName(Core::ICore::mainWindow(), tr("Load QML Trace"), QString(),
tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension)));
if (!filename.isEmpty()) { if (!filename.isEmpty()) {
// delayed load (prevent graphical artifacts due to long load time) // delayed load (prevent graphical artifacts due to long load time)

View File

@@ -132,7 +132,7 @@ public:
QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerDataModel *model, QmlProfilerStateManager *profilerState) QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerTool *profilerTool, QmlProfilerViewManager *container, QmlProfilerDataModel *model, QmlProfilerStateManager *profilerState)
: QWidget(parent), d(new QmlProfilerTraceViewPrivate(this)) : QWidget(parent), d(new QmlProfilerTraceViewPrivate(this))
{ {
setObjectName("QML Profiler"); setObjectName(QLatin1String("QML Profiler"));
d->m_zoomControl = new ZoomControl(this); d->m_zoomControl = new ZoomControl(this);
connect(d->m_zoomControl, SIGNAL(rangeChanged()), this, SLOT(updateRange())); connect(d->m_zoomControl, SIGNAL(rangeChanged()), this, SLOT(updateRange()));
@@ -183,9 +183,9 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, Analyzer::IAnalyzerT
d->m_profilerDataModel = model; d->m_profilerDataModel = model;
connect(d->m_profilerDataModel, SIGNAL(stateChanged()), connect(d->m_profilerDataModel, SIGNAL(stateChanged()),
this, SLOT(profilerDataModelStateChanged())); this, SLOT(profilerDataModelStateChanged()));
d->m_mainView->rootContext()->setContextProperty("qmlProfilerDataModel", d->m_mainView->rootContext()->setContextProperty(QLatin1String("qmlProfilerDataModel"),
d->m_profilerDataModel); d->m_profilerDataModel);
d->m_overview->rootContext()->setContextProperty("qmlProfilerDataModel", d->m_overview->rootContext()->setContextProperty(QLatin1String("qmlProfilerDataModel"),
d->m_profilerDataModel); d->m_profilerDataModel);
d->m_profilerState = profilerState; d->m_profilerState = profilerState;
@@ -210,14 +210,14 @@ QmlProfilerTraceView::~QmlProfilerTraceView()
// Initialize widgets // Initialize widgets
void QmlProfilerTraceView::reset() void QmlProfilerTraceView::reset()
{ {
d->m_mainView->rootContext()->setContextProperty("zoomControl", d->m_zoomControl); d->m_mainView->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
d->m_timebar->rootContext()->setContextProperty("zoomControl", d->m_zoomControl); d->m_timebar->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
d->m_overview->rootContext()->setContextProperty("zoomControl", d->m_zoomControl); d->m_overview->rootContext()->setContextProperty(QLatin1String("zoomControl"), d->m_zoomControl);
d->m_timebar->setSource(QUrl("qrc:/qmlprofiler/TimeDisplay.qml")); d->m_timebar->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/TimeDisplay.qml")));
d->m_overview->setSource(QUrl("qrc:/qmlprofiler/Overview.qml")); d->m_overview->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/Overview.qml")));
d->m_mainView->setSource(QUrl("qrc:/qmlprofiler/MainView.qml")); d->m_mainView->setSource(QUrl(QLatin1String("qrc:/qmlprofiler/MainView.qml")));
d->m_mainView->rootObject()->setProperty("width", QVariant(width())); d->m_mainView->rootObject()->setProperty("width", QVariant(width()));
d->m_mainView->rootObject()->setProperty("candidateHeight", QVariant(height() - d->m_timebar->height() - d->m_overview->height())); d->m_mainView->rootObject()->setProperty("candidateHeight", QVariant(height() - d->m_timebar->height() - d->m_overview->height()));
@@ -244,19 +244,19 @@ QWidget *QmlProfilerTraceView::createToolbar()
toolBarLayout->setSpacing(0); toolBarLayout->setSpacing(0);
QToolButton *buttonPrev= new QToolButton; QToolButton *buttonPrev= new QToolButton;
buttonPrev->setIcon(QIcon(":/qmlprofiler/ico_prev.png")); buttonPrev->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_prev.png")));
buttonPrev->setToolTip(tr("Jump to previous event")); buttonPrev->setToolTip(tr("Jump to previous event"));
connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev())); connect(buttonPrev, SIGNAL(clicked()), this, SIGNAL(jumpToPrev()));
connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool))); connect(this, SIGNAL(enableToolbar(bool)), buttonPrev, SLOT(setEnabled(bool)));
QToolButton *buttonNext= new QToolButton; QToolButton *buttonNext= new QToolButton;
buttonNext->setIcon(QIcon(":/qmlprofiler/ico_next.png")); buttonNext->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_next.png")));
buttonNext->setToolTip(tr("Jump to next event")); buttonNext->setToolTip(tr("Jump to next event"));
connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext())); connect(buttonNext, SIGNAL(clicked()), this, SIGNAL(jumpToNext()));
connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool))); connect(this, SIGNAL(enableToolbar(bool)), buttonNext, SLOT(setEnabled(bool)));
QToolButton *buttonZoomControls = new QToolButton; QToolButton *buttonZoomControls = new QToolButton;
buttonZoomControls->setIcon(QIcon(":/qmlprofiler/ico_zoom.png")); buttonZoomControls->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_zoom.png")));
buttonZoomControls->setToolTip(tr("Show zoom slider")); buttonZoomControls->setToolTip(tr("Show zoom slider"));
buttonZoomControls->setCheckable(true); buttonZoomControls->setCheckable(true);
buttonZoomControls->setChecked(false); buttonZoomControls->setChecked(false);
@@ -264,7 +264,7 @@ QWidget *QmlProfilerTraceView::createToolbar()
connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool))); connect(this, SIGNAL(enableToolbar(bool)), buttonZoomControls, SLOT(setEnabled(bool)));
d->m_buttonRange = new QToolButton; d->m_buttonRange = new QToolButton;
d->m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png")); d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
d->m_buttonRange->setToolTip(tr("Select range")); d->m_buttonRange->setToolTip(tr("Select range"));
d->m_buttonRange->setCheckable(true); d->m_buttonRange->setCheckable(true);
d->m_buttonRange->setChecked(false); d->m_buttonRange->setChecked(false);
@@ -273,7 +273,7 @@ QWidget *QmlProfilerTraceView::createToolbar()
connect(this, SIGNAL(rangeModeChanged(bool)), d->m_buttonRange, SLOT(setChecked(bool))); connect(this, SIGNAL(rangeModeChanged(bool)), d->m_buttonRange, SLOT(setChecked(bool)));
d->m_buttonLock = new QToolButton; d->m_buttonLock = new QToolButton;
d->m_buttonLock->setIcon(QIcon(":/qmlprofiler/ico_selectionmode.png")); d->m_buttonLock->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_selectionmode.png")));
d->m_buttonLock->setToolTip(tr("View event information on mouseover")); d->m_buttonLock->setToolTip(tr("View event information on mouseover"));
d->m_buttonLock->setCheckable(true); d->m_buttonLock->setCheckable(true);
d->m_buttonLock->setChecked(false); d->m_buttonLock->setChecked(false);
@@ -313,7 +313,7 @@ QWidget *QmlProfilerTraceView::createZoomToolbar()
connect(this, SIGNAL(enableToolbar(bool)), zoomSlider, SLOT(setEnabled(bool))); connect(this, SIGNAL(enableToolbar(bool)), zoomSlider, SLOT(setEnabled(bool)));
connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomLevel(int))); connect(zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomLevel(int)));
connect(this, SIGNAL(zoomLevelChanged(int)), zoomSlider, SLOT(setValue(int))); connect(this, SIGNAL(zoomLevelChanged(int)), zoomSlider, SLOT(setValue(int)));
zoomSlider->setStyleSheet("\ zoomSlider->setStyleSheet(QLatin1String("\
QSlider:horizontal {\ QSlider:horizontal {\
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #5a5a5a);\ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #444444, stop: 1 #5a5a5a);\
border: 1px #313131;\ border: 1px #313131;\
@@ -328,7 +328,7 @@ QWidget *QmlProfilerTraceView::createZoomToolbar()
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #5a5a5a, stop: 1 #444444);\
border: 1px #313131;\ border: 1px #313131;\
}\ }\
"); "));
toolBarLayout->addWidget(zoomSlider); toolBarLayout->addWidget(zoomSlider);
@@ -394,9 +394,9 @@ void QmlProfilerTraceView::toggleRangeMode(bool active)
bool rangeMode = d->m_mainView->rootObject()->property("selectionRangeMode").toBool(); bool rangeMode = d->m_mainView->rootObject()->property("selectionRangeMode").toBool();
if (active != rangeMode) { if (active != rangeMode) {
if (active) if (active)
d->m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselected.png")); d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselected.png")));
else else
d->m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png")); d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
d->m_mainView->rootObject()->setProperty("selectionRangeMode", QVariant(active)); d->m_mainView->rootObject()->setProperty("selectionRangeMode", QVariant(active));
} }
} }
@@ -405,9 +405,9 @@ void QmlProfilerTraceView::updateRangeButton()
{ {
bool rangeMode = d->m_mainView->rootObject()->property("selectionRangeMode").toBool(); bool rangeMode = d->m_mainView->rootObject()->property("selectionRangeMode").toBool();
if (rangeMode) if (rangeMode)
d->m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselected.png")); d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselected.png")));
else else
d->m_buttonRange->setIcon(QIcon(":/qmlprofiler/ico_rangeselection.png")); d->m_buttonRange->setIcon(QIcon(QLatin1String(":/qmlprofiler/ico_rangeselection.png")));
emit rangeModeChanged(rangeMode); emit rangeModeChanged(rangeMode);
} }

View File

@@ -65,7 +65,7 @@ QmlProfilerViewManager::QmlProfilerViewManager(QObject *parent,
QmlProfilerStateManager *profilerState) QmlProfilerStateManager *profilerState)
: QObject(parent), d(new QmlProfilerViewManagerPrivate(this)) : QObject(parent), d(new QmlProfilerViewManagerPrivate(this))
{ {
setObjectName("QML Profiler View Manager"); setObjectName(QLatin1String("QML Profiler View Manager"));
d->traceView = 0; d->traceView = 0;
d->eventsView = 0; d->eventsView = 0;
d->v8profilerView = 0; d->v8profilerView = 0;

View File

@@ -298,24 +298,24 @@ void QV8ProfilerDataModel::QV8ProfilerDataModelPrivate::clearV8RootEvent()
void QV8ProfilerDataModel::save(QXmlStreamWriter &stream) void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
{ {
stream.writeStartElement("v8profile"); // v8 profiler output stream.writeStartElement(QLatin1String("v8profile")); // v8 profiler output
stream.writeAttribute("totalTime", QString::number(d->v8MeasuredTime)); stream.writeAttribute(QLatin1String("totalTime"), QString::number(d->v8MeasuredTime));
foreach (QV8EventData *v8event, d->v8EventHash.values()) { foreach (QV8EventData *v8event, d->v8EventHash.values()) {
stream.writeStartElement("event"); stream.writeStartElement(QLatin1String("event"));
stream.writeAttribute("index", stream.writeAttribute(QLatin1String("index"),
QString::number( QString::number(
d->v8EventHash.keys().indexOf( d->v8EventHash.keys().indexOf(
v8event->eventHashStr))); v8event->eventHashStr)));
stream.writeTextElement("displayname", v8event->displayName); stream.writeTextElement(QLatin1String("displayname"), v8event->displayName);
stream.writeTextElement("functionname", v8event->functionName); stream.writeTextElement(QLatin1String("functionname"), v8event->functionName);
if (!v8event->filename.isEmpty()) { if (!v8event->filename.isEmpty()) {
stream.writeTextElement("filename", v8event->filename); stream.writeTextElement(QLatin1String("filename"), v8event->filename);
stream.writeTextElement("line", QString::number(v8event->line)); stream.writeTextElement(QLatin1String("line"), QString::number(v8event->line));
} }
stream.writeTextElement("totalTime", QString::number(v8event->totalTime)); stream.writeTextElement(QLatin1String("totalTime"), QString::number(v8event->totalTime));
stream.writeTextElement("selfTime", QString::number(v8event->selfTime)); stream.writeTextElement(QLatin1String("selfTime"), QString::number(v8event->selfTime));
if (!v8event->childrenHash.isEmpty()) { if (!v8event->childrenHash.isEmpty()) {
stream.writeStartElement("childrenEvents"); stream.writeStartElement(QLatin1String("childrenEvents"));
QStringList childrenIndexes; QStringList childrenIndexes;
QStringList childrenTimes; QStringList childrenTimes;
QStringList parentTimes; QStringList parentTimes;
@@ -325,9 +325,9 @@ void QV8ProfilerDataModel::save(QXmlStreamWriter &stream)
parentTimes << QString::number(v8child->totalTime); parentTimes << QString::number(v8child->totalTime);
} }
stream.writeAttribute("list", childrenIndexes.join(QString(", "))); stream.writeAttribute(QLatin1String("list"), childrenIndexes.join(QLatin1String(", ")));
stream.writeAttribute("childrenTimes", childrenTimes.join(QString(", "))); stream.writeAttribute(QLatin1String("childrenTimes"), childrenTimes.join(QLatin1String(", ")));
stream.writeAttribute("parentTimes", parentTimes.join(QString(", "))); stream.writeAttribute(QLatin1String("parentTimes"), parentTimes.join(QLatin1String(", ")));
stream.writeEndElement(); stream.writeEndElement();
} }
stream.writeEndElement(); stream.writeEndElement();
@@ -349,8 +349,8 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
// get the v8 time // get the v8 time
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("totalTime")) if (attributes.hasAttribute(QLatin1String("totalTime")))
d->v8MeasuredTime = attributes.value("totalTime").toString().toDouble(); d->v8MeasuredTime = attributes.value(QLatin1String("totalTime")).toString().toDouble();
while (!stream.atEnd() && !stream.hasError()) { while (!stream.atEnd() && !stream.hasError()) {
QXmlStreamReader::TokenType token = stream.readNext(); QXmlStreamReader::TokenType token = stream.readNext();
@@ -358,10 +358,10 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
switch (token) { switch (token) {
case QXmlStreamReader::StartDocument : continue; case QXmlStreamReader::StartDocument : continue;
case QXmlStreamReader::StartElement : { case QXmlStreamReader::StartElement : {
if (elementName == "event") { if (elementName == QLatin1String("event")) {
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
if (attributes.hasAttribute("index")) { if (attributes.hasAttribute(QLatin1String("index"))) {
int ndx = attributes.value("index").toString().toInt(); int ndx = attributes.value(QLatin1String("index")).toString().toInt();
if (!v8eventBuffer.value(ndx)) if (!v8eventBuffer.value(ndx))
v8eventBuffer[ndx] = new QV8EventData; v8eventBuffer[ndx] = new QV8EventData;
v8event = v8eventBuffer[ndx]; v8event = v8eventBuffer[ndx];
@@ -374,19 +374,19 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
if (!v8event) if (!v8event)
break; break;
if (elementName == "childrenEvents") { if (elementName == QLatin1String("childrenEvents")) {
QXmlStreamAttributes attributes = stream.attributes(); QXmlStreamAttributes attributes = stream.attributes();
int eventIndex = v8eventBuffer.key(v8event); int eventIndex = v8eventBuffer.key(v8event);
if (attributes.hasAttribute("list")) { if (attributes.hasAttribute(QLatin1String("list"))) {
// store for later parsing (we haven't read all the events yet) // store for later parsing (we haven't read all the events yet)
childrenIndexes[eventIndex] = attributes.value("list").toString(); childrenIndexes[eventIndex] = attributes.value(QLatin1String("list")).toString();
} }
if (attributes.hasAttribute("childrenTimes")) { if (attributes.hasAttribute(QLatin1String("childrenTimes"))) {
childrenTimes[eventIndex] = childrenTimes[eventIndex] =
attributes.value("childrenTimes").toString(); attributes.value(QLatin1String("childrenTimes")).toString();
} }
if (attributes.hasAttribute("parentTimes")) { if (attributes.hasAttribute(QLatin1String("parentTimes"))) {
parentTimes[eventIndex] = attributes.value("parentTimes").toString(); parentTimes[eventIndex] = attributes.value(QLatin1String("parentTimes")).toString();
} }
} }
@@ -395,40 +395,40 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
break; break;
QString readData = stream.text().toString(); QString readData = stream.text().toString();
if (elementName == "displayname") { if (elementName == QLatin1String("displayname")) {
v8event->displayName = readData; v8event->displayName = readData;
break; break;
} }
if (elementName == "functionname") { if (elementName == QLatin1String("functionname")) {
v8event->functionName = readData; v8event->functionName = readData;
break; break;
} }
if (elementName == "filename") { if (elementName == QLatin1String("filename")) {
v8event->filename = readData; v8event->filename = readData;
break; break;
} }
if (elementName == "line") { if (elementName == QLatin1String("line")) {
v8event->line = readData.toInt(); v8event->line = readData.toInt();
break; break;
} }
if (elementName == "totalTime") { if (elementName == QLatin1String("totalTime")) {
v8event->totalTime = readData.toDouble(); v8event->totalTime = readData.toDouble();
cumulatedV8Time += v8event->totalTime; cumulatedV8Time += v8event->totalTime;
break; break;
} }
if (elementName == "selfTime") { if (elementName == QLatin1String("selfTime")) {
v8event->selfTime = readData.toDouble(); v8event->selfTime = readData.toDouble();
break; break;
} }
break; break;
} }
case QXmlStreamReader::EndElement : { case QXmlStreamReader::EndElement : {
if (elementName == "v8profile") { if (elementName == QLatin1String("v8profile")) {
// done reading the v8 profile data // done reading the v8 profile data
break; break;
} }
@@ -443,9 +443,9 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream)
// find v8events' children and parents // find v8events' children and parents
foreach (int parentIndex, childrenIndexes.keys()) { foreach (int parentIndex, childrenIndexes.keys()) {
QStringList childrenStrings = childrenIndexes.value(parentIndex).split(","); QStringList childrenStrings = childrenIndexes.value(parentIndex).split(QLatin1String(","));
QStringList childrenTimesStrings = childrenTimes.value(parentIndex).split(", "); QStringList childrenTimesStrings = childrenTimes.value(parentIndex).split(QLatin1String(", "));
QStringList parentTimesStrings = parentTimes.value(parentIndex).split(", "); QStringList parentTimesStrings = parentTimes.value(parentIndex).split(QLatin1String(", "));
for (int ndx = 0; ndx < childrenStrings.count(); ndx++) { for (int ndx = 0; ndx < childrenStrings.count(); ndx++) {
int childIndex = childrenStrings[ndx].toInt(); int childIndex = childrenStrings[ndx].toInt();
if (v8eventBuffer.value(childIndex)) { if (v8eventBuffer.value(childIndex)) {