diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-10-16 09:38:51 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-10-19 12:39:16 +0000 |
commit | 52d5b272394f5d1fd84d5c44af78e3b87d264766 (patch) | |
tree | 2f03119fab864c4ce41e83185f3c317e647484c4 /tests/auto/widgets/itemviews/qtreewidget | |
parent | 240d768ca6ef41bf661a1fb8e1bde408e25ba553 (diff) |
tests/auto/widgets: Remove some placeholder formatting.
Use QByteArray/QString addition instead in loops and for
test row names.
Change-Id: Ia067cd966bf13506e6ca19925eae3158da027b83
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qtreewidget')
-rw-r--r-- | tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index afc61025ba..1acdc103bd 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -320,7 +320,7 @@ void tst_QTreeWidget::addTopLevelItem() for (int i = 0; i < 100; i += count) { tops.clear(); for (int j = 0; j < count; ++j) - tops << new TreeItem(QStringList() << QString("%0").arg(j)); + tops << new TreeItem(QStringList(QString::number(j))); tree.addTopLevelItems(tops); QCOMPARE(tree.topLevelItemCount(), count + i); for (int j = 0; j < count; ++j) @@ -511,10 +511,10 @@ void tst_QTreeWidget::takeItem() for (int i=0; i<3; ++i) { QTreeWidgetItem *top = new QTreeWidgetItem(testWidget); - top->setText(0, QString("top%1").arg(i)); + top->setText(0, QStringLiteral("top") + QString::number(i)); for (int j=0; j<3; ++j) { QTreeWidgetItem *child = new QTreeWidgetItem(top); - child->setText(0, QString("child%1").arg(j)); + child->setText(0, QStringLiteral("child") + QString::number(j)); } } @@ -528,7 +528,7 @@ void tst_QTreeWidget::takeItem() QCOMPARE(item, (QTreeWidgetItem *)0); QCOMPARE(count, testWidget->topLevelItemCount()); } else { - QCOMPARE(item->text(0), QString("top%1").arg(index)); + QCOMPARE(item->text(0), QStringLiteral("top") + QString::number(index)); QCOMPARE(count-1, testWidget->topLevelItemCount()); delete item; } @@ -539,7 +539,7 @@ void tst_QTreeWidget::takeItem() QCOMPARE(item, (QTreeWidgetItem *)0); QCOMPARE(count, testWidget->topLevelItem(0)->childCount()); } else { - QCOMPARE(item->text(0), QString("child%1").arg(index)); + QCOMPARE(item->text(0), QStringLiteral("child") + QString::number(index)); QCOMPARE(count-1, testWidget->topLevelItem(0)->childCount()); delete item; } @@ -794,10 +794,11 @@ void tst_QTreeWidget::selectedItems() // create items for (int t=0; t<topLevel; ++t) { QTreeWidgetItem *top = new QTreeWidgetItem(testWidget); - top->setText(0, QString("top%1").arg(t)); + const QString topS = QLatin1String("top") + QString::number(t); + top->setText(0, topS); for (int c=0; c<children; ++c) { QTreeWidgetItem *child = new QTreeWidgetItem(top); - child->setText(0, QString("top%1child%2").arg(t).arg(c)); + child->setText(0, topS + QLatin1String("child") + QString::number(c)); } } @@ -1442,11 +1443,10 @@ static void fillTreeWidget(QTreeWidgetItem *parent, int rows) { const int columns = parent->treeWidget()->columnCount(); for (int r = 0; r < rows; ++r) { + const QString prefix = QLatin1String("[r:") + QString::number(r) + QLatin1String(",c:"); QTreeWidgetItem *w = new QTreeWidgetItem(parent); - for ( int c = 0; c < columns; ++c ) { - QString s = QString("[r:%1,c:%2]").arg(r).arg(c); - w->setText(c, s); - } + for (int c = 0; c < columns; ++c) + w->setText(c, prefix + QString::number(c) + QLatin1Char(']')); fillTreeWidget(w, rows - r - 1); } } @@ -1455,10 +1455,9 @@ static void fillTreeWidget(QTreeWidget *tree, int rows) { for (int r = 0; r < rows; ++r) { QTreeWidgetItem *w = new QTreeWidgetItem(); - for ( int c = 0; c < tree->columnCount(); ++c ) { - QString s = QString("[r:%1,c:%2]").arg(r).arg(c); - w->setText(c, s); - } + const QString prefix = QLatin1String("[r:") + QString::number(r) + QLatin1String(",c:"); + for (int c = 0; c < tree->columnCount(); ++c) + w->setText(c, prefix + QString::number(c) + QLatin1Char(']')); tree->insertTopLevelItem(r, w); fillTreeWidget(w, rows - r - 1); } @@ -1555,7 +1554,7 @@ void tst_QTreeWidget::keyboardNavigation() } QTreeWidgetItem *current = testWidget->currentItem(); - QCOMPARE(current->text(0), QString("[r:%1,c:0]").arg(row)); + QCOMPARE(current->text(0), QLatin1String("[r:") + QString::number(row) + QLatin1String(",c:0]")); if (current->parent()) QCOMPARE(current->parent()->indexOfChild(current), row); else @@ -1696,7 +1695,7 @@ void tst_QTreeWidget::addChild() for (int i = 0; i < 100; i += count) { QList<QTreeWidgetItem*> list; for (int j = 0; j < count; ++j) - list << new QTreeWidgetItem(QStringList() << QString("%0").arg(j)); + list << new QTreeWidgetItem(QStringList(QString::number(j))); item->addChildren(list); QCOMPARE(item->childCount(), count + i); for (int j = 0; j < count; ++j) { @@ -1743,7 +1742,8 @@ void tst_QTreeWidget::setData() for (int i = 1; i <= 2; ++i) { for (int j = 0; j < 5; ++j) { QVariantList args; - QString text = QString("text %0").arg(i); + const QString iS = QString::number(i); + const QString text = QLatin1String("text ") + iS; item->setText(j, text); QCOMPARE(item->text(j), text); QCOMPARE(itemChangedSpy.count(), 1); @@ -1765,7 +1765,7 @@ void tst_QTreeWidget::setData() item->setIcon(j, icon); QCOMPARE(itemChangedSpy.count(), 0); - QString toolTip = QString("toolTip %0").arg(i); + const QString toolTip = QLatin1String("toolTip ") + iS; item->setToolTip(j, toolTip); QCOMPARE(item->toolTip(j), toolTip); QCOMPARE(itemChangedSpy.count(), 1); @@ -1775,7 +1775,7 @@ void tst_QTreeWidget::setData() item->setToolTip(j, toolTip); QCOMPARE(itemChangedSpy.count(), 0); - QString statusTip = QString("statusTip %0").arg(i); + const QString statusTip = QLatin1String("statusTip ") + iS; item->setStatusTip(j, statusTip); QCOMPARE(item->statusTip(j), statusTip); QCOMPARE(itemChangedSpy.count(), 1); @@ -1785,7 +1785,7 @@ void tst_QTreeWidget::setData() item->setStatusTip(j, statusTip); QCOMPARE(itemChangedSpy.count(), 0); - QString whatsThis = QString("whatsThis %0").arg(i); + const QString whatsThis = QLatin1String("whatsThis ") + iS; item->setWhatsThis(j, whatsThis); QCOMPARE(item->whatsThis(j), whatsThis); QCOMPARE(itemChangedSpy.count(), 1); @@ -2147,8 +2147,8 @@ void tst_QTreeWidget::insertItemsWithSorting_data() QStringList ascendingItems; QStringList reverseItems; for (int i = 'a'; i <= 'z'; ++i) { - ascendingItems << QString("%0").arg(QLatin1Char(i)); - reverseItems << QString("%0").arg(QLatin1Char('z' - i + 'a')); + ascendingItems << QString(1, QLatin1Char(i)); + reverseItems << QString(1, QLatin1Char('z' - i + 'a')); ascendingRows << i - 'a'; reverseRows << 'z' - i + 'a'; } @@ -2671,9 +2671,9 @@ void tst_QTreeWidget::expandAndCallapse() QTreeWidgetItem *top = new QTreeWidgetItem(&tw, QStringList() << "top"); QTreeWidgetItem *p; for (int i = 0; i < 10; ++i) { - p = new QTreeWidgetItem(top, QStringList() << QString("%1").arg(i)); + p = new QTreeWidgetItem(top, QStringList(QString::number(i))); for (int j = 0; j < 10; ++j) - new QTreeWidgetItem(p, QStringList() << QString("%1").arg(j)); + new QTreeWidgetItem(p, QStringList(QString::number(j))); } QSignalSpy spy0(&tw, SIGNAL(itemExpanded(QTreeWidgetItem*))); QSignalSpy spy1(&tw, SIGNAL(itemCollapsed(QTreeWidgetItem*))); @@ -3133,7 +3133,7 @@ void tst_QTreeWidget::selectionOrder() testWidget->setColumnCount(1); QList<QTreeWidgetItem *> items; for (int i = 0; i < 10; ++i) - items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("item: %1").arg(i)))); + items.append(new QTreeWidgetItem((QTreeWidget*)0, QStringList(QLatin1String("item: ") + QString::number(i)))); testWidget->insertTopLevelItems(0, items); QModelIndex idx = testWidget->indexFromItem(items[0]); |