From 14275363e5ae678ca92a6da4778035ca2ad1594c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 16 Jul 2009 17:15:13 +1000 Subject: Add a QmlError::toString() method --- src/declarative/qml/qmlerror.cpp | 29 +++++++++++++++++------------ src/declarative/qml/qmlerror.h | 2 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp index 149e173..5ee9144 100644 --- a/src/declarative/qml/qmlerror.cpp +++ b/src/declarative/qml/qmlerror.cpp @@ -168,6 +168,21 @@ void QmlError::setColumn(int column) } /*! + Return the error as a human readable string. +*/ +QString QmlError::toString() const +{ + QString rv; + rv = url().toString() + QLatin1String(":") + QString::number(line()); + if(column() != -1) + rv += QLatin1String(":") + QString::number(column()); + + rv += QLatin1String(": ") + description(); + + return rv; +} + +/*! \relates QmlError \fn QDebug operator<<(QDebug debug, const QmlError &error) @@ -176,19 +191,9 @@ void QmlError::setColumn(int column) QDebug operator<<(QDebug debug, const QmlError &error) { - QUrl url = error.url(); - - QString output; - - output = url.toString() + QLatin1String(":") + - QString::number(error.line()); + debug << qPrintable(error.toString()); - if(error.column() != -1) - output += QLatin1String(":") + QString::number(error.column()); - - output += QLatin1String(": ") + error.description(); - - debug << qPrintable(output); + QUrl url = error.url(); if (error.line() > 0 && url.scheme() == QLatin1String("file")) { QString file = url.toLocalFile(); diff --git a/src/declarative/qml/qmlerror.h b/src/declarative/qml/qmlerror.h index 57d2f8f..c1a8720 100644 --- a/src/declarative/qml/qmlerror.h +++ b/src/declarative/qml/qmlerror.h @@ -69,6 +69,8 @@ public: void setLine(int); int column() const; void setColumn(int); + + QString toString() const; private: QmlErrorPrivate *d; }; -- cgit v0.12