From c338447261878111df7198fbd96051926464e865 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Oct 2022 08:17:22 +0200 Subject: Port from container::count() and length() to size() This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName()))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: I95f6410e57a6a92b1cf91bbedfbe3d517cab6b44 Reviewed-by: Qt CI Bot Reviewed-by: Kai Koehne Reviewed-by: Friedemann Kleint --- src/qdbus/qdbusviewer/qdbusmodel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/qdbus/qdbusviewer/qdbusmodel.cpp') diff --git a/src/qdbus/qdbusviewer/qdbusmodel.cpp b/src/qdbus/qdbusviewer/qdbusmodel.cpp index 0da1dea44..9bb0dd97b 100644 --- a/src/qdbus/qdbusviewer/qdbusmodel.cpp +++ b/src/qdbus/qdbusviewer/qdbusmodel.cpp @@ -32,7 +32,7 @@ struct QDBusItem s.prepend(item->name); item = item->parent; } - if (s.length() > 1) + if (s.size() > 1) s.chop(1); // remove tailing slash return s; } @@ -160,7 +160,7 @@ QModelIndex QDBusModel::index(int row, int column, const QModelIndex &parent) co if (!item) item = root; - if (column != 0 || row < 0 || row >= item->children.count()) + if (column != 0 || row < 0 || row >= item->children.size()) return QModelIndex(); return createIndex(row, 0, item->children.at(row)); @@ -183,7 +183,7 @@ int QDBusModel::rowCount(const QModelIndex &parent) const if (!item->isPrefetched) const_cast(this)->addPath(item); - return item->children.count(); + return item->children.size(); } int QDBusModel::columnCount(const QModelIndex &) const @@ -229,7 +229,7 @@ void QDBusModel::refresh(const QModelIndex &aIndex) item = root; if (!item->children.isEmpty()) { - beginRemoveRows(index, 0, item->children.count() - 1); + beginRemoveRows(index, 0, item->children.size() - 1); qDeleteAll(item->children); item->children.clear(); endRemoveRows(); @@ -237,7 +237,7 @@ void QDBusModel::refresh(const QModelIndex &aIndex) addPath(item); if (!item->children.isEmpty()) { - beginInsertRows(index, 0, item->children.count() - 1); + beginInsertRows(index, 0, item->children.size() - 1); endInsertRows(); } } @@ -291,7 +291,7 @@ QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath) childIdx = -1; // do a linear search over all the children - for (int i = 0; i < item->children.count(); ++i) { + for (int i = 0; i < item->children.size(); ++i) { QDBusItem *child = item->children.at(i); if (child->type == PathItem && child->name == branch) { item = child; -- cgit v1.2.3