Using QLatin1String instead of QLatin1Literal

QLatin1Literal is just a typedef of QLatin1String.

Change-Id: If20ca225e57a7fb45a7775f0fc81aedb6da88c96
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
Debao Zhang 2012-04-16 13:16:11 -07:00 committed by Qt by Nokia
parent b9790a04ee
commit 6fb0110f97
9 changed files with 11 additions and 16 deletions

View File

@ -715,7 +715,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
return false; return false;
QFileInfo info(fileName); QFileInfo info(fileName);
QString key = QLatin1Literal("qt_pixmap") QString key = QLatin1String("qt_pixmap")
% info.absoluteFilePath() % info.absoluteFilePath()
% HexString<uint>(info.lastModified().toTime_t()) % HexString<uint>(info.lastModified().toTime_t())
% HexString<quint64>(info.size()) % HexString<quint64>(info.size())

View File

@ -100,7 +100,7 @@ QPixmap qt_pixmapForBrush(int brushStyle, bool invert)
{ {
QPixmap pm; QPixmap pm;
QString key = QLatin1Literal("$qt-brush$") QString key = QLatin1String("$qt-brush$")
% HexString<uint>(brushStyle) % HexString<uint>(brushStyle)
% QLatin1Char(invert ? '1' : '0'); % QLatin1Char(invert ? '1' : '0');
if (!QPixmapCache::find(key, pm)) { if (!QPixmapCache::find(key, pm)) {

View File

@ -6109,7 +6109,7 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen)
{ {
const qreal radiusBase = qMax(qreal(1), maxRadius); const qreal radiusBase = qMax(qreal(1), maxRadius);
QString key = QLatin1Literal("WaveUnderline-") QString key = QLatin1String("WaveUnderline-")
% pen.color().name() % pen.color().name()
% HexString<qreal>(radiusBase); % HexString<qreal>(radiusBase);

View File

@ -266,7 +266,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
actualSize.scale(size, Qt::KeepAspectRatio); actualSize.scale(size, Qt::KeepAspectRatio);
// #### Qt5 no idea what this really does, but we need to remove the QApp and style references // #### Qt5 no idea what this really does, but we need to remove the QApp and style references
QString key = QLatin1Literal("qt_") QString key = QLatin1String("qt_")
% HexString<quint64>(pm.cacheKey()) % HexString<quint64>(pm.cacheKey())
% HexString<uint>(pe->mode) % HexString<uint>(pe->mode)
% HexString<quint64>(QApplication::palette().cacheKey()) % HexString<quint64>(QApplication::palette().cacheKey())

View File

@ -507,7 +507,7 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st
basePixmap.load(filename); basePixmap.load(filename);
int actualSize = qMin(size.width(), size.height()); int actualSize = qMin(size.width(), size.height());
QString key = QLatin1Literal("$qt_theme_") QString key = QLatin1String("$qt_theme_")
% HexString<qint64>(basePixmap.cacheKey()) % HexString<qint64>(basePixmap.cacheKey())
% HexString<int>(mode) % HexString<int>(mode)
% HexString<qint64>(qApp->palette().cacheKey()) % HexString<qint64>(qApp->palette().cacheKey())

View File

@ -707,7 +707,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
// thin rectangular images // thin rectangular images
const int pmSize = 64; const int pmSize = 64;
const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget); const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
const QString pmKey = QLatin1Literal("windowframe") % HexString<uint>(option->state); const QString pmKey = QLatin1String("windowframe") % HexString<uint>(option->state);
QPixmap pixmap; QPixmap pixmap;
QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));

View File

@ -487,7 +487,7 @@ static void qBrushSetAlphaF(QBrush *brush, qreal alpha)
// Modify the texture - ridiculously expensive. // Modify the texture - ridiculously expensive.
QPixmap texture = brush->texture(); QPixmap texture = brush->texture();
QPixmap pixmap; QPixmap pixmap;
QString name = QLatin1Literal("qbrushtexture-alpha") QString name = QLatin1String("qbrushtexture-alpha")
% HexString<qreal>(alpha) % HexString<qreal>(alpha)
% HexString<qint64>(texture.cacheKey()); % HexString<qint64>(texture.cacheKey());
if (!QPixmapCache::find(name, pixmap)) { if (!QPixmapCache::find(name, pixmap)) {
@ -550,7 +550,7 @@ static QBrush qBrushLight(QBrush brush, int light)
// Modify the texture - ridiculously expensive. // Modify the texture - ridiculously expensive.
QPixmap texture = brush.texture(); QPixmap texture = brush.texture();
QPixmap pixmap; QPixmap pixmap;
QString name = QLatin1Literal("qbrushtexture-light") QString name = QLatin1String("qbrushtexture-light")
% HexString<int>(light) % HexString<int>(light)
% HexString<qint64>(texture.cacheKey()); % HexString<qint64>(texture.cacheKey());
@ -612,7 +612,7 @@ static QBrush qBrushDark(QBrush brush, int dark)
// Modify the texture - ridiculously expensive. // Modify the texture - ridiculously expensive.
QPixmap texture = brush.texture(); QPixmap texture = brush.texture();
QPixmap pixmap; QPixmap pixmap;
QString name = QLatin1Literal("qbrushtexture-dark") QString name = QLatin1String("qbrushtexture-dark")
% HexString<int>(dark) % HexString<int>(dark)
% HexString<qint64>(texture.cacheKey()); % HexString<qint64>(texture.cacheKey());
@ -739,7 +739,7 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto
static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, static void qt_plastique_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart,
const QColor &gradientStop) const QColor &gradientStop)
{ {
QString gradientName = QLatin1Literal("qplastique-g") QString gradientName = QLatin1String("qplastique-g")
% HexString<int>(rect.width()) % HexString<int>(rect.width())
% HexString<int>(rect.height()) % HexString<int>(rect.height())
% HexString<QRgb>(gradientStart.rgba()) % HexString<QRgb>(gradientStart.rgba())

View File

@ -68,7 +68,6 @@ void runScenario()
{ {
// this code is latin1. TODO: replace it with the utf8 block below, once // this code is latin1. TODO: replace it with the utf8 block below, once
// strings default to utf8. // strings default to utf8.
QLatin1Literal l1literal(LITERAL);
QLatin1String l1string(LITERAL); QLatin1String l1string(LITERAL);
QString string(l1string); QString string(l1string);
QStringRef stringref(&string, 2, 10); QStringRef stringref(&string, 2, 10);
@ -78,14 +77,10 @@ void runScenario()
QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL);
QString r; QString r;
r = l1literal Q l1literal;
QCOMPARE(r, r2);
r = string P string; r = string P string;
QCOMPARE(r, r2); QCOMPARE(r, r2);
r = stringref Q stringref; r = stringref Q stringref;
QCOMPARE(r, QString(stringref.toString() + stringref.toString())); QCOMPARE(r, QString(stringref.toString() + stringref.toString()));
r = string Q l1literal;
QCOMPARE(r, r2);
r = string P l1string; r = string P l1string;
QCOMPARE(r, r2); QCOMPARE(r, r2);
r = string Q QStringLiteral(LITERAL); r = string Q QStringLiteral(LITERAL);

View File

@ -1153,7 +1153,7 @@ void tst_QLocalSocket::verifyListenWithDescriptor_data()
QTest::addColumn<bool>("abstract"); QTest::addColumn<bool>("abstract");
QTest::addColumn<bool>("bound"); QTest::addColumn<bool>("bound");
QTest::newRow("normal") << QDir::tempPath() + QLatin1Literal("/testsocket") << false << true; QTest::newRow("normal") << QDir::tempPath() + QLatin1String("/testsocket") << false << true;
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QTest::newRow("absrtact") << QString::fromLatin1("abstractsocketname") << true << true; QTest::newRow("absrtact") << QString::fromLatin1("abstractsocketname") << true << true;
QTest::newRow("abstractwithslash") << QString::fromLatin1("abstractsocketwitha/inthename") << true << true; QTest::newRow("abstractwithslash") << QString::fromLatin1("abstractsocketwitha/inthename") << true << true;