diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-09-30 14:09:04 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-04 07:40:08 +0200 |
commit | df9d882d41b741fef7c5beeddb0abe9d904443d8 (patch) | |
tree | 6f3e90dacad4581b7f1cabe235cca298833a3da4 /src/widgets/widgets/qmainwindowlayout.cpp | |
parent | 109e088c7c5d0c9325966e88d55fd9f7a58f67ea (diff) |
Port from container.count()/length() to size()
This is semantic patch using ClangTidyTransformator:
auto QtContainerClass = 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'.
<classes> are:
// sequential:
"QByteArray",
"QList",
"QQueue",
"QStack",
"QString",
"QVarLengthArray",
"QVector",
// associative:
"QHash",
"QMultiHash",
"QMap",
"QMultiMap",
"QSet",
// Qt has no QMultiSet
Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/widgets/qmainwindowlayout.cpp')
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index dc90731c68..5ba065f084 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -106,7 +106,7 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QSt indent += " "_L1; - for (int i = 0; i < layout.item_list.count(); ++i) { + for (int i = 0; i < layout.item_list.size(); ++i) { qout << indent << "Item: " << i << '\n'; dumpLayout(qout, layout.item_list.at(i), indent + " "_L1); } @@ -366,7 +366,7 @@ QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const } } if (!dw) { - for (int i = 0; !dw && i < info->item_list.count(); ++i) { + for (int i = 0; !dw && i < info->item_list.size(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); if (item.skip()) continue; @@ -1470,7 +1470,7 @@ inline static Qt::DockWidgetArea toDockWidgetArea(int pos) #if QT_CONFIG(dockwidget) static bool isAreaAllowed(QWidget *widget, const QList<int> &path) { - Q_ASSERT_X((path.count() > 1), "isAreaAllowed", "invalid path size"); + Q_ASSERT_X((path.size() > 1), "isAreaAllowed", "invalid path size"); const Qt::DockWidgetArea area = toDockWidgetArea(path[1]); // Read permissions directly from a single dock widget @@ -1485,7 +1485,7 @@ static bool isAreaAllowed(QWidget *widget, const QList<int> &path) if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) { const QList<QDockWidget *> children = dwgw->findChildren<QDockWidget *>(QString(), Qt::FindDirectChildrenOnly); - if (children.count() == 1) { + if (children.size() == 1) { // Group window has a single child => read its permissions const bool allowed = children.at(0)->isAreaAllowed(area); if (!allowed) @@ -1493,7 +1493,7 @@ static bool isAreaAllowed(QWidget *widget, const QList<int> &path) return allowed; } else { // Group window has more than one or no children => dock it anywhere - qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "has" << children.count() << "children:"; + qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "has" << children.size() << "children:"; qCDebug(lcQpaDockWidgets) << children; qCDebug(lcQpaDockWidgets) << "DockWidgetGroupWindow" << widget << "can dock at" << area << "and anywhere else."; return true; |