Declarative: Fix ASCII conversion warnings.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Fri, 30 Sep 2011 11:50:59 +0000 (13:50 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 30 Sep 2011 12:08:51 +0000 (14:08 +0200)
Change-Id: Ide43c1e37eeda8e5dc2c2d24b99c3b4f96e1b53e
Reviewed-on: http://codereview.qt-project.org/5867
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
src/declarative/items/context2d/qsgcontext2d.cpp
src/declarative/items/qsganimation.cpp
src/declarative/items/qsgspriteimage.cpp
src/declarative/particles/qsgparticlesmodule.cpp
src/declarative/particles/qsgparticlesystem.cpp
src/declarative/particles/qsgturbulence.cpp

index 71cc9dc..e9cf65d 100644 (file)
@@ -829,10 +829,10 @@ static v8::Handle<v8::Value> ctx2d_fillStyle(v8::Local<v8::String>, const v8::Ac
         if (color.alpha() == 255)
             return engine->toString(color.name());
         QString alphaString = QString::number(color.alphaF(), 'f');
-        while (alphaString.endsWith('0'))
+        while (alphaString.endsWith(QLatin1Char('0')))
             alphaString.chop(1);
-        if (alphaString.endsWith('.'))
-            alphaString += '0';
+        if (alphaString.endsWith(QLatin1Char('.')))
+            alphaString += QLatin1Char('0');
         return engine->toString(QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString));
     }
     return r->context->m_fillStyle;
@@ -898,10 +898,10 @@ static void ctx2d_fillRule_set(v8::Local<v8::String>, v8::Local<v8::Value> value
 
     QV8Engine *engine = V8ENGINE_ACCESSOR();
 
-    if ((value->IsString() && engine->toString(value) == "WindingFill")
+    if ((value->IsString() && engine->toString(value) == QStringLiteral("WindingFill"))
       ||(value->IsNumber() && value->NumberValue() == Qt::WindingFill)) {
         r->context->state.fillRule = Qt::WindingFill;
-    } else if ((value->IsString() && engine->toString(value) == "OddEvenFill")
+    } else if ((value->IsString() && engine->toString(value) == QStringLiteral("OddEvenFill"))
                ||(value->IsNumber() && value->NumberValue() == Qt::OddEvenFill)) {
         r->context->state.fillRule = Qt::OddEvenFill;
     } else {
@@ -934,10 +934,10 @@ v8::Handle<v8::Value> ctx2d_strokeStyle(v8::Local<v8::String>, const v8::Accesso
         if (color.alpha() == 255)
             return engine->toString(color.name());
         QString alphaString = QString::number(color.alphaF(), 'f');
-        while (alphaString.endsWith('0'))
+        while (alphaString.endsWith(QLatin1Char('0')))
             alphaString.chop(1);
-        if (alphaString.endsWith('.'))
-            alphaString += '0';
+        if (alphaString.endsWith(QLatin1Char('.')))
+            alphaString += QLatin1Char('0');
         return engine->toString(QString::fromLatin1("rgba(%1, %2, %3, %4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(alphaString));
     }
     return r->context->m_strokeStyle;
@@ -1177,14 +1177,14 @@ static v8::Handle<v8::Value> ctx2d_createPattern(const v8::Arguments &args)
                 styleResouce->brush.setTextureImage(patternTexture);
 
                 QString repetition = engine->toString(args[1]);
-                if (repetition == "repeat" || repetition.isEmpty()) {
+                if (repetition == QStringLiteral("repeat") || repetition.isEmpty()) {
                     styleResouce->patternRepeatX = true;
                     styleResouce->patternRepeatY = true;
-                } else if (repetition == "repeat-x") {
+                } else if (repetition == QStringLiteral("repeat-x")) {
                     styleResouce->patternRepeatX = true;
-                } else if (repetition == "repeat-y") {
+                } else if (repetition == QStringLiteral("repeat-y")) {
                     styleResouce->patternRepeatY = true;
-                } else if (repetition == "no-repeat") {
+                } else if (repetition == QStringLiteral("no-repeat")) {
                     styleResouce->patternRepeatY = false;
                     styleResouce->patternRepeatY = false;
                 } else {
@@ -3320,7 +3320,7 @@ void QSGContext2D::reset()
     newState.textAlign = QSGContext2D::Start;
     newState.textBaseline = QSGContext2D::Alphabetic;
 
-    m_fontString = "";
+    m_fontString.clear();
     m_stateStack.clear();
     m_stateStack.push(newState);
     popState();
@@ -3347,4 +3347,4 @@ void QSGContext2D::setV8Engine(QV8Engine *engine)
     }
 }
 
-QT_END_NAMESPACE
\ No newline at end of file
+QT_END_NAMESPACE
index 59c9fe3..e57edbd 100644 (file)
@@ -722,8 +722,8 @@ void QSGPathAnimationUpdater::setValue(qreal v)
     }
 
     //### could cache properties rather than reconstructing each time
-    QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, "x"), currentPos.x(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
-    QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, "y"), currentPos.y(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+    QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, QStringLiteral("x")), currentPos.x(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+    QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, QStringLiteral("y")), currentPos.y(), QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
 
     //adjust angle according to orientation
     if (!fixed) {
@@ -774,7 +774,7 @@ void QSGPathAnimationUpdater::setValue(qreal v)
             else if (v > exitStart)
                 angle = endRotation * (v - exitStart) / exitInterval + angle * (exitInterval - (v - exitStart)) / exitInterval;
         }
-        QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, "rotation"), angle, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
+        QDeclarativePropertyPrivate::write(QDeclarativeProperty(target, QStringLiteral("rotation")), angle, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
     }
 
     /*
index 8f3256e..1814bc1 100644 (file)
@@ -98,11 +98,11 @@ class SpriteMaterialData : public QSGMaterialShader
 public:
     SpriteMaterialData(const char *vertexFile = 0, const char *fragmentFile = 0)
     {
-        QFile vf(vertexFile ? vertexFile : ":defaultshaders/spriteimagevertex.shader");
+        QFile vf(vertexFile ? QLatin1String(vertexFile) : QLatin1String(":defaultshaders/spriteimagevertex.shader"));
         vf.open(QFile::ReadOnly);
         m_vertex_code = vf.readAll();
 
-        QFile ff(fragmentFile ? fragmentFile : ":defaultshaders/spriteimagefragment.shader");
+        QFile ff(fragmentFile ? QLatin1String(fragmentFile) : QLatin1String(":defaultshaders/spriteimagefragment.shader"));
         ff.open(QFile::ReadOnly);
         m_fragment_code = ff.readAll();
 
index f880842..362a361 100644 (file)
@@ -106,10 +106,14 @@ void QSGParticlesModule::defineModule()
     qmlRegisterType<QSGTargetAffector>(uri, 2, 0 , "Target");
 
     //Exposed just for completeness
-    qmlRegisterUncreatableType<QSGParticleAffector>(uri, 2, 0, "ParticleAffector", "Abstract type. Use one of the inheriting types instead.");
-    qmlRegisterUncreatableType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter", "Abstract type. Use one of the inheriting types instead.");
-    qmlRegisterUncreatableType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder", "Abstract type. Use one of the inheriting types instead.");
-    qmlRegisterUncreatableType<QSGDirection>(uri, 2, 0, "NullVector", "Abstract type. Use one of the inheriting types instead.");
+    qmlRegisterUncreatableType<QSGParticleAffector>(uri, 2, 0, "ParticleAffector",
+                                                    QStringLiteral("Abstract type. Use one of the inheriting types instead."));
+    qmlRegisterUncreatableType<QSGParticlePainter>(uri, 2, 0, "ParticlePainter",
+                                                   QStringLiteral("Abstract type. Use one of the inheriting types instead."));
+    qmlRegisterUncreatableType<QSGParticleExtruder>(uri, 2, 0, "ParticleExtruder",
+                                                    QStringLiteral("Abstract type. Use one of the inheriting types instead."));
+    qmlRegisterUncreatableType<QSGDirection>(uri, 2, 0, "NullVector",
+                                             QStringLiteral("Abstract type. Use one of the inheriting types instead."));
 }
 
 QT_END_NAMESPACE
index 78e37e7..9190bd4 100644 (file)
@@ -635,7 +635,7 @@ void QSGParticleSystem::initGroups()
 
     QSGParticleGroupData* gd = new QSGParticleGroupData(0, this);//Default group
     groupData.insert(0,gd);
-    groupIds.insert("",0);
+    groupIds.insert(QString(), 0);
     m_nextGroupId = 1;
 }
 
@@ -802,7 +802,7 @@ void QSGParticleSystem::loadPainter(QObject *p)
     int particleCount = 0;
     if (painter->groups().isEmpty()){//Uses default particle
         QStringList def;
-        def << "";
+        def << QString();
         painter->setGroups(def);
         particleCount += groupData[0]->size();
         groupData[0]->painters << painter;
index a5a2410..1cac833 100644 (file)
@@ -140,7 +140,7 @@ void QSGTurbulenceAffector::initializeGrid()
     if (!m_noiseSource.isEmpty())
         image = QImage(m_noiseSource.toLocalFile()).scaled(QSize(m_gridSize, m_gridSize));
     if (image.isNull())
-        image = QImage(":defaultshaders/noise.png").scaled(QSize(m_gridSize, m_gridSize));
+        image = QImage(QStringLiteral(":defaultshaders/noise.png")).scaled(QSize(m_gridSize, m_gridSize));
 
     for (int i=0; i<m_gridSize; i++)
         for (int j=0; j<m_gridSize; j++)