summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/itemmodels
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-09-30 14:09:04 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-11-03 14:59:24 +0100
commit1c6bf3e09ea9722717caedcfcceaaf3d607615cf (patch)
treecad1814e104667a84ba7b5f403bbda015413e058 /tests/auto/gui/itemmodels
parent43cda7807b98552e9292ac09a1f6612d432a8b13 (diff)
Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests/auto/gui/itemmodels')
-rw-r--r--tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp74
-rw-r--r--tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp6
-rw-r--r--tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp96
3 files changed, 88 insertions, 88 deletions
diff --git a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
index b42136ee9d..3802f8afc6 100644
--- a/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -173,7 +173,7 @@ void tst_QFileSystemModel::rootPath()
QSignalSpy rootChanged(model.data(), &QFileSystemModel::rootPathChanged);
QModelIndex root = model->setRootPath(model->rootPath());
root = model->setRootPath("this directory shouldn't exist");
- QCOMPARE(rootChanged.count(), 0);
+ QCOMPARE(rootChanged.size(), 0);
QString oldRootPath = model->rootPath();
const QStringList documentPaths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation);
@@ -190,26 +190,26 @@ void tst_QFileSystemModel::rootPath()
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), QString(documentPath));
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? 0 : 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? 0 : 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
model->setRootPath(QDir::rootPath());
- int oldCount = rootChanged.count();
+ int oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), documentPath);
- QCOMPARE(rootChanged.count(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldRootPath == model->rootPath() ? oldCount : oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), documentPath);
QDir newdir = documentPath;
if (newdir.cdUp()) {
- oldCount = rootChanged.count();
+ oldCount = rootChanged.size();
oldRootPath = model->rootPath();
root = model->setRootPath(documentPath + QLatin1String("/.."));
QTRY_VERIFY(model->rowCount(root) >= 0);
QCOMPARE(model->rootPath(), newdir.path());
- QCOMPARE(rootChanged.count(), oldCount + 1);
+ QCOMPARE(rootChanged.size(), oldCount + 1);
QCOMPARE(model->rootDirectory().absolutePath(), newdir.path());
}
@@ -403,8 +403,8 @@ void tst_QFileSystemModel::rowCount()
QModelIndex root = prepareTestModelRoot(model.data(), flatDirTestPath, &spy2, &spy3);
QVERIFY(root.isValid());
- QVERIFY(spy2 && spy2->count() > 0);
- QVERIFY(spy3 && spy3->count() > 0);
+ QVERIFY(spy2 && spy2->size() > 0);
+ QVERIFY(spy3 && spy3->size() > 0);
}
void tst_QFileSystemModel::rowsInserted_data()
@@ -446,7 +446,7 @@ void tst_QFileSystemModel::rowsInserted()
QVERIFY(createFiles(model.data(), tmp, files, 5));
QTRY_COMPARE(model->rowCount(root), oldCount + count);
int totalRowsInserted = 0;
- for (int i = 0; i < spy0.count(); ++i) {
+ for (int i = 0; i < spy0.size(); ++i) {
int start = spy0[i].value(1).toInt();
int end = spy0[i].value(2).toInt();
totalRowsInserted += end - start + 1;
@@ -455,24 +455,24 @@ void tst_QFileSystemModel::rowsInserted()
const QString expected = ascending == Qt::AscendingOrder ? QStringLiteral("j") : QStringLiteral("b");
QTRY_COMPARE(lastEntry(root), expected);
- if (spy0.count() > 0) {
+ if (spy0.size() > 0) {
if (count == 0)
- QCOMPARE(spy0.count(), 0);
+ QCOMPARE(spy0.size(), 0);
else
- QVERIFY(spy0.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
}
- if (count == 0) QCOMPARE(spy1.count(), 0); else QVERIFY(spy1.count() >= 1);
+ if (count == 0) QCOMPARE(spy1.size(), 0); else QVERIFY(spy1.size() >= 1);
QVERIFY(createFiles(model.data(), tmp, QStringList(".hidden_file"), 5 + count));
if (count != 0)
- QTRY_VERIFY(spy0.count() >= 1);
+ QTRY_VERIFY(spy0.size() >= 1);
else
- QTRY_COMPARE(spy0.count(), 0);
+ QTRY_COMPARE(spy0.size(), 0);
if (count != 0)
- QTRY_VERIFY(spy1.count() >= 1);
+ QTRY_VERIFY(spy1.size() >= 1);
else
- QTRY_COMPARE(spy1.count(), 0);
+ QTRY_COMPARE(spy1.size(), 0);
}
void tst_QFileSystemModel::rowsRemoved_data()
@@ -503,14 +503,14 @@ void tst_QFileSystemModel::rowsRemoved()
}
for (int i = 0 ; i < 10; ++i) {
if (count != 0) {
- if (i == 10 || spy0.count() != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ if (i == 10 || spy0.size() != 0) {
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
}
} else {
- if (i == 10 || spy0.count() == 0) {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ if (i == 10 || spy0.size() == 0) {
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
QStringList lst;
@@ -529,11 +529,11 @@ void tst_QFileSystemModel::rowsRemoved()
QVERIFY(QFile::remove(tmp + QLatin1String("/.c")));
if (count != 0) {
- QVERIFY(spy0.count() >= 1);
- QVERIFY(spy1.count() >= 1);
+ QVERIFY(spy0.size() >= 1);
+ QVERIFY(spy1.size() >= 1);
} else {
- QCOMPARE(spy0.count(), 0);
- QCOMPARE(spy1.count(), 0);
+ QCOMPARE(spy0.size(), 0);
+ QCOMPARE(spy1.size(), 0);
}
}
@@ -565,7 +565,7 @@ void tst_QFileSystemModel::dataChanged()
QTest::qWait(WAITTIME);
- if (count != 0) QVERIFY(spy.count() >= 1); else QCOMPARE(spy.count(), 0);
+ if (count != 0) QVERIFY(spy.size() >= 1); else QCOMPARE(spy.size(), 0);
}
void tst_QFileSystemModel::filters_data()
@@ -620,7 +620,7 @@ void tst_QFileSystemModel::filters()
QFETCH(QStringList, nameFilters);
QFETCH(int, rowCount);
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
model->setNameFilters(nameFilters);
model->setNameFilterDisables(false);
model->setFilter(dirFilters);
@@ -632,12 +632,12 @@ void tst_QFileSystemModel::filters()
QDir xFactor(tmp);
QStringList dirEntries;
- if (nameFilters.count() > 0)
+ if (nameFilters.size() > 0)
dirEntries = xFactor.entryList(nameFilters, dirFilters);
else
dirEntries = xFactor.entryList(dirFilters);
- QCOMPARE(dirEntries.count(), rowCount);
+ QCOMPARE(dirEntries.size(), rowCount);
QStringList modelEntries;
@@ -649,7 +649,7 @@ void tst_QFileSystemModel::filters()
QCOMPARE(dirEntries, modelEntries);
#ifdef Q_OS_LINUX
- if (files.count() >= 3 && rowCount >= 3 && rowCount != 5) {
+ if (files.size() >= 3 && rowCount >= 3 && rowCount != 5) {
QString fileName1 = (tmp + '/' + files.at(0));
QString fileName2 = (tmp + '/' + files.at(1));
QString fileName3 = (tmp + '/' + files.at(2));
@@ -748,7 +748,7 @@ void tst_QFileSystemModel::setData()
tmpIdx = model->index(tmp);
model->fetchMore(tmpIdx);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
QModelIndex idx = model->index(tmp + '/' + oldFileName);
QCOMPARE(idx.isValid(), true);
@@ -758,7 +758,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(model->setData(idx, newFileName), success);
model->setReadOnly(true);
if (success) {
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
@@ -767,7 +767,7 @@ void tst_QFileSystemModel::setData()
QCOMPARE(arguments.at(2).toString(), newFileName);
QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
}
- QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.size());
// cleanup
if (!subdirName.isEmpty())
QVERIFY(QDir(tmp).removeRecursively());
@@ -997,7 +997,7 @@ void tst_QFileSystemModel::caseSensitivity()
QStringList paths;
QModelIndexList indexes;
QCOMPARE(model->rowCount(root), 0);
- for (int i = 0; i < files.count(); ++i) {
+ for (int i = 0; i < files.size(); ++i) {
const QString path = tmp + '/' + files.at(i);
const QModelIndex index = model->index(path);
QVERIFY(index.isValid());
@@ -1007,7 +1007,7 @@ void tst_QFileSystemModel::caseSensitivity()
if (!QFileSystemEngine::isCaseSensitive()) {
// QTBUG-31103, QTBUG-64147: Verify that files can be accessed by paths with fLipPeD case.
- for (int i = 0; i < paths.count(); ++i) {
+ for (int i = 0; i < paths.size(); ++i) {
const QModelIndex flippedCaseIndex = model->index(flipCase(paths.at(i)));
QCOMPARE(indexes.at(i), flippedCaseIndex);
}
diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
index 616488a3e8..6f42c45821 100644
--- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp
@@ -984,8 +984,8 @@ void tst_QStandardItem::sortChildren()
QCOMPARE(two->child(1)->text(), QLatin1String("e"));
QCOMPARE(two->child(2)->text(), QLatin1String("f"));
- QCOMPARE(layoutAboutToBeChangedSpy.count(), (x == 0) ? 0 : 3);
- QCOMPARE(layoutChangedSpy.count(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), (x == 0) ? 0 : 3);
+ QCOMPARE(layoutChangedSpy.size(), (x == 0) ? 0 : 3);
if (x == 0)
delete item;
@@ -1027,7 +1027,7 @@ void tst_QStandardItem::subclassing()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
item->emitDataChanged();
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
QCOMPARE(itemChangedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QStandardItem*>(itemChangedSpy.at(0).at(0)), item);
diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
index c9f503c1f8..07fc074577 100644
--- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
+++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp
@@ -448,16 +448,16 @@ void tst_QStandardItemModel::setHeaderData()
for (int i = 0; i < count; ++i) {
QString customString = QString("custom") + QString::number(i);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 1);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 1);
+ QCOMPARE(dataChangedSpy.size(), 0);
QVariantList args = headerDataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<Qt::Orientation>(args.at(0)), orient);
QCOMPARE(args.at(1).toInt(), i);
QCOMPARE(args.at(2).toInt(), i);
QCOMPARE(m_model->headerData(i, orient).toString(), customString);
QCOMPARE(m_model->setHeaderData(i, orient, customString), true);
- QCOMPARE(headerDataChangedSpy.count(), 0);
- QCOMPARE(dataChangedSpy.count(), 0);
+ QCOMPARE(headerDataChangedSpy.size(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
}
//check read from invalid sections
@@ -761,9 +761,9 @@ void tst_QStandardItemModel::clear()
model.clear();
- QCOMPARE(modelResetSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 0);
- QCOMPARE(rowsRemovedSpy.count(), 0);
+ QCOMPARE(modelResetSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 0);
+ QCOMPARE(rowsRemovedSpy.size(), 0);
QCOMPARE(model.index(0, 0), QModelIndex());
QCOMPARE(model.columnCount(), 0);
QCOMPARE(model.rowCount(), 0);
@@ -805,8 +805,8 @@ void tst_QStandardItemModel::sort()
QFETCH(QStringList, expected);
// prepare model
QStandardItemModel model;
- QVERIFY(model.insertRows(0, initial.count(), QModelIndex()));
- QCOMPARE(model.rowCount(QModelIndex()), initial.count());
+ QVERIFY(model.insertRows(0, initial.size(), QModelIndex()));
+ QCOMPARE(model.rowCount(QModelIndex()), initial.size());
model.insertColumns(0, 1, QModelIndex());
QCOMPARE(model.columnCount(QModelIndex()), 1);
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -822,8 +822,8 @@ void tst_QStandardItemModel::sort()
// sort
model.sort(0, sortOrder);
- QCOMPARE(layoutAboutToBeChangedSpy.count(), 1);
- QCOMPARE(layoutChangedSpy.count(), 1);
+ QCOMPARE(layoutAboutToBeChangedSpy.size(), 1);
+ QCOMPARE(layoutChangedSpy.size(), 1);
// make sure the model is sorted
for (int row = 0; row < model.rowCount(QModelIndex()); ++row) {
@@ -867,7 +867,7 @@ void tst_QStandardItemModel::sortRole()
QFETCH(QVariantList, expectedData);
QStandardItemModel model;
- for (int i = 0; i < initialText.count(); ++i) {
+ for (int i = 0; i < initialText.size(); ++i) {
QStandardItem *item = new QStandardItem;
item->setText(initialText.at(i));
item->setData(initialData.at(i), Qt::UserRole);
@@ -875,7 +875,7 @@ void tst_QStandardItemModel::sortRole()
}
model.setSortRole(sortRole);
model.sort(0, sortOrder);
- for (int i = 0; i < expectedText.count(); ++i) {
+ for (int i = 0; i < expectedText.size(); ++i) {
QStandardItem *item = model.item(i);
QCOMPARE(item->text(), expectedText.at(i));
QCOMPARE(item->data(Qt::UserRole), expectedData.at(i));
@@ -1061,9 +1061,9 @@ void tst_QStandardItemModel::getSetItemData()
QSignalSpy modelDataChangedSpy(
&model, &QStandardItemModel::dataChanged);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1);
+ QCOMPARE(modelDataChangedSpy.size(), 1);
QVERIFY(model.setItemData(idx, roles));
- QCOMPARE(modelDataChangedSpy.count(), 1); //it was already changed once
+ QCOMPARE(modelDataChangedSpy.size(), 1); //it was already changed once
QCOMPARE(model.itemData(idx), roles);
}
@@ -1127,12 +1127,12 @@ void tst_QStandardItemModel::setHeaderLabels()
model.setHorizontalHeaderLabels(labels);
else
model.setVerticalHeaderLabels(labels);
- for (int i = 0; i < expectedLabels.count(); ++i)
+ for (int i = 0; i < expectedLabels.size(); ++i)
QCOMPARE(model.headerData(i, orientation).toString(), expectedLabels.at(i));
- QCOMPARE(columnsInsertedSpy.count(),
- (orientation == Qt::Vertical) ? 0 : labels.count() > columns);
- QCOMPARE(rowsInsertedSpy.count(),
- (orientation == Qt::Horizontal) ? 0 : labels.count() > rows);
+ QCOMPARE(columnsInsertedSpy.size(),
+ (orientation == Qt::Vertical) ? 0 : labels.size() > columns);
+ QCOMPARE(rowsInsertedSpy.size(),
+ (orientation == Qt::Horizontal) ? 0 : labels.size() > rows);
}
void tst_QStandardItemModel::itemDataChanged()
@@ -1143,8 +1143,8 @@ void tst_QStandardItemModel::itemDataChanged()
QSignalSpy itemChangedSpy(&model, &QStandardItemModel::itemChanged);
model.setItem(0, &item);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
QModelIndex index = model.indexFromItem(&item);
QList<QVariant> args;
args = dataChangedSpy.takeFirst();
@@ -1154,8 +1154,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(QLatin1String("foo"), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1163,12 +1163,12 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setData(item.data(Qt::DisplayRole), Qt::DisplayRole);
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
item.setFlags(Qt::ItemIsEnabled);
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(itemChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(itemChangedSpy.size(), 1);
args = dataChangedSpy.takeFirst();
QCOMPARE(qvariant_cast<QModelIndex>(args.at(0)), index);
QCOMPARE(qvariant_cast<QModelIndex>(args.at(1)), index);
@@ -1176,8 +1176,8 @@ void tst_QStandardItemModel::itemDataChanged()
QCOMPARE(qvariant_cast<QStandardItem*>(args.at(0)), &item);
item.setFlags(item.flags());
- QCOMPARE(dataChangedSpy.count(), 0);
- QCOMPARE(itemChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 0);
+ QCOMPARE(itemChangedSpy.size(), 0);
}
void tst_QStandardItemModel::takeHeaderItem()
@@ -1305,7 +1305,7 @@ void tst_QStandardItemModel::setNullChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
item->setChild(0, nullptr);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::deleteChild()
@@ -1317,7 +1317,7 @@ void tst_QStandardItemModel::deleteChild()
QSignalSpy spy(&model, &QAbstractItemModel::dataChanged);
delete item->child(0);
QCOMPARE(item->child(0), nullptr);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QStandardItemModel::rootItemFlags()
@@ -1558,8 +1558,8 @@ void tst_QStandardItemModel::removeRowsAndColumns()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1580,15 +1580,15 @@ void tst_QStandardItemModel::removeRowsAndColumns()
VERIFY_MODEL
QList<QStandardItem *> row_taken = model.takeRow(6);
- QCOMPARE(row_taken.size(), col_list.count());
- for (int c = 0; c < col_list.count(); c++)
+ QCOMPARE(row_taken.size(), col_list.size());
+ for (int c = 0; c < col_list.size(); c++)
QCOMPARE(row_taken[c]->text() , row_list[6] + QLatin1Char('x') + col_list[c]);
row_list.remove(6);
VERIFY_MODEL
QList<QStandardItem *> col_taken = model.takeColumn(10);
- QCOMPARE(col_taken.size(), row_list.count());
- for (int r = 0; r < row_list.count(); r++)
+ QCOMPARE(col_taken.size(), row_list.size());
+ for (int r = 0; r < row_list.size(); r++)
QCOMPARE(col_taken[r]->text() , row_list[r] + QLatin1Char('x') + col_list[10]);
col_list.remove(10);
VERIFY_MODEL
@@ -1605,8 +1605,8 @@ void tst_QStandardItemModel::itemRoleNames()
QStringList row_list = QString("1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20").split(',');
QStringList col_list = row_list;
QStandardItemModel model;
- for (int c = 0; c < col_list.count(); c++)
- for (int r = 0; r < row_list.count(); r++)
+ for (int c = 0; c < col_list.size(); c++)
+ for (int r = 0; r < row_list.size(); r++)
model.setItem(r, c, new QStandardItem(row_list[r] + QLatin1Char('x') + col_list[c]));
VERIFY_MODEL
@@ -1646,7 +1646,7 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
QModelIndex index = item->index();
QCOMPARE(model.itemData(index).size(), 3);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QMap<int, QVariant> roles;
@@ -1654,21 +1654,21 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 2, 2);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.insert(Qt::UserRole + 1, 1);
roles.insert(Qt::UserRole + 2, 2);
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
roles.clear();
roles.insert(Qt::UserRole + 1, 10);
roles.insert(Qt::UserRole + 3, 12);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QMap<int, QVariant> itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 4);
@@ -1680,13 +1680,13 @@ void tst_QStandardItemModel::taskQTBUG_45114_setItemData()
roles.insert(Qt::UserRole + 3, 1);
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
roles.clear();
roles.insert(Qt::UserRole + 3, QVariant());
model.setItemData(index, roles);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
itemRoles = model.itemData(index);
QCOMPARE(itemRoles.size(), 3);
@@ -1739,13 +1739,13 @@ void tst_QStandardItemModel::signalsOnTakeItem() // QTBUG-89145
QSignalSpy dataChangedSpy(&m, &QAbstractItemModel::dataChanged);
QStandardItem *const takenItem = m.takeItem(1, 0);
for (auto &&spy : removeSpies) {
- QCOMPARE(spy->count(), 1);
+ QCOMPARE(spy->size(), 1);
const auto spyArgs = spy->takeFirst();
QCOMPARE(spyArgs.at(0).value<QModelIndex>(), parentIndex);
QCOMPARE(spyArgs.at(1).toInt(), 0);
QCOMPARE(spyArgs.at(2).toInt(), 1);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
const auto dataChangedSpyArgs = dataChangedSpy.takeFirst();
QCOMPARE(dataChangedSpyArgs.at(0).value<QModelIndex>(), m.index(1, 0));
QCOMPARE(dataChangedSpyArgs.at(1).value<QModelIndex>(), m.index(1, 0));