Valgrind: Use Tr::tr

Change-Id: I77b27462d88079699e620ef459f951846c15c3e2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2022-07-08 16:08:27 +02:00
parent f901478c6a
commit 866f20e4f9
50 changed files with 575 additions and 1512 deletions

View File

@@ -29,6 +29,7 @@
#include "frame.h"
#include "stack.h"
#include "modelhelpers.h"
#include "../valgrindtr.h"
#include <debugger/analyzer/diagnosticlocation.h>
#include <utils/qtcassert.h>
@@ -87,7 +88,7 @@ private:
ErrorListModel::ErrorListModel(QObject *parent)
: Utils::TreeModel<>(parent)
{
setHeader(QStringList() << tr("Issue") << tr("Location"));
setHeader({Tr::tr("Issue"), Tr::tr("Location")});
}
Frame ErrorListModel::findRelevantFrame(const Error &error) const
@@ -126,7 +127,7 @@ static QString makeFrameName(const Frame &frame, bool withLocation)
if (!fn.isEmpty()) {
const QString location = withLocation || path == frame.object()
? QString::fromLatin1(" in %2").arg(path) : QString();
return QCoreApplication::translate("Valgrind::Internal", "%1%2").arg(fn, location);
return QCoreApplication::translate("Valgrind", "%1%2").arg(fn, location);
}
if (!path.isEmpty())
return path;
@@ -135,8 +136,8 @@ static QString makeFrameName(const Frame &frame, bool withLocation)
QString ErrorListModel::errorLocation(const Error &error) const
{
return QCoreApplication::translate("Valgrind::Internal", "in %1").
arg(makeFrameName(findRelevantFrame(error), true));
return QCoreApplication::translate("Valgrind", "in %1")
.arg(makeFrameName(findRelevantFrame(error), true));
}
void ErrorListModel::addError(const Error &error)
@@ -221,7 +222,7 @@ QVariant ErrorItem::data(int column, int role) const
|| m_error.stacks().constFirst().frames().constFirst().functionName().isEmpty()) {
return m_error.what();
}
return ErrorListModel::tr("%1 in function %2")
return Tr::tr("%1 in function %2")
.arg(m_error.what(), m_error.stacks().constFirst().frames().constFirst().functionName());
case Qt::ToolTipRole:
return toolTipForFrame(m_model->findRelevantFrame(m_error));

View File

@@ -39,8 +39,6 @@ class Frame;
class ErrorListModel : public Utils::TreeModel<>
{
Q_OBJECT
public:
enum Role {
ErrorRole = Debugger::DetailedErrorView::FullTextRole + 1,

View File

@@ -26,11 +26,11 @@
#include "modelhelpers.h"
#include "frame.h"
#include "../valgrindtr.h"
#include <QString>
#include <QDir>
#include <QPair>
#include <QCoreApplication>
namespace Valgrind {
namespace XmlProtocol {
@@ -48,17 +48,14 @@ QString toolTipForFrame(const Frame &frame)
QList<StringPair> lines;
if (!frame.functionName().isEmpty())
lines << qMakePair(QCoreApplication::translate("Valgrind::XmlProtocol", "Function:"),
frame.functionName());
lines << qMakePair(Tr::tr("Function:"), frame.functionName());
if (!location.isEmpty())
lines << qMakePair(QCoreApplication::translate("Valgrind::XmlProtocol", "Location:"),
location);
lines << qMakePair(Tr::tr("Location:"), location);
if (frame.instructionPointer())
lines << qMakePair(QCoreApplication::translate("Valgrind::XmlProtocol",
"Instruction pointer:"),
QString::fromLatin1("0x%1").arg(frame.instructionPointer(), 0, 16));
lines << qMakePair(Tr::tr("Instruction pointer:"),
QString("0x%1").arg(frame.instructionPointer(), 0, 16));
if (!frame.object().isEmpty())
lines << qMakePair(QCoreApplication::translate("Valgrind::XmlProtocol", "Object:"), frame.object());
lines << qMakePair(Tr::tr("Object:"), frame.object());
QString html = "<html><head>"
"<style>dt { font-weight:bold; } dd { font-family: monospace; }</style>\n"

View File

@@ -31,10 +31,11 @@
#include "stack.h"
#include "status.h"
#include "suppression.h"
#include "../valgrindtr.h"
#include <utils/qtcassert.h>
#include <QAbstractSocket>
#include <QCoreApplication>
#include <QHash>
#include <QIODevice>
#include <QPair>
@@ -173,8 +174,7 @@ static quint64 parseHex(const QString &str, const QString &context)
bool ok;
const quint64 v = str.toULongLong(&ok, 16);
if (!ok)
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Could not parse hex number from \"%1\" (%2)").arg(str, context));
throw ParserException(Tr::tr("Could not parse hex number from \"%1\" (%2)").arg(str, context));
return v;
}
@@ -183,8 +183,7 @@ static qint64 parseInt64(const QString &str, const QString &context)
bool ok;
const quint64 v = str.toLongLong(&ok);
if (!ok)
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Could not parse hex number from \"%1\" (%2)").arg(str, context));
throw ParserException(Tr::tr("Could not parse hex number from \"%1\" (%2)").arg(str, context));
return v;
}
@@ -242,8 +241,7 @@ QString Parser::Private::blockingReadElementText()
//affects at least Qt <= 4.7.1. Reported as QTBUG-14661.
if (!reader.isStartElement())
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"trying to read element text although current position is not start of element"));
throw ParserException(Tr::tr("trying to read element text although current position is not start of element"));
QString result;
@@ -260,12 +258,10 @@ QString Parser::Private::blockingReadElementText()
case QXmlStreamReader::Comment:
break;
case QXmlStreamReader::StartElement:
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unexpected child element while reading element text"));
throw ParserException(Tr::tr("Unexpected child element while reading element text"));
default:
//TODO handle
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unexpected token type %1").arg(type));
throw ParserException(Tr::tr("Unexpected token type %1").arg(type));
break;
}
}
@@ -277,11 +273,9 @@ void Parser::Private::checkProtocolVersion(const QString &versionStr)
bool ok;
const int version = versionStr.toInt(&ok);
if (!ok)
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Could not parse protocol version from \"%1\"").arg(versionStr));
throw ParserException(Tr::tr("Could not parse protocol version from \"%1\"").arg(versionStr));
if (version != 4)
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"XmlProtocol version %1 not supported (supported version: 4)").arg(version));
throw ParserException(Tr::tr("XmlProtocol version %1 not supported (supported version: 4)").arg(version));
}
void Parser::Private::checkTool(const QString &reportedStr)
@@ -289,8 +283,7 @@ void Parser::Private::checkTool(const QString &reportedStr)
const QHash<QString,Parser::Tool>::ConstIterator reported = toolsByName.constFind(reportedStr);
if (reported == toolsByName.constEnd())
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Valgrind tool \"%1\" not supported").arg(reportedStr));
throw ParserException(Tr::tr("Valgrind tool \"%1\" not supported").arg(reportedStr));
tool = reported.value();
}
@@ -349,8 +342,7 @@ MemcheckErrorKind Parser::Private::parseMemcheckErrorKind(const QString &kind)
if (it != errorKindsByName_memcheck.constEnd())
return *it;
else
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unknown memcheck error kind \"%1\"").arg(kind));
throw ParserException(Tr::tr("Unknown memcheck error kind \"%1\"").arg(kind));
}
HelgrindErrorKind Parser::Private::parseHelgrindErrorKind(const QString &kind)
@@ -359,8 +351,7 @@ HelgrindErrorKind Parser::Private::parseHelgrindErrorKind(const QString &kind)
if (it != errorKindsByName_helgrind.constEnd())
return *it;
else
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unknown helgrind error kind \"%1\"").arg(kind));
throw ParserException(Tr::tr("Unknown helgrind error kind \"%1\"").arg(kind));
}
PtrcheckErrorKind Parser::Private::parsePtrcheckErrorKind(const QString &kind)
@@ -369,8 +360,7 @@ PtrcheckErrorKind Parser::Private::parsePtrcheckErrorKind(const QString &kind)
if (it != errorKindsByName_ptrcheck.constEnd())
return *it;
else
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unknown ptrcheck error kind \"%1\"").arg(kind));
throw ParserException(Tr::tr("Unknown ptrcheck error kind \"%1\"").arg(kind));
}
int Parser::Private::parseErrorKind(const QString &kind)
@@ -386,8 +376,7 @@ int Parser::Private::parseErrorKind(const QString &kind)
default:
break;
}
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Could not parse error kind, tool not yet set."));
throw ParserException(Tr::tr("Could not parse error kind, tool not yet set."));
}
static Status::State parseState(const QString &state)
@@ -396,8 +385,7 @@ static Status::State parseState(const QString &state)
return Status::Running;
if (state == "FINISHED")
return Status::Finished;
throw ParserException(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unknown state \"%1\"").arg(state));
throw ParserException(Tr::tr("Unknown state \"%1\"").arg(state));
}
void Parser::Private::reportInternalError(const QString &e)
@@ -723,8 +711,7 @@ void Parser::Private::parse(QIODevice *device)
} catch (const ParserException &e) {
reportInternalError(e.message());
} catch (...) {
reportInternalError(QCoreApplication::translate("Valgrind::XmlProtocol::Parser",
"Unexpected exception caught during parsing."));
reportInternalError(Tr::tr("Unexpected exception caught during parsing."));
}
emit q->finished();
}

View File

@@ -29,6 +29,7 @@
#include "frame.h"
#include "stack.h"
#include "modelhelpers.h"
#include "../valgrindtr.h"
#include <utils/qtcassert.h>
@@ -155,19 +156,19 @@ QVariant StackModel::headerData(int section, Qt::Orientation orientation, int ro
switch (section) {
case NameColumn:
return tr("Description");
return Tr::tr("Description");
case InstructionPointerColumn:
return tr("Instruction Pointer");
return Tr::tr("Instruction Pointer");
case ObjectColumn:
return tr("Object");
return Tr::tr("Object");
case FunctionNameColumn:
return tr("Function");
return Tr::tr("Function");
case DirectoryColumn:
return tr("Directory");
return Tr::tr("Directory");
case FileColumn:
return tr("File");
return Tr::tr("File");
case LineColumn:
return tr("Line");
return Tr::tr("Line");
}
return QVariant();

View File

@@ -27,9 +27,8 @@
#include "threadedparser.h"
#include "parser.h"
#include "error.h"
#include "frame.h"
#include "status.h"
#include "suppression.h"
#include <utils/qtcassert.h>
#include <QIODevice>