diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 08:17:22 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 18:20:17 +0200 |
commit | c338447261878111df7198fbd96051926464e865 (patch) | |
tree | d21b5af1efae225f75d5c05dfe370daefb1ea1d1 /src/qdbus/qdbusviewer/qdbusmodel.cpp | |
parent | 6495329e6de803025e6e4e8291b648f94893551c (diff) |
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(<classes>)))).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 <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/qdbus/qdbusviewer/qdbusmodel.cpp')
-rw-r--r-- | src/qdbus/qdbusviewer/qdbusmodel.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
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<QDBusModel *>(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; |