summaryrefslogtreecommitdiffstats
path: root/src/plugins
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 /src/plugins
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 'src/plugins')
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp6
-rw-r--r--src/plugins/platforms/xcb/qxcbclipboard.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbsessionmanager.cpp2
-rw-r--r--src/plugins/printsupport/cups/qcupsprintersupport.cpp2
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp4
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp4
6 files changed, 10 insertions, 10 deletions
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 145352973d..a304963669 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -39,7 +39,7 @@ QTuioHandler::QTuioHandler(const QString &specification)
bool invertx = false;
bool inverty = false;
- for (int i = 0; i < args.count(); ++i) {
+ for (int i = 0; i < args.size(); ++i) {
if (args.at(i).startsWith("udp=")) {
QString portString = args.at(i).section('=', 1, 1);
portNumber = portString.toInt();
@@ -326,7 +326,7 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
- if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ if (!win && QGuiApplication::topLevelWindows().size() > 0 && forceDelivery)
win = QGuiApplication::topLevelWindows().at(0);
if (!win)
@@ -499,7 +499,7 @@ void QTuioHandler::process2DObjFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
- if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ if (!win && QGuiApplication::topLevelWindows().size() > 0 && forceDelivery)
win = QGuiApplication::topLevelWindows().at(0);
if (!win)
diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp
index 6c15d7c142..7c3a9d0741 100644
--- a/src/plugins/platforms/xcb/qxcbclipboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp
@@ -56,7 +56,7 @@ protected:
if (isEmpty())
return QStringList();
- if (!formatList.count()) {
+ if (!formatList.size()) {
QXcbClipboardMime *that = const_cast<QXcbClipboardMime *>(this);
// get the list of targets from the current clipboard owner - we do this
// once so that multiple calls to this function don't require multiple
diff --git a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
index 3d1229044c..b4e28ab831 100644
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
@@ -108,7 +108,7 @@ static void sm_setProperty(const QString &name, const QString &value)
static void sm_setProperty(const QString &name, const QStringList &value)
{
- SmPropValue *prop = new SmPropValue[value.count()];
+ SmPropValue *prop = new SmPropValue[value.size()];
int count = 0;
QList<QByteArray> vl;
vl.reserve(value.size());
diff --git a/src/plugins/printsupport/cups/qcupsprintersupport.cpp b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
index 539cd55c54..40381097d2 100644
--- a/src/plugins/printsupport/cups/qcupsprintersupport.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintersupport.cpp
@@ -57,7 +57,7 @@ static const char *getPasswordCB(const char */*prompt*/, http_t *http, const cha
QString resourceString = QString::fromLocal8Bit(resource);
if (resourceString.startsWith(QStringLiteral("/printers/")))
- resourceString = resourceString.mid(QStringLiteral("/printers/").length());
+ resourceString = resourceString.mid(QStringLiteral("/printers/").size());
QLabel *label = new QLabel();
if (hostname == QStringLiteral("localhost")) {
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 487b02784e..95813c90fa 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -428,7 +428,7 @@ bool QPpdPrintDevice::setProperty(QPrintDevice::PrintDevicePropertyKey key, cons
{
if (key == PDPK_PpdOption) {
const QStringList values = value.toStringList();
- if (values.count() == 2) {
+ if (values.size() == 2) {
ppdMarkOption(m_ppd, values[0].toLatin1(), values[1].toLatin1());
return true;
}
@@ -441,7 +441,7 @@ bool QPpdPrintDevice::isFeatureAvailable(QPrintDevice::PrintDevicePropertyKey ke
{
if (key == PDPK_PpdChoiceIsInstallableConflict) {
const QStringList values = params.toStringList();
- if (values.count() == 2)
+ if (values.size() == 2)
return ppdInstallableConflict(m_ppd, values[0].toLatin1(), values[1].toLatin1());
}
diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 301e45d2c9..6812addae1 100644
--- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -779,7 +779,7 @@ void QSQLiteDriver::close()
for (QSQLiteResult *result : std::as_const(d->results))
result->d_func()->finalize();
- if (d->access && (d->notificationid.count() > 0)) {
+ if (d->access && (d->notificationid.size() > 0)) {
d->notificationid.clear();
sqlite3_update_hook(d->access, nullptr, nullptr);
}
@@ -990,7 +990,7 @@ bool QSQLiteDriver::subscribeToNotification(const QString &name)
//sqlite supports only one notification callback, so only the first is registered
d->notificationid << name;
- if (d->notificationid.count() == 1)
+ if (d->notificationid.size() == 1)
sqlite3_update_hook(d->access, &handle_sqlite_callback, reinterpret_cast<void *> (this));
return true;