From 575ede308e7a237980c3c1ba50a7e80941cd34c6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 2 May 2012 16:32:26 +0200 Subject: [PATCH] Change remaining uses of {to,from}Ascii to {to,from}Latin1 [QtGui] This operation should be a no-op anyway, since at this point in time, the fromAscii and toAscii functions simply call their fromLatin1 and toLatin1 counterparts. Task-number: QTBUG-21872 Change-Id: I2850033159508ebb1ff7564e15b99a146dbee94c Reviewed-by: Lars Knoll --- src/gui/image/qimage.h | 16 ++++++++-------- src/gui/text/qtextdocument.cpp | 2 +- tests/auto/gui/image/qimagereader/tst_qimagereader.cpp | 4 ++-- .../auto/gui/text/qtextdocument/tst_qtextdocument.cpp | 18 +++++++++--------- .../tst_qtextdocumentfragment.cpp | 16 ++++++++-------- tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 2 +- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 18 +++++++++--------- tests/benchmarks/gui/image/blendbench/main.cpp | 2 +- .../benchmarks/gui/painting/qpainter/tst_qpainter.cpp | 2 +- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index db54969..aa81061 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -326,9 +326,9 @@ inline QString QImage::text(const char* key, const char* lang) const { if (!d) return QString(); - QString k = QString::fromAscii(key); + QString k = QString::fromLatin1(key); if (lang && *lang) - k += QLatin1Char('/') + QString::fromAscii(lang); + k += QLatin1Char('/') + QString::fromLatin1(lang); return text(k); } @@ -342,8 +342,8 @@ inline QList QImage::textList() const int index = keys.at(i).indexOf(QLatin1Char('/')); if (index > 0) { QImageTextKeyLang tkl(true); - tkl.key = keys.at(i).left(index).toAscii(); - tkl.lang = keys.at(i).mid(index+1).toAscii(); + tkl.key = keys.at(i).left(index).toLatin1(); + tkl.lang = keys.at(i).mid(index+1).toLatin1(); imageTextKeys += tkl; } } @@ -370,9 +370,9 @@ inline QString QImage::text(const QImageTextKeyLang&kl) const { if (!d) return QString(); - QString k = QString::fromAscii(kl.key.constData()); + QString k = QString::fromLatin1(kl.key.constData()); if (!kl.lang.isEmpty()) - k += QLatin1Char('/') + QString::fromAscii(kl.lang.constData()); + k += QLatin1Char('/') + QString::fromLatin1(kl.lang.constData()); return text(k); } @@ -386,9 +386,9 @@ inline void QImage::setText(const char* key, const char* lang, const QString &s) if (!d) return; - QString k = QString::fromAscii(key); + QString k = QString::fromLatin1(key); if (lang && *lang) - k += QLatin1Char('/') + QString::fromAscii(lang); + k += QLatin1Char('/') + QString::fromLatin1(lang); setText(k, s); } diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index f9fe166..89f6d1a 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2025,7 +2025,7 @@ QString QTextHtmlExporter::toHtml(const QByteArray &encoding, ExportMode mode) fragmentMarkers = (mode == ExportFragment); if (!encoding.isEmpty()) - html += QString::fromLatin1("").arg(QString::fromAscii(encoding)); + html += QString::fromLatin1("").arg(QString::fromLatin1(encoding)); QString title = doc->metaInformation(QTextDocument::DocumentTitle); if (!title.isEmpty()) diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index 12c9044..a1d050c 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -1617,14 +1617,14 @@ void tst_QImageReader::pixelCompareWithBaseline() // least one file succeeded we know that the plugin was built. // The other failures are then real failures. QImage icoImg; - const QString inputFileName(QString::fromAscii("images/%1").arg(fileName)); + const QString inputFileName(QString::fromLatin1("images/%1").arg(fileName)); QFileInfo fi(inputFileName); ++enteredCount; // might fail if the plugin does not exist, which is ok. if (icoImg.load(inputFileName)) { icoImg = icoImg.convertToFormat(QImage::Format_ARGB32_Premultiplied); - const QString baselineFileName(QString::fromAscii("baseline/%1.png").arg(fi.baseName())); + const QString baselineFileName(QString::fromLatin1("baseline/%1.png").arg(fi.baseName())); #if 0 icoImg.save(baselineFileName); #else diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index 213b388..6fb3ab9 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -279,23 +279,23 @@ void tst_QTextDocument::find_data() QTest::newRow("1") << "Hello World" << "World" << int(QTextDocument::FindCaseSensitively) << 0 << 6 << 11; - QTest::newRow("2") << QString::fromAscii("Hello") + QString(QChar::ParagraphSeparator) + QString::fromAscii("World") + QTest::newRow("2") << QString::fromLatin1("Hello") + QString(QChar::ParagraphSeparator) + QString::fromLatin1("World") << "World" << int(QTextDocument::FindCaseSensitively) << 1 << 6 << 11; - QTest::newRow("3") << QString::fromAscii("Hello") + QString(QChar::ParagraphSeparator) + QString::fromAscii("World") + QTest::newRow("3") << QString::fromLatin1("Hello") + QString(QChar::ParagraphSeparator) + QString::fromLatin1("World") << "Hello" << int(QTextDocument::FindCaseSensitively | QTextDocument::FindBackward) << 10 << 0 << 5; - QTest::newRow("4wholewords") << QString::fromAscii("Hello Blah World") + QTest::newRow("4wholewords") << QString::fromLatin1("Hello Blah World") << "Blah" << int(QTextDocument::FindWholeWords) << 0 << 6 << 10; - QTest::newRow("5wholewords") << QString::fromAscii("HelloBlahWorld") + QTest::newRow("5wholewords") << QString::fromLatin1("HelloBlahWorld") << "Blah" << int(QTextDocument::FindWholeWords) << 0 << -1 << -1; - QTest::newRow("6wholewords") << QString::fromAscii("HelloBlahWorld Blah Hah") + QTest::newRow("6wholewords") << QString::fromLatin1("HelloBlahWorld Blah Hah") << "Blah" << int(QTextDocument::FindWholeWords) << 0 << 15 << 19; - QTest::newRow("7wholewords") << QString::fromAscii("HelloBlahWorld Blah Hah") + QTest::newRow("7wholewords") << QString::fromLatin1("HelloBlahWorld Blah Hah") << "Blah" << int(QTextDocument::FindWholeWords | QTextDocument::FindBackward) << 23 << 15 << 19; - QTest::newRow("8wholewords") << QString::fromAscii("Hello: World\n") + QTest::newRow("8wholewords") << QString::fromLatin1("Hello: World\n") << "orld" << int(QTextDocument::FindWholeWords) << 0 << -1 << -1; - QTest::newRow("across-paragraphs") << QString::fromAscii("First Parag\nSecond Parag with a lot more text") + QTest::newRow("across-paragraphs") << QString::fromLatin1("First Parag\nSecond Parag with a lot more text") << "Parag" << int(QTextDocument::FindBackward) << 15 << 6 << 11; @@ -350,7 +350,7 @@ void tst_QTextDocument::findWithRegExp_data() // match ampersands but not & QTest::newRow("2") << "His & hers & theirs" << "&(?!amp;)"<< int(QTextDocument::FindCaseSensitively) << 0 << 15 << 16; //backward search - QTest::newRow("3") << QString::fromAscii("HelloBlahWorld Blah Hah") + QTest::newRow("3") << QString::fromLatin1("HelloBlahWorld Blah Hah") << "h" << int(QTextDocument::FindBackward) << 18 << 8 << 9; } diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 7ca4fc9..d9fc5da 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -884,7 +884,7 @@ void tst_QTextDocumentFragment::hrefAnchor() const char html[] = "blah"; setHtml(QString::fromLatin1(html)); QVERIFY(doc->begin().begin().fragment().charFormat().isAnchor()); - QCOMPARE(doc->begin().begin().fragment().charFormat().anchorHref(), QString::fromAscii("test")); + QCOMPARE(doc->begin().begin().fragment().charFormat().anchorHref(), QString::fromLatin1("test")); QVERIFY(doc->begin().begin().fragment().charFormat().fontUnderline() == true); } @@ -912,13 +912,13 @@ void tst_QTextDocumentFragment::namedAnchorFragments() // the 'a' QVERIFY(it.fragment().isValid()); - QCOMPARE(it.fragment().text(), QString::fromAscii("a")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("a")); QVERIFY(it.fragment().charFormat().isAnchor() == false); // the 'b' of 'blah' as separate fragment with the anchor attribute ++it; QVERIFY(it.fragment().isValid()); - QCOMPARE(it.fragment().text(), QString::fromAscii("b")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("b")); QVERIFY(it.fragment().charFormat().isAnchor()); // the 'lah' of 'blah' as remainder @@ -938,12 +938,12 @@ void tst_QTextDocumentFragment::namedAnchorFragments2() QTextBlock::Iterator it = doc->begin().begin(); QVERIFY(!it.atEnd()); - QCOMPARE(it.fragment().text(), QString::fromAscii("H")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("H")); QVERIFY(it.fragment().charFormat().isAnchor()); ++it; - QCOMPARE(it.fragment().text(), QString::fromAscii("ello")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("ello")); QVERIFY(!it.fragment().charFormat().isAnchor()); } @@ -956,7 +956,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments3() QTextBlock::Iterator it = doc->begin().begin(); QVERIFY(!it.atEnd()); - QCOMPARE(it.fragment().text(), QString::fromAscii("T")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("T")); QVERIFY(it.fragment().charFormat().isAnchor()); QCOMPARE(it.fragment().charFormat().anchorName(), QString("target")); QStringList targets; targets << "target" << "target2"; @@ -964,7 +964,7 @@ void tst_QTextDocumentFragment::namedAnchorFragments3() ++it; - QCOMPARE(it.fragment().text(), QString::fromAscii("ext")); + QCOMPARE(it.fragment().text(), QString::fromLatin1("ext")); QVERIFY(!it.fragment().charFormat().isAnchor()); } @@ -1068,7 +1068,7 @@ void tst_QTextDocumentFragment::mayNotHaveChildren() // make sure the Hey does not end up as tag text for the img tag const char html[] = "Hey"; setHtml(QString::fromLatin1(html)); - QCOMPARE(doc->toPlainText().mid(1), QString::fromAscii("Hey")); + QCOMPARE(doc->toPlainText().mid(1), QString::fromLatin1("Hey")); } void tst_QTextDocumentFragment::inheritAlignment() diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 8920e63..d83f1e9 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -530,7 +530,7 @@ void tst_QTextLayout::defaultWordSeparators_data() QString separators(".,:;-<>[](){}=/+%&^*"); separators += QLatin1String("!?"); for (int i = 0; i < separators.count(); ++i) { - QTest::newRow(QString::number(i).toAscii().data()) + QTest::newRow(QString::number(i).toLatin1().data()) << QString::fromLatin1("abcd") + separators.at(i) + QString::fromLatin1("efgh") << 0 << 4; } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index ba1e73a..68ad38d 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -368,7 +368,7 @@ void tst_QAccessibility::cleanup() const EventList list = QTestAccessibility::events(); if (!list.isEmpty()) { qWarning("%d accessibility event(s) were not handled in testfunction '%s':", list.count(), - QString(QTest::currentTestFunction()).toAscii().constData()); + QString(QTest::currentTestFunction()).toLatin1().constData()); for (int i = 0; i < list.count(); ++i) qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i)->object(), qAccessibleEventString(list.at(i)->type()), list.at(i)->child()); @@ -567,7 +567,7 @@ static QWidget *createWidgets() int i = 0; box->addWidget(new QComboBox(w)); - box->addWidget(new QPushButton(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QPushButton(QString::fromLatin1("widget text %1").arg(i++), w)); box->addWidget(new QHeaderView(Qt::Vertical, w)); box->addWidget(new QTreeView(w)); box->addWidget(new QTreeWidget(w)); @@ -577,25 +577,25 @@ static QWidget *createWidgets() box->addWidget(new QTableWidget(w)); box->addWidget(new QCalendarWidget(w)); box->addWidget(new QDialogButtonBox(w)); - box->addWidget(new QGroupBox(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QGroupBox(QString::fromLatin1("widget text %1").arg(i++), w)); box->addWidget(new QFrame(w)); - box->addWidget(new QLineEdit(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QLineEdit(QString::fromLatin1("widget text %1").arg(i++), w)); box->addWidget(new QProgressBar(w)); box->addWidget(new QTabWidget(w)); - box->addWidget(new QCheckBox(QString::fromAscii("widget text %1").arg(i++), w)); - box->addWidget(new QRadioButton(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QCheckBox(QString::fromLatin1("widget text %1").arg(i++), w)); + box->addWidget(new QRadioButton(QString::fromLatin1("widget text %1").arg(i++), w)); box->addWidget(new QDial(w)); box->addWidget(new QScrollBar(w)); box->addWidget(new QSlider(w)); box->addWidget(new QDateTimeEdit(w)); box->addWidget(new QDoubleSpinBox(w)); box->addWidget(new QSpinBox(w)); - box->addWidget(new QLabel(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QLabel(QString::fromLatin1("widget text %1").arg(i++), w)); box->addWidget(new QLCDNumber(w)); box->addWidget(new QStackedWidget(w)); box->addWidget(new QToolBox(w)); - box->addWidget(new QLabel(QString::fromAscii("widget text %1").arg(i++), w)); - box->addWidget(new QTextEdit(QString::fromAscii("widget text %1").arg(i++), w)); + box->addWidget(new QLabel(QString::fromLatin1("widget text %1").arg(i++), w)); + box->addWidget(new QTextEdit(QString::fromLatin1("widget text %1").arg(i++), w)); /* Not in the list * QAbstractItemView, QGraphicsView, QScrollArea, diff --git a/tests/benchmarks/gui/image/blendbench/main.cpp b/tests/benchmarks/gui/image/blendbench/main.cpp index 82d7d4b..75e8e82 100644 --- a/tests/benchmarks/gui/image/blendbench/main.cpp +++ b/tests/benchmarks/gui/image/blendbench/main.cpp @@ -126,7 +126,7 @@ void BlendBench::blendBench_data() for (int brush = ImageBrush; brush <= SolidBrush; ++brush) for (int mode = first; mode < limit; ++mode) QTest::newRow(QString("brush=%1; mode=%2") - .arg(brushTypes[brush]).arg(compositionModes[mode]).toAscii().data()) + .arg(brushTypes[brush]).arg(compositionModes[mode]).toLatin1().data()) << brush << mode; } diff --git a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp index e5f09b9..9529ff6 100644 --- a/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/benchmarks/gui/painting/qpainter/tst_qpainter.cpp @@ -490,7 +490,7 @@ void tst_QPainter::setupBrushes() // it != m_brushes.constEnd(); ++it) { // for (int w=2; w<1025; w*=2) { // for (int h=2; h<1025; h*=2) { -// QTest::newRow(QString("brush=%1; size=[%2,%3]").arg(it.key()).arg(w).arg(h).toAscii().data()) +// QTest::newRow(QString("brush=%1; size=[%2,%3]").arg(it.key()).arg(w).arg(h).toLatin1().data()) // << *it << QSize(w, h); // } // } -- 2.7.4