From 8bc0dce2c74c28acd36daa73e84f7c9d79760e4a Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Sep 2010 17:25:00 +0200 Subject: QString usage cleanups - tr() already returns a QString, duh - use multi-arg arg() (heh) --- demos/browser/downloadmanager.cpp | 2 +- examples/sql/masterdetail/mainwindow.cpp | 6 ++--- examples/tools/treemodelcompleter/mainwindow.cpp | 2 +- examples/xmlpatterns/filetree/mainwindow.cpp | 2 +- src/3rdparty/phonon/gstreamer/mediaobject.cpp | 6 ++--- tests/auto/qkeysequence/tst_qkeysequence.cpp | 28 +++++++++++----------- tools/activeqt/testcon/changeproperties.cpp | 8 +++---- tools/qdoc3/main.cpp | 2 +- .../shared/qtpropertybrowser/qtpropertymanager.cpp | 24 +++++++++---------- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/demos/browser/downloadmanager.cpp b/demos/browser/downloadmanager.cpp index 876ec1d..ab68209 100644 --- a/demos/browser/downloadmanager.cpp +++ b/demos/browser/downloadmanager.cpp @@ -282,7 +282,7 @@ void DownloadItem::updateInfoLabel() remaining = tr("- %4 %5 remaining") .arg(timeRemaining) .arg(timeRemainingString); - info = QString(tr("%1 of %2 (%3/sec) %4")) + info = tr("%1 of %2 (%3/sec) %4") .arg(dataString(m_bytesReceived)) .arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal)) .arg(dataString((int)speed)) diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp index b8c9df6..2ef8ad0 100644 --- a/examples/sql/masterdetail/mainwindow.cpp +++ b/examples/sql/masterdetail/mainwindow.cpp @@ -189,9 +189,9 @@ void MainWindow::deleteAlbum() QMessageBox::StandardButton button; button = QMessageBox::question(this, tr("Delete Album"), - QString(tr("Are you sure you want to " \ - "delete '%1' by '%2'?")) - .arg(title).arg(artist), + tr("Are you sure you want to " + "delete '%1' by '%2'?") + .arg(title, artist), QMessageBox::Yes | QMessageBox::No); if (button == QMessageBox::Yes) { diff --git a/examples/tools/treemodelcompleter/mainwindow.cpp b/examples/tools/treemodelcompleter/mainwindow.cpp index 0448e9d..cfe003a 100644 --- a/examples/tools/treemodelcompleter/mainwindow.cpp +++ b/examples/tools/treemodelcompleter/mainwindow.cpp @@ -241,6 +241,6 @@ void MainWindow::changeCase(int cs) void MainWindow::updateContentsLabel(const QString& sep) { - contentsLabel->setText(QString(tr("Type path from model above with items at each level separated by a '%1'")).arg(sep)); + contentsLabel->setText(tr("Type path from model above with items at each level separated by a '%1'").arg(sep)); } diff --git a/examples/xmlpatterns/filetree/mainwindow.cpp b/examples/xmlpatterns/filetree/mainwindow.cpp index 5b9b0c3..85348f3 100644 --- a/examples/xmlpatterns/filetree/mainwindow.cpp +++ b/examples/xmlpatterns/filetree/mainwindow.cpp @@ -140,7 +140,7 @@ void MainWindow::loadDirectory(const QString &directory) QXmlFormatter formatter(query, &buffer); query.evaluateTo(&formatter); - treeInfo->setText((QString(tr("Model of %1 output as XML.")).arg(directory))); + treeInfo->setText(tr("Model of %1 output as XML.").arg(directory)); fileTree->setText(QString::fromLatin1(output.constData())); evaluateResult(); //! [6] diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp index 3e0addc..23a60c0 100644 --- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp +++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp @@ -219,9 +219,9 @@ void MediaObject::noMorePadsAvailable () if ( status != GST_INSTALL_PLUGINS_STARTED_OK ) { if( status == GST_INSTALL_PLUGINS_HELPER_MISSING ) - setError(QString(tr("Missing codec helper script assistant.")), Phonon::FatalError ); + setError(tr("Missing codec helper script assistant."), Phonon::FatalError ); else - setError(QString(tr("Plugin codec installation failed for codec: %0")) + setError(tr("Plugin codec installation failed for codec: %0") .arg(m_missingCodecs[0].split("|")[3]), error); } m_missingCodecs.clear(); @@ -232,7 +232,7 @@ void MediaObject::noMorePadsAvailable () m_hasVideo = false; emit hasVideoChanged(false); } - setError(QString(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0")).arg(codecs), error); + setError(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0").arg(codecs), error); m_missingCodecs.clear(); #endif } diff --git a/tests/auto/qkeysequence/tst_qkeysequence.cpp b/tests/auto/qkeysequence/tst_qkeysequence.cpp index 1faae6a..60f022f 100644 --- a/tests/auto/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/qkeysequence/tst_qkeysequence.cpp @@ -532,20 +532,20 @@ void tst_QKeySequence::translated_data() QTest::addColumn("transKey"); QTest::addColumn("compKey"); - QTest::newRow("Shift++") << QString(tr("Shift++")) << QString("Umschalt++"); - QTest::newRow("Ctrl++") << QString(tr("Ctrl++")) << QString("Strg++"); - QTest::newRow("Alt++") << QString(tr("Alt++")) << QString("Alt++"); - QTest::newRow("Meta++") << QString(tr("Meta++")) << QString("Meta++"); - - QTest::newRow("Shift+,, Shift++") << QString(tr("Shift+,, Shift++")) << QString("Umschalt+,, Umschalt++"); - QTest::newRow("Shift+,, Ctrl++") << QString(tr("Shift+,, Ctrl++")) << QString("Umschalt+,, Strg++"); - QTest::newRow("Shift+,, Alt++") << QString(tr("Shift+,, Alt++")) << QString("Umschalt+,, Alt++"); - QTest::newRow("Shift+,, Meta++") << QString(tr("Shift+,, Meta++")) << QString("Umschalt+,, Meta++"); - - QTest::newRow("Ctrl+,, Shift++") << QString(tr("Ctrl+,, Shift++")) << QString("Strg+,, Umschalt++"); - QTest::newRow("Ctrl+,, Ctrl++") << QString(tr("Ctrl+,, Ctrl++")) << QString("Strg+,, Strg++"); - QTest::newRow("Ctrl+,, Alt++") << QString(tr("Ctrl+,, Alt++")) << QString("Strg+,, Alt++"); - QTest::newRow("Ctrl+,, Meta++") << QString(tr("Ctrl+,, Meta++")) << QString("Strg+,, Meta++"); + QTest::newRow("Shift++") << tr("Shift++") << QString("Umschalt++"); + QTest::newRow("Ctrl++") << tr("Ctrl++") << QString("Strg++"); + QTest::newRow("Alt++") << tr("Alt++") << QString("Alt++"); + QTest::newRow("Meta++") << tr("Meta++") << QString("Meta++"); + + QTest::newRow("Shift+,, Shift++") << tr("Shift+,, Shift++") << QString("Umschalt+,, Umschalt++"); + QTest::newRow("Shift+,, Ctrl++") << tr("Shift+,, Ctrl++") << QString("Umschalt+,, Strg++"); + QTest::newRow("Shift+,, Alt++") << tr("Shift+,, Alt++") << QString("Umschalt+,, Alt++"); + QTest::newRow("Shift+,, Meta++") << tr("Shift+,, Meta++") << QString("Umschalt+,, Meta++"); + + QTest::newRow("Ctrl+,, Shift++") << tr("Ctrl+,, Shift++") << QString("Strg+,, Umschalt++"); + QTest::newRow("Ctrl+,, Ctrl++") << tr("Ctrl+,, Ctrl++") << QString("Strg+,, Strg++"); + QTest::newRow("Ctrl+,, Alt++") << tr("Ctrl+,, Alt++") << QString("Strg+,, Alt++"); + QTest::newRow("Ctrl+,, Meta++") << tr("Ctrl+,, Meta++") << QString("Strg+,, Meta++"); qApp->removeTranslator(ourTranslator); qApp->removeTranslator(qtTranslator); diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp index e2ad601..00a2cab 100644 --- a/tools/activeqt/testcon/changeproperties.cpp +++ b/tools/activeqt/testcon/changeproperties.cpp @@ -111,10 +111,10 @@ void ChangeProperties::on_buttonSet_clicked() value = qVariantFromValue(col); } else { QMessageBox::warning(this, tr("Can't parse input"), - QString(tr("Failed to create a color from %1\n" + tr("Failed to create a color from %1\n" "The string has to be a valid color name (e.g. 'red')\n" "or a RGB triple of format '#rrggbb'." - ).arg(editValue->text()))); + ).arg(editValue->text())); } } break; @@ -125,10 +125,10 @@ void ChangeProperties::on_buttonSet_clicked() value = qVariantFromValue(fnt); } else { QMessageBox::warning(this, tr("Can't parse input"), - (tr("Failed to create a font from %1\n" + tr("Failed to create a font from %1\n" "The string has to have a format family, or\n" "family,pointsize,stylehint,weight,italic,underline,strikeout,fixedpitch,rawmode." - ).arg(editValue->text()))); + ).arg(editValue->text())); } } break; diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index fa7efee..2bfe38e 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -148,7 +148,7 @@ static void printHelp() */ static void printVersion() { - QString s = QString(tr("qdoc version ")) + QString(QT_VERSION_STR); + QString s = tr("qdoc version %1").arg(QT_VERSION_STR); Location::information(s); } diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp index a0bef0a..8c7835c 100644 --- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp +++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp @@ -2643,8 +2643,8 @@ QString QtPointPropertyManager::valueText(const QtProperty *property) const if (it == d_ptr->m_values.constEnd()) return QString(); const QPoint v = it.value(); - return QString(tr("(%1, %2)").arg(QString::number(v.x())) - .arg(QString::number(v.y()))); + return tr("(%1, %2)").arg(QString::number(v.x())) + .arg(QString::number(v.y())); } /*! @@ -2884,8 +2884,8 @@ QString QtPointFPropertyManager::valueText(const QtProperty *property) const return QString(); const QPointF v = it.value().val; const int dec = it.value().decimals; - return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec))); + return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) + .arg(QString::number(v.y(), 'f', dec)); } /*! @@ -3204,8 +3204,8 @@ QString QtSizePropertyManager::valueText(const QtProperty *property) const if (it == d_ptr->m_values.constEnd()) return QString(); const QSize v = it.value().val; - return QString(tr("%1 x %2").arg(QString::number(v.width())) - .arg(QString::number(v.height()))); + return tr("%1 x %2").arg(QString::number(v.width())) + .arg(QString::number(v.height())); } /*! @@ -3569,8 +3569,8 @@ QString QtSizeFPropertyManager::valueText(const QtProperty *property) const return QString(); const QSizeF v = it.value().val; const int dec = it.value().decimals; - return QString(tr("%1 x %2").arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec))); + return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec)) + .arg(QString::number(v.height(), 'f', dec)); } /*! @@ -3962,10 +3962,10 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const if (it == d_ptr->m_values.constEnd()) return QString(); const QRect v = it.value().val; - return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x())) - .arg(QString::number(v.y())) - .arg(QString::number(v.width())) - .arg(QString::number(v.height()))); + return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x())) + .arg(QString::number(v.y())) + .arg(QString::number(v.width())) + .arg(QString::number(v.height())); } /*! -- cgit v0.12