OSDN Git Service

fix some compiler warnings in benchmarks
authorIvailo Monev <xakepa10@gmail.com>
Tue, 12 Jul 2016 12:44:50 +0000 (12:44 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 12 Jul 2016 12:44:50 +0000 (12:44 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
tests/benchmarks/declarative/compilation/tst_compilation.cpp
tests/benchmarks/gui/graphicsview/qgraphicsview/benchapps/chipTest/chip.cpp
tests/benchmarks/gui/graphicsview/qgraphicsview/chiptester/chip.cpp
tests/benchmarks/gui/image/qimagereader/tst_qimagereader.cpp
tests/benchmarks/gui/painting/qtbench/benchmarktests.h
tests/benchmarks/gui/painting/qtbench/tst_qtbench.cpp
tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp

index ef62982..2513948 100644 (file)
@@ -68,7 +68,7 @@ inline QUrl TEST_FILE(const QString &filename)
 
 void tst_compilation::boomblock()
 {
-    QFile f(SRCDIR + QLatin1String("/data/BoomBlock.qml"));
+    QFile f(QLatin1String(SRCDIR) + QLatin1String("/data/BoomBlock.qml"));
     QVERIFY(f.open(QIODevice::ReadOnly));
     QByteArray data = f.readAll();
 
index 650150c..d703977 100644 (file)
@@ -111,8 +111,8 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
         painter->save();
         painter->scale(0.1, 0.1);
         painter->drawText(170, 180, QString("Model: VSC-2000 (Very Small Chip) at %1x%2").arg(x).arg(y));
-        painter->drawText(170, 200, QString("Serial number: DLWR-WEER-123L-ZZ33-SDSJ"));
-        painter->drawText(170, 220, QString("Manufacturer: Chip Manufacturer"));
+        painter->drawText(170, 200, QLatin1String("Serial number: DLWR-WEER-123L-ZZ33-SDSJ"));
+        painter->drawText(170, 220, QLatin1String("Manufacturer: Chip Manufacturer"));
         painter->restore();
     }
 
index 6ac21fa..383c307 100644 (file)
@@ -116,8 +116,8 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
         painter->save();
         painter->scale(0.1, 0.1);
         painter->drawText(170, 180, QString("Model: VSC-2000 (Very Small Chip) at %1x%2").arg(x).arg(y));
-        painter->drawText(170, 200, QString("Serial number: DLWR-WEER-123L-ZZ33-SDSJ"));
-        painter->drawText(170, 220, QString("Manufacturer: Chip Manufacturer"));
+        painter->drawText(170, 200, QLatin1String("Serial number: DLWR-WEER-123L-ZZ33-SDSJ"));
+        painter->drawText(170, 220, QLatin1String("Manufacturer: Chip Manufacturer"));
         painter->restore();
     }
 
index 67b1f44..c5d9c36 100644 (file)
@@ -155,7 +155,7 @@ void tst_QImageReader::readImage()
     QFETCH(QByteArray, format);
 
     QBENCHMARK {
-        QImageReader io("images/" + fileName, format);
+        QImageReader io(QLatin1String("images/") + fileName, format);
         QImage image = io.read();
         QVERIFY(!image.isNull());
     }
@@ -186,7 +186,7 @@ void tst_QImageReader::setScaledSize()
     QFETCH(QByteArray, format);
 
     QBENCHMARK {
-        QImageReader reader("images/" + fileName, format);
+        QImageReader reader(QLatin1String("images/") + fileName, format);
         reader.setScaledSize(newSize);
         QImage image = reader.read();
         QCOMPARE(image.size(), newSize);
@@ -213,7 +213,7 @@ void tst_QImageReader::setClipRect()
     QFETCH(QByteArray, format);
 
     QBENCHMARK {
-        QImageReader reader("images/" + fileName, format);
+        QImageReader reader(QLatin1String("images/") + fileName, format);
         reader.setClipRect(newRect);
         QImage image = reader.read();
         QCOMPARE(image.rect(), newRect);
@@ -232,7 +232,7 @@ void tst_QImageReader::setScaledClipRect()
     QFETCH(QByteArray, format);
 
     QBENCHMARK {
-        QImageReader reader("images/" + fileName, format);
+        QImageReader reader(QLatin1String("images/") + fileName, format);
         reader.setScaledSize(QSize(300, 300));
         reader.setScaledClipRect(newRect);
         QImage image = reader.read();
index dd242a1..e1b0d65 100644 (file)
 #include <QTextLayout>
 #include <QFontMetrics>
 #include <QDebug>
-
-#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
-#  include <QStaticText>
-#endif
+#include <QStaticText>
 
 class Benchmark
 {
@@ -335,7 +332,7 @@ public:
     DrawScaledImage(const QImage &image, qreal scale, bool asPixmap)
         : Benchmark(QSize(image.width(), image.height())),
           m_image(image),
-          m_type(m_as_pixmap ? "Pixmap" : "Image"),
+          m_type(m_as_pixmap ? QLatin1String("Pixmap") : QLatin1String("Image")),
           m_scale(scale),
           m_as_pixmap(asPixmap)
     {
@@ -383,7 +380,7 @@ public:
     DrawTransformedImage(const QImage &image, bool asPixmap)
         : Benchmark(QSize(image.width(), image.height())),
           m_image(image),
-          m_type(m_as_pixmap ? "Pixmap" : "Image"),
+          m_type(m_as_pixmap ? QLatin1String("Pixmap") : QLatin1String("Image")),
           m_as_pixmap(asPixmap)
     {
         m_pixmap = QPixmap::fromImage(m_image);
@@ -429,7 +426,7 @@ public:
     DrawImage(const QImage &image, bool asPixmap)
         : Benchmark(QSize(image.width(), image.height())),
           m_image(image),
-          m_type(m_as_pixmap ? "Pixmap" : "Image"),
+          m_type(m_as_pixmap ? QLatin1String("Pixmap") : QLatin1String("Image")),
           m_as_pixmap(asPixmap)
     {
         m_pixmap = QPixmap::fromImage(image);
@@ -472,13 +469,10 @@ public:
         PainterQPointMode,
         LayoutMode,
         DocumentMode,
-        PixmapMode
-
-#if QT_VERSION >= 0x040700
-        , StaticTextMode,
+        PixmapMode,
+        StaticTextMode,
         StaticTextWithMaximumSizeMode,
         StaticTextBackendOptimizations
-#endif
     };
 
     DrawText(const QString &text, Mode mode)
@@ -487,12 +481,8 @@ public:
     }
 
     virtual void begin(QPainter *p, int iterations) {
-#if QT_VERSION >= 0x040700
         m_staticTexts.clear();
         m_currentStaticText = 0;
-#else
-        Q_UNUSED(iterations);
-#endif
         m_pixmaps.clear();
         m_currentPixmap = 0;
         QRect m_bounds = QRect(0,0,p->device()->width(), p->device()->height());
@@ -516,10 +506,9 @@ public:
                 m_pixmaps.append(pixmap);
             }
             break;
-
         case LayoutMode: {
             QRect r = p->boundingRect(m_bounds, 0, m_text);
-            QStringList lines = m_text.split('\n');
+            QStringList lines = m_text.split(QLatin1Char('\n'));
             int height = 0;
             int leading = p->fontMetrics().leading();
             m_layout.beginLayout();
@@ -536,7 +525,6 @@ public:
             m_size = m_layout.boundingRect().toRect().size();
             break; }
 
-#if QT_VERSION >= 0x040700
         case StaticTextWithMaximumSizeMode: {
             QStaticText staticText;
             m_size = (p->boundingRect(m_bounds, 0, m_text)).size();
@@ -570,7 +558,6 @@ public:
 
             break;
         }
-#endif
 
         case PainterQPointMode: {
             QFontMetrics fm(p->font());
@@ -602,8 +589,6 @@ public:
         case LayoutMode:
             m_layout.draw(p, rect.topLeft());
             break;
-
-#if QT_VERSION >= 0x040700
         case StaticTextWithMaximumSizeMode:
         case StaticTextMode:
             p->drawStaticText(rect.topLeft(), m_staticTexts.at(0));
@@ -612,28 +597,24 @@ public:
             p->drawStaticText(rect.topLeft(), m_staticTexts.at(m_currentStaticText));
             m_currentStaticText = (m_currentStaticText + 1) % m_staticTexts.size();
             break;
-#endif
         }
     }
 
     virtual QString name() const {
         int letters = m_text.length();
-        int lines = m_text.count('\n');
+        int lines = m_text.count(QLatin1Char('\n'));
         if (lines == 0)
             lines = 1;
         QString type;
         switch (m_mode) {
-        case PainterMode: type = "drawText(rect)"; break;
-        case PainterQPointMode: type = "drawText(point)"; break;
-        case LayoutMode: type = "layout.draw()"; break;
-        case DocumentMode: type = "doc.drawContents()"; break;
-        case PixmapMode: type = "pixmap cached text"; break;
-
-#if QT_VERSION >= 0x040700
-        case StaticTextMode: type = "drawStaticText()"; break;
-        case StaticTextWithMaximumSizeMode: type = "drawStaticText() w/ maxsize"; break;
-        case StaticTextBackendOptimizations: type = "drawStaticText() w/ backend optimizations"; break;
-#endif
+        case PainterMode: type = QLatin1String("drawText(rect)"); break;
+        case PainterQPointMode: type = QLatin1String("drawText(point)"); break;
+        case LayoutMode: type = QLatin1String("layout.draw()"); break;
+        case DocumentMode: type = QLatin1String("doc.drawContents()"); break;
+        case PixmapMode: type = QLatin1String("pixmap cached text"); break;
+        case StaticTextMode: type = QLatin1String("drawStaticText()"); break;
+        case StaticTextWithMaximumSizeMode: type = QLatin1String("drawStaticText() w/ maxsize"); break;
+        case StaticTextBackendOptimizations: type = QLatin1String("drawStaticText() w/ backend optimizations"); break;
         }
 
         return QString::fromLatin1("%3, len=%1, lines=%2")
@@ -651,10 +632,8 @@ private:
     QList<QPixmap> m_pixmaps;
     int m_currentPixmap;
 
-#if QT_VERSION >= 0x040700
     int m_currentStaticText;
     QList<QStaticText> m_staticTexts;
-#endif
 };
 
 
@@ -749,28 +728,28 @@ public:
         QString namedType;
         switch (m_type) {
         case RectClip:
-            namedType = "rect";
+            namedType = QLatin1String("rect");
             break;
         case TwoRectRegionClip:
-            namedType = "two-rect-region";
+            namedType = QLatin1String("two-rect-region");
             break;
         case EllipseRegionClip:
-            namedType = "ellipse-region";
+            namedType = QLatin1String("ellipse-region");
             break;
         case TwoRectPathClip:
-            namedType = "two-rect-path";
+            namedType = QLatin1String("two-rect-path");
             break;
         case EllipsePathClip:
-            namedType = "ellipse-path";
+            namedType = QLatin1String("ellipse-path");
             break;
         case AAEllipsePathClip:
-            namedType = "aa-ellipse-path";
+            namedType = QLatin1String("aa-ellipse-path");
             break;
         case EllipseRegionThenRectClip:
-            namedType = "ellipseregion&rect";
+            namedType = QLatin1String("ellipseregion&rect");
             break;
         case EllipsePathThenRectClip:
-            namedType = "ellipsepath&rect";
+            namedType = QLatin1String("ellipsepath&rect");
             break;
         }
         return QString::fromLatin1("%1-clipped-drawRect(%2)").arg(namedType).arg(m_size.width());
index 7d72096..bde96c6 100644 (file)
@@ -168,8 +168,8 @@ void tst_QtBench::qtBench_data()
 
     QString shortString = makeString(5);
     QString middleString = makeString(50);
-    QString longString = makeString(35) + "\n"
-                         + makeString(45) + "\n"
+    QString longString = makeString(35) + QLatin1Char('\n')
+                         + makeString(45) + QLatin1Char('\n')
                          + makeString(75);
     QString superLongString = QLatin1String("Lorem ipsum dolor sit am\n"
                               "et, consectetur adipisci\n"
index e4d3240..69ab7b6 100644 (file)
@@ -67,25 +67,25 @@ QWidget *tst_qstylesheetstyle::buildSimpleWidgets()
     QWidget *w = new QWidget();
     QGridLayout *layout = new QGridLayout(w);
     w->setLayout(layout);
-    layout->addWidget(new QPushButton("pushButton")     ,0,0);
-    layout->addWidget(new QComboBox()                   ,0,1);
-    layout->addWidget(new QCheckBox("checkBox")         ,0,2);
-    layout->addWidget(new QRadioButton("radioButton")   ,0,3);
-    layout->addWidget(new QLineEdit()                   ,1,0);
-    layout->addWidget(new QLabel("label")               ,1,1);
-    layout->addWidget(new QSpinBox()                    ,1,2);
-    layout->addWidget(new QProgressBar()                ,1,3);
+    layout->addWidget(new QPushButton(QLatin1String("pushButton"))     ,0,0);
+    layout->addWidget(new QComboBox()                                  ,0,1);
+    layout->addWidget(new QCheckBox(QLatin1String("checkBox"))         ,0,2);
+    layout->addWidget(new QRadioButton(QLatin1String("radioButton"))   ,0,3);
+    layout->addWidget(new QLineEdit()                                  ,1,0);
+    layout->addWidget(new QLabel(QLatin1String("label"))               ,1,1);
+    layout->addWidget(new QSpinBox()                                   ,1,2);
+    layout->addWidget(new QProgressBar()                               ,1,3);
     return w;
 }
 
 void tst_qstylesheetstyle::empty()
 {
     QWidget *w = buildSimpleWidgets();
-    w->setStyleSheet("/* */");
+    w->setStyleSheet(QLatin1String("/* */"));
     QApplication::processEvents();
     int i = 0;
     QBENCHMARK {
-        w->setStyleSheet("/*" + QString::number(i) + "*/");
+        w->setStyleSheet(QLatin1String("/*") + QString::number(i) + QLatin1String("*/"));
         i++; // we want a different string in case we have severals iterations
     }
     delete w;
@@ -94,11 +94,11 @@ void tst_qstylesheetstyle::empty()
 void tst_qstylesheetstyle::empty_events()
 {
     QWidget *w = buildSimpleWidgets();
-    w->setStyleSheet("/* */");
+    w->setStyleSheet(QLatin1String("/* */"));
     QApplication::processEvents();
     int i = 0;
     QBENCHMARK {
-        w->setStyleSheet("/*" + QString::number(i) + "*/");
+        w->setStyleSheet(QLatin1String("/*") + QString::number(i) + QLatin1String("*/"));
         i++; // we want a different string in case we have severals iterations
         qApp->processEvents();
     }
@@ -113,11 +113,11 @@ static const char *simple_css =
 void tst_qstylesheetstyle::simple()
 {
     QWidget *w = buildSimpleWidgets();
-    w->setStyleSheet("/* */");
+    w->setStyleSheet(QLatin1String("/* */"));
     QApplication::processEvents();
     int i = 0;
     QBENCHMARK {
-        w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
+        w->setStyleSheet(QLatin1String(simple_css) + QLatin1String("/*") + QString::number(i) + QLatin1String("*/"));
         i++; // we want a different string in case we have severals iterations
     }
     delete w;
@@ -126,11 +126,11 @@ void tst_qstylesheetstyle::simple()
 void tst_qstylesheetstyle::simple_events()
 {
     QWidget *w = buildSimpleWidgets();
-    w->setStyleSheet("/* */");
+    w->setStyleSheet(QLatin1String("/* */"));
     QApplication::processEvents();
     int i = 0;
     QBENCHMARK {
-        w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
+        w->setStyleSheet(QLatin1String(simple_css) + QLatin1String("/*") + QString::number(i) + QLatin1String("*/"));
         i++; // we want a different string in case we have severals iterations
         qApp->processEvents();
     }
@@ -169,7 +169,7 @@ void tst_qstylesheetstyle::grid()
         stylesheet += QString("#label%1 { background-color: rgb(0,%2,%3); color: rgb(%2,%3,255);  } ").arg(y*N+x).arg(y*255/N).arg(x*255/N);
     }
 
-    w->setStyleSheet("/* */");
+    w->setStyleSheet(QLatin1String("/* */"));
     if(show) {
         w->show();
         QTest::qWaitForWindowShown(w);